create-lxc: fix tty1 auto-login regex (Alpine uses empty id field)

The previous sed pattern required ^tty1::respawn: but Alpine's LXC
inittab has no id field — the line is ::respawn:/sbin/getty 38400 tty1.
Match any line containing "getty.*tty1$" instead, and pkill getty after
the reload so init respawns with the new command.
This commit is contained in:
d4nn13 committed 2026-04-19 19:34:13 +02:00
1 parent 33d713f95b
commit 14fad9a49e
1 file changed
+6 -5
+6 -5
View File
@@ -142,13 +142,14 @@ exec /bin/login -f root
AUTOLOGIN
pct exec "$VMID" -- sh -c '
# Replace the tty1 getty line; if none exists, append one.
if grep -qE "^tty1::" /etc/inittab; then
sed -i "s|^tty1::respawn:.*|tty1::respawn:/sbin/getty -n -l /usr/local/sbin/autologin-root 38400 tty1|" /etc/inittab
else
# Drop ANY existing getty line for tty1 (Alpine LXC inittab uses an empty
# id field: "::respawn:/sbin/getty 38400 tty1"), then add the auto-login
# variant with an explicit id so our line wins on any future re-run.
sed -i -E "/getty.*tty1$/d" /etc/inittab
echo "tty1::respawn:/sbin/getty -n -l /usr/local/sbin/autologin-root 38400 tty1" >> /etc/inittab
fi
# Reload init and kick any running getty so it respawns from the new config.
kill -HUP 1 2>/dev/null || true
pkill -KILL getty 2>/dev/null || true
'
# --- optional: start web UI -------------------------------------------------