Wednesday, August 12, 2015

mgetty in systemd for modem dial-in server

I used to have a modem dial-in server as an out-of-band management for key network elements. The idea was to call the server over the GSM from another place with minicom, connect to the terminal of the server and then use another serial consoles that was connected from the server to routers, switches etc...

So far so good, I used to have a simple /etc/inittab line like this:

T3:23:respawn:/sbin/mgetty -D -s 115200 ttyS0

But... The fucking almighty systemd came to create hell on earth for Linux users... No /etc/inittab anymore, no nothing. Well, UTFG, so I get completely wrong advice to try:

# systemctl start getty@ttyS0.service

And that's it... (?) No, it isn't! It simply does not accept the call, because it uses agetty and agetty can't do that or it is not configured or whatever.

After one particularly hot, unpleasant and exhausting afternoon spent on experimenting with this I came to following config for systemd that works for me (place it to /etc/systemd/system/mgetty.service):

[Unit]
Description=Smart Modem Getty(mgetty)
Documentation=man:mgetty(8)
Requires=systemd-udev-settle.service
After=systemd-udev-settle.service

[Service]
Type=simple
ExecStart=/sbin/mgetty -D -s 115200 /dev/ttyS0
Restart=always
PIDFile=/var/run/mgetty.pid.ttyS0

[Install]
WantedBy=multi-user.target

And of course:

# systemctl start mgetty.service
# systemctl enable mgetty.service

I hate systemd! I really do. But I'll learn about it. It has spread to all reasonable distros like a nasty infection so we have to learn living with it, I guess.

1 comment:

  1. Thanks. Finally surrendered to systemd since it seemed inevitable, and needed my trusty faxmodem still receiving for legal documents.

    ReplyDelete