Setting the Login Message
rset
is designed to run scripts on remote hosts, however it is also possible to
pull in some context from your local environment. Starting with the 2.1
release, 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 apu4d2/motd >> /etc/motd
This works, but doesn't give us a diff of changes. To accomplish this, we can construct a new file to install
motd: → head -n 1 /etc/motd > motd.new → cat xa10/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 xa10/motd` → Last configured by $CONFIGURE_USER from $CONFIGURE_HOST → EOF