memo

2011-07-16

systemd な環境で sulogin を置いておく

systemd + pam_systemd な環境で dbus が死んじゃってログインすらできない、 みたいなことが過去に2回くらいはあったので、そういう緊急時のために tty11 あたりに sulogin を置いておく方法。

/etc/systemd/system/sulogin@.service:

[Unit]
Description=sulogin on %I
ConditionPathExists=/dev/tty0

[Service]
Environment=TERM=linux
ExecStart=-/sbin/agetty -n -l /sbin/sulogin %I 38400
Restart=always
RestartSec=0
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
KillMode=process
IgnoreSIGPIPE=no

# Unset locale for the console getty since the console has problems
# displaying some internationalized messages.
Environment=LANG= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION=

# Some login implementations ignore SIGTERM, so we send SIGHUP
# instead, to ensure that login terminates cleanly.
KillSignal=SIGHUP

[Install]
Alias=multi-user.target.wants/sulogin@tty11.service

んで systemctl enable sulogin@.service