From b994f6a2c0f831f77626c1915a1940d498df1653 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Mon, 27 Apr 2026 14:13:41 +0200 Subject: [PATCH] Improve LXC getty autologin handling Configure both container-getty@1 and console-getty to auto-login root with unified agetty options, ensuring either Proxmox noVNC (/dev/tty1) or pct/serial (/dev/console) works. Add stable _agetty_opts, write per-service override files, enable console-getty on distros that need it, and reload systemd. Disable vte profile scripts to avoid cursor-query noise on first prompt, restart only active getty services to avoid duplicates, and create /root/.hushlogin to suppress login messages. --- misc/install.func | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/misc/install.func b/misc/install.func index 4468ee67..ec4fcea4 100644 --- a/misc/install.func +++ b/misc/install.func @@ -1171,35 +1171,44 @@ customize() { systemctl mask systemd-homed-firstboot.service &>/dev/null || true systemctl mask systemd-homed.service &>/dev/null || true - # Configure console-getty for auto-login in LXC containers - # console-getty.service is THE service that handles /dev/console in LXC - # It's present on all systemd distros but not enabled by default on Fedora/RHEL + # In LXC there are TWO possible getty paths: + # - container-getty@1.service -> /dev/tty1 (Proxmox web noVNC console) + # - console-getty.service -> /dev/console (pct console / serial) + # We configure both with --autologin --noissue (prevents banner spam from + # rapid respawns) so whichever one the user opens works. + local _agetty_opts='--autologin root --noclear --noissue --keep-baud' + + if [[ -f /usr/lib/systemd/system/container-getty@.service ]]; then + mkdir -p /etc/systemd/system/container-getty@1.service.d + cat >/etc/systemd/system/container-getty@1.service.d/override.conf </etc/systemd/system/console-getty.service.d/override.conf <<'EOF' + cat >/etc/systemd/system/console-getty.service.d/override.conf </dev/null || true fi - # Also configure container-getty@1 (Debian/Ubuntu default in LXC) - if [[ -f /usr/lib/systemd/system/container-getty@.service ]]; then - mkdir -p /etc/systemd/system/container-getty@1.service.d - cat >/etc/systemd/system/container-getty@1.service.d/override.conf <<'EOF' -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 - $TERM -EOF - fi + # Fedora/RHEL: /etc/profile.d/vte.sh emits cursor-position queries (CSI 6n) + # whose responses leak into the shell input buffer, causing + # "R;80R: command not found" garbage on the first prompt. Disable it. + [[ -f /etc/profile.d/vte.sh ]] && chmod -x /etc/profile.d/vte.sh 2>/dev/null || true + [[ -f /etc/profile.d/vte.csh ]] && chmod -x /etc/profile.d/vte.csh 2>/dev/null || true - # Reload systemd and restart getty services to apply auto-login systemctl daemon-reload - systemctl restart console-getty.service &>/dev/null || true - systemctl restart container-getty@1.service &>/dev/null || true + # Restart only what's currently active to avoid spawning duplicate gettys + systemctl is-active container-getty@1.service &>/dev/null && systemctl restart container-getty@1.service &>/dev/null || true + systemctl is-active console-getty.service &>/dev/null && systemctl restart console-getty.service &>/dev/null || true + touch /root/.hushlogin ;; openrc)