Refactor auto-login setup for various init systems
Simplifies and improves auto-login configuration for systemd, openrc, and sysvinit. Removes unnecessary service reloads and restarts during installation, and directly modifies configuration files where appropriate.
This commit is contained in:
parent
19a2d83c5a
commit
f799a11348
@ -854,39 +854,40 @@ customize() {
|
|||||||
case "$INIT_SYSTEM" in
|
case "$INIT_SYSTEM" in
|
||||||
systemd)
|
systemd)
|
||||||
# Configure getty for auto-login
|
# Configure getty for auto-login
|
||||||
local GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf"
|
# Just write the config - systemd picks it up on next boot/login
|
||||||
|
# No daemon-reload or restart needed during installation!
|
||||||
|
local GETTY_OVERRIDE=""
|
||||||
|
|
||||||
|
if [[ -f /usr/lib/systemd/system/container-getty@.service ]]; then
|
||||||
|
GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf"
|
||||||
|
elif [[ -f /usr/lib/systemd/system/getty@.service ]]; then
|
||||||
|
GETTY_OVERRIDE="/etc/systemd/system/getty@tty1.service.d/override.conf"
|
||||||
|
elif [[ -f /usr/lib/systemd/system/console-getty.service ]]; then
|
||||||
|
GETTY_OVERRIDE="/etc/systemd/system/console-getty.service.d/override.conf"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$GETTY_OVERRIDE" ]]; then
|
||||||
mkdir -p "$(dirname "$GETTY_OVERRIDE")"
|
mkdir -p "$(dirname "$GETTY_OVERRIDE")"
|
||||||
cat >"$GETTY_OVERRIDE" <<EOF
|
cat >"$GETTY_OVERRIDE" <<EOF
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=
|
ExecStart=
|
||||||
ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM
|
ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM
|
||||||
EOF
|
EOF
|
||||||
svc_reload_daemon
|
fi
|
||||||
systemctl restart "$(basename "$(dirname "$GETTY_OVERRIDE")" | sed 's/\.d//')" 2>/dev/null || true
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
openrc)
|
openrc)
|
||||||
# Alpine/Gentoo: use inittab for auto-login
|
# Alpine/Gentoo: modify inittab for auto-login
|
||||||
pkg_install util-linux 2>/dev/null || true
|
if [[ -f /etc/inittab ]]; then
|
||||||
|
|
||||||
# Create persistent autologin boot script
|
|
||||||
mkdir -p /etc/local.d
|
|
||||||
cat <<'EOFSCRIPT' >/etc/local.d/autologin.start
|
|
||||||
#!/bin/sh
|
|
||||||
sed -i 's|^tty1::respawn:.*|tty1::respawn:/sbin/agetty --autologin root --noclear tty1 38400 linux|' /etc/inittab
|
sed -i 's|^tty1::respawn:.*|tty1::respawn:/sbin/agetty --autologin root --noclear tty1 38400 linux|' /etc/inittab
|
||||||
kill -HUP 1
|
fi
|
||||||
EOFSCRIPT
|
|
||||||
chmod +x /etc/local.d/autologin.start
|
|
||||||
rc-update add local 2>/dev/null || true
|
|
||||||
/etc/local.d/autologin.start 2>/dev/null || true
|
|
||||||
touch /root/.hushlogin
|
touch /root/.hushlogin
|
||||||
;;
|
;;
|
||||||
|
|
||||||
sysvinit)
|
sysvinit)
|
||||||
# Devuan/older systems
|
# Devuan/older systems - just modify inittab, no telinit needed during install
|
||||||
if [[ -f /etc/inittab ]]; then
|
if [[ -f /etc/inittab ]]; then
|
||||||
sed -i 's|^1:2345:respawn:/sbin/getty.*|1:2345:respawn:/sbin/agetty --autologin root tty1 38400 linux|' /etc/inittab
|
sed -i 's|^1:2345:respawn:/sbin/getty.*|1:2345:respawn:/sbin/agetty --autologin root tty1 38400 linux|' /etc/inittab
|
||||||
telinit q 2>/dev/null || true
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user