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:
1 parent
33d713f95b
commit
14fad9a49e
1 file changed
+6
-5
@@ -142,13 +142,14 @@ exec /bin/login -f root
|
|||||||
AUTOLOGIN
|
AUTOLOGIN
|
||||||
|
|
||||||
pct exec "$VMID" -- sh -c '
|
pct exec "$VMID" -- sh -c '
|
||||||
# Replace the tty1 getty line; if none exists, append one.
|
# Drop ANY existing getty line for tty1 (Alpine LXC inittab uses an empty
|
||||||
if grep -qE "^tty1::" /etc/inittab; then
|
# id field: "::respawn:/sbin/getty 38400 tty1"), then add the auto-login
|
||||||
sed -i "s|^tty1::respawn:.*|tty1::respawn:/sbin/getty -n -l /usr/local/sbin/autologin-root 38400 tty1|" /etc/inittab
|
# variant with an explicit id so our line wins on any future re-run.
|
||||||
else
|
sed -i -E "/getty.*tty1$/d" /etc/inittab
|
||||||
echo "tty1::respawn:/sbin/getty -n -l /usr/local/sbin/autologin-root 38400 tty1" >> /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
|
kill -HUP 1 2>/dev/null || true
|
||||||
|
pkill -KILL getty 2>/dev/null || true
|
||||||
'
|
'
|
||||||
|
|
||||||
# --- optional: start web UI -------------------------------------------------
|
# --- optional: start web UI -------------------------------------------------
|
||||||
|
|||||||
Reference in new issue
Block a user