0

Longtime users of Linux and most other forms of Unix (especially those which used to have startup frameworks based on the venerable SysV init) supported a special file /etc/issue which was displayed on local consoles and serial terminals prior to the login: prompt.

I needed to do something like this for my OpenBSD portable jump hosts. I take these systems to events remotely maintain some in wiring closets (they're in the NUC form factor, not much larger than a pack of cigarettes). But I want quick, easy and unauthenticated access to the MAC and IP (DHCP) addresses (on just em0).

However, OpenBSD doesn't support /etc/issue ... so I had to hack around this with an rc.local and a gettytab.template. (Posted as an answer below).

Question: is there a better way to do this?

1 Answer 1

0

I created an /etc/gettytab template like so:

# The default gettytab entry, used to set defaults for all other
# entries, and in cases where getty is called with no table name
#
default:\
    :np:im=\r\n%s/%m\r\n{MACADDR}\r\n(%h@{IPADDR}) (%t)\r\n\r\n:sp#1200:

... where the relevant changes are the insertions of the strings \r\n{MACADDR}\r\n and @{IPADDR} in that entry. "im:" is the "issue message" field of that table?

From there I use the following snippet of code in my /etc/rc.local:

## Include IP and MAC address of em0 in login screen message:
mv ./gettytab ./gettytab.old
ifconfig em0 | egrep "(lladdr|inet) " \
   | sed 's/:/-/g' \
   | { read x macaddr x; read x ip x; 
       sed -e "s/{IPADDR}/$ip/;s/{MACADDR}/$macaddr/" ./gettytab.template 
     } > ./gettytab
## : in MAC address translated to - for compatibility with gettytab syntax

(I suppose I could try for an optimization that only changes the file if either of these variables changes; but these systems usually are moved about as often as they are rebooted ... so it's not much of a savings).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .