Sample Header Ad - 728x90

How do I adapt the /etc/issue file depending on how the terminal is attached: serial line vs. network?

0 votes
1 answer
52 views
I've got a machine running OpenSuSE Leap 15.5, which can be remote-controlled both by usign a local serial line (RS232), and via network (SSH). Now I've got an /etc/issue file auto-generated by /usr/sbin/issue-generator upon every system startup. Here is the content of /etc/issue:
Welcome to \S - Kernel \r (\l).

eth0: \4{eth0} \6{eth0}
It's obvious that the eth0 line doesn't make very much sense when accessing the machine via serial line. Here I would rather expect something like this: ttyS5 vt340 115200 8N1 And this is what /etc/sysconfig/issue-generator looks like (comments omitted):
NETWORK_INTERFACE_REGEX="^[be]"
This makes it necessary for the getty process in use (I'm using agetty for the serial line) to find out which interface the terminal is attached to and to adapt the line stated above accordingly, but how? This is the serial getty service file (comments omitted):
[Unit]
Description=Serial Getty on %I
Documentation=man:agetty(8) man:systemd-getty-generator(8)
Documentation=http://0pointer.de/blog/projects/serial-console.html 
BindsTo=dev-%i.device
After=dev-%i.device systemd-user-sessions.service plymouth-quit-wait.service getty-pre.target
After=rc-local.service

Before=getty.target
IgnoreOnIsolate=yes

Conflicts=rescue.service
Before=rescue.service

[Service]
ExecStart=-/sbin/agetty -L 115200 %I $TERM
Type=idle
Restart=always
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
IgnoreSIGPIPE=no
SendSIGHUP=yes

[Install]
WantedBy=getty.target
Asked by Neppomuk (364 rep)
Jun 29, 2025, 01:47 PM
Last activity: Jun 29, 2025, 03:40 PM