rset(1) : Formulas

Setting the Login Message

rset is designed to run scripts on remote hosts, however it is also possible to pull in some context from the environment of the initiator. The output of local commands defined between { and } is prepended to a label.

Simple Message on BSD

To quote the OpenBSD motd man page:

During system startup, a line containing the kernel version string replaces all lines up to (but not including) the first blank line of this file. Customized messages can be added to this file after that first blank line.

Therefore to properly manage this file we can delete all but the first line

motd:
→   sed -i -n '1p;' /etc/motd
→   cat ai1/motd >> /etc/motd

This works, but does not print a diff of changes. To accomplish this, we can construct a new file to install

motd:
→   head -n 1 /etc/motd > motd.new
→   cat ai1/motd >> motd.new
→   ./rinstall motd.new /etc/motd

Using Local Execution

The following demonstrates the local execution context used to customize /etc/motd with information of who ran the configuration

motd:
{
→   echo "CONFIGURE_HOST=$(hostname)"
→   echo "CONFIGURE_USER=$(whoami)"
}
→   cat > /etc/motd <<-EOF
→   `head -n 1 /etc/motd`
→   `cat ai1/motd`

→   Last configured by $CONFIGURE_USER from $CONFIGURE_HOST
→   EOF