From b3f7a8667d8ba5a1e9851056595bf0d11632f0a1 Mon Sep 17 00:00:00 2001 From: Christian Hewitt Date: Sat, 21 Dec 2024 13:48:42 +0000 Subject: [PATCH] systemd: support console login when LOCAL_LOGIN is defined Signed-off-by: Christian Hewitt --- packages/sysutils/systemd/package.mk | 25 +++++++++++------ .../systemd/system.d/getty@tty0.service | 28 +++++++++++++++++++ 2 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 packages/sysutils/systemd/system.d/getty@tty0.service diff --git a/packages/sysutils/systemd/package.mk b/packages/sysutils/systemd/package.mk index 5ae7255176..1b51a5b1ea 100644 --- a/packages/sysutils/systemd/package.mk +++ b/packages/sysutils/systemd/package.mk @@ -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 } diff --git a/packages/sysutils/systemd/system.d/getty@tty0.service b/packages/sysutils/systemd/system.d/getty@tty0.service new file mode 100644 index 0000000000..68226b1c2b --- /dev/null +++ b/packages/sysutils/systemd/system.d/getty@tty0.service @@ -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