systemd: support console login when LOCAL_LOGIN is defined

Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
This commit is contained in:
Christian Hewitt 2024-12-21 13:48:42 +00:00
parent 7c87a7acdf
commit b3f7a8667d
No known key found for this signature in database
2 changed files with 45 additions and 8 deletions

View File

@ -134,14 +134,16 @@ post_makeinstall_target() {
safe_remove ${INSTALL}/usr/lib/udev/rules.d/71-seat.rules
safe_remove ${INSTALL}/usr/lib/udev/rules.d/73-seat-late.rules
# remove getty units, we dont want a console
safe_remove ${INSTALL}/usr/lib/systemd/system/autovt@.service
safe_remove ${INSTALL}/usr/lib/systemd/system/console-getty.service
safe_remove ${INSTALL}/usr/lib/systemd/system/container-getty@.service
safe_remove ${INSTALL}/usr/lib/systemd/system/getty.target
safe_remove ${INSTALL}/usr/lib/systemd/system/getty@.service
safe_remove ${INSTALL}/usr/lib/systemd/system/serial-getty@.service
safe_remove ${INSTALL}/usr/lib/systemd/system/*.target.wants/getty.target
if [ "${LOCAL_LOGIN}" = "no" ]; then
# remove getty units, we dont want a console
safe_remove ${INSTALL}/usr/lib/systemd/system/autovt@.service
safe_remove ${INSTALL}/usr/lib/systemd/system/console-getty.service
safe_remove ${INSTALL}/usr/lib/systemd/system/container-getty@.service
safe_remove ${INSTALL}/usr/lib/systemd/system/getty.target
safe_remove ${INSTALL}/usr/lib/systemd/system/getty@.service
safe_remove ${INSTALL}/usr/lib/systemd/system/serial-getty@.service
safe_remove ${INSTALL}/usr/lib/systemd/system/*.target.wants/getty.target
fi
# remove other notused or nonsense stuff (our /etc is ro)
safe_remove ${INSTALL}/usr/lib/systemd/systemd-update-done
@ -206,6 +208,10 @@ post_makeinstall_target() {
sed -e "s,^.*SystemMaxUse=.*$,SystemMaxUse=10M,g" -i ${INSTALL}/etc/systemd/journald.conf
# tune logind.conf
if [ "${LOCAL_LOGIN}" = "yes" ]; then
sed -e "s,^.*NAutoVTs=.*$,NAutoVTs=2,g" -i ${INSTALL}/etc/systemd/logind.conf
sed -e "s,^.*ReserveVT=.*$,ReserveVT=6,g" -i ${INSTALL}/etc/systemd/logind.conf
fi
sed -e "s,^.*HandleLidSwitch=.*$,HandleLidSwitch=ignore,g" -i ${INSTALL}/etc/systemd/logind.conf
if [ "${DISPLAYSERVER}" = "no" ]; then
sed -e "s,^.*HandlePowerKey=.*$,HandlePowerKey=poweroff,g" -i ${INSTALL}/etc/systemd/logind.conf
@ -308,4 +314,7 @@ post_install() {
enable_service systemd-timesyncd.service
enable_service systemd-timesyncd-setup.service
enable_service systemd-userdbd.socket
if [ "${LOCAL_LOGIN}" = "yes" ]; then
enable_service getty@tty0.service
fi
}

View File

@ -0,0 +1,28 @@
[Unit]
Description=Getty on %I
After=getty-pre.target
Before=getty.target
IgnoreOnIsolate=yes
ConditionPathExists=/dev/tty0
[Service]
ExecStart=-/sbin/agetty -o '-p -- \\u' --noissue --noclear --nohostname - $TERM
Type=idle
Restart=always
RestartSec=0
UtmpIdentifier=%I
StandardInput=tty
StandardOutput=tty
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
IgnoreSIGPIPE=no
SendSIGHUP=yes
ImportCredential=agetty.*
ImportCredential=login.*
UnsetEnvironment=LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION
[Install]
WantedBy=getty.target
DefaultInstance=tty1