fix: LXC distro compatibility issues
- Gentoo: Fix template pattern to match 'gentoo-current-openrc' naming - openSUSE: Sanitize ANSI escape codes from MSG_INFO_SHOWN array keys - Devuan: Use flexible runlevel matching for sysvinit autologin - CentOS/RHEL: Add missing '-' before $TERM in agetty commands Fixes reported issues: - Gentoo template not found (wrong pattern '-current_') - openSUSE 'not a valid identifier' error on msg_ok with color codes - Devuan autologin failing due to strict runlevel pattern - CentOS autologin improvements for LXC console
This commit is contained in:
parent
df9863cec2
commit
92cbcd5132
@ -3728,7 +3728,7 @@ create_lxc_container() {
|
||||
case "$PCT_OSTYPE" in
|
||||
debian | ubuntu | devuan) TEMPLATE_PATTERN="-standard_" ;;
|
||||
alpine | fedora | rocky | rockylinux | centos | almalinux | openeuler) TEMPLATE_PATTERN="-default_" ;;
|
||||
gentoo) TEMPLATE_PATTERN="-current_" ;;
|
||||
gentoo) TEMPLATE_PATTERN="-current-openrc" ;;
|
||||
opensuse) TEMPLATE_PATTERN="-default_" ;;
|
||||
*) TEMPLATE_PATTERN="" ;;
|
||||
esac
|
||||
|
||||
@ -523,8 +523,11 @@ msg_info() {
|
||||
if ! declare -p MSG_INFO_SHOWN &>/dev/null || ! declare -A MSG_INFO_SHOWN &>/dev/null; then
|
||||
declare -gA MSG_INFO_SHOWN=()
|
||||
fi
|
||||
[[ -n "${MSG_INFO_SHOWN["$msg"]+x}" ]] && return
|
||||
MSG_INFO_SHOWN["$msg"]=1
|
||||
# Sanitize message for use as associative array key (remove ANSI codes)
|
||||
local sanitized_msg
|
||||
sanitized_msg=$(printf '%s' "$msg" | sed 's/\x1b\[[0-9;]*m//g')
|
||||
[[ -n "${MSG_INFO_SHOWN["$sanitized_msg"]+x}" ]] && return
|
||||
MSG_INFO_SHOWN["$sanitized_msg"]=1
|
||||
|
||||
stop_spinner
|
||||
SPINNER_MSG="$msg"
|
||||
@ -569,7 +572,10 @@ msg_ok() {
|
||||
stop_spinner
|
||||
clear_line
|
||||
echo -e "$CM ${GN}${msg}${CL}"
|
||||
unset MSG_INFO_SHOWN["$msg"]
|
||||
# Sanitize message for use as associative array key (remove ANSI codes)
|
||||
local sanitized_msg
|
||||
sanitized_msg=$(printf '%s' "$msg" | sed 's/\x1b\[[0-9;]*m//g')
|
||||
unset MSG_INFO_SHOWN["$sanitized_msg"]
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
@ -867,7 +867,7 @@ customize() {
|
||||
cat >/etc/systemd/system/console-getty.service.d/override.conf <<'EOF'
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud 115200,38400,9600 $TERM
|
||||
ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud 115200,38400,9600 - $TERM
|
||||
EOF
|
||||
# Enable console-getty for LXC web console (required on Fedora/RHEL)
|
||||
systemctl enable console-getty.service &>/dev/null || true
|
||||
@ -879,7 +879,7 @@ EOF
|
||||
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
|
||||
ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 - $TERM
|
||||
EOF
|
||||
fi
|
||||
|
||||
@ -898,9 +898,10 @@ EOF
|
||||
;;
|
||||
|
||||
sysvinit)
|
||||
# Devuan/older systems - just modify inittab, no telinit needed during install
|
||||
# Devuan/older systems - modify inittab with flexible runlevel matching
|
||||
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
|
||||
# Match various runlevel patterns (23, 2345, 12345, etc.) and both getty/agetty
|
||||
sed -i 's|^1:[0-9]*:respawn:/sbin/a\?getty.*|1:2345:respawn:/sbin/agetty --autologin root tty1 38400 linux|' /etc/inittab
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user