fix: Multiple distro issues from testing
Devuan: - Fixed sed syntax error: replaced -E with BRE, removed invalid [^$] pattern - Simplified regex patterns for inittab autologin matching openEuler: - Added template patching to inject /etc/redhat-release before pct create - This fixes 'error in setup task PVE::LXC::Setup::post_create_hook' - Reverted to unprivileged container (privileged not needed with patch) openSUSE: - Added --gpg-auto-import-keys to zypper to avoid interactive GPG prompts - This was causing the 15+ minute hangs during package manager init Gentoo: - Changed to use emerge-webrsync (http) instead of emerge --sync (rsync) - webrsync is significantly faster than full rsync sync - Install curl FIRST before other packages (required for install.func) - Better error handling with separate curl check Rocky Linux DNS issue: - Not a script bug - container network/DNS not working - User should check container gateway and DNS settings
This commit is contained in:
parent
b8afdab106
commit
3d6a5f58b0
@ -5,10 +5,9 @@ source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxV
|
||||
# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
|
||||
# Source: https://www.openeuler.org/
|
||||
|
||||
# NOTE: openEuler requires privileged container due to PVE limitation
|
||||
# PVE's post_create_hook expects /etc/redhat-release which openEuler doesn't have
|
||||
# This causes "unable to create CT - error in setup task PVE::LXC::Setup::post_create_hook"
|
||||
# Setting var_unprivileged=0 creates privileged container which bypasses this check
|
||||
# NOTE: openEuler has a PVE compatibility issue
|
||||
# PVE's post_create_hook expects /etc/redhat-release which openEuler doesn't have by default
|
||||
# We handle this in build.func by creating the file after container creation
|
||||
|
||||
APP="openEuler"
|
||||
var_tags="${var_tags:-os}"
|
||||
@ -17,7 +16,7 @@ var_ram="${var_ram:-512}"
|
||||
var_disk="${var_disk:-4}"
|
||||
var_os="${var_os:-openeuler}"
|
||||
var_version="${var_version:-25.03}"
|
||||
var_unprivileged="${var_unprivileged:-0}"
|
||||
var_unprivileged="${var_unprivileged:-1}"
|
||||
|
||||
header_info "$APP"
|
||||
variables
|
||||
|
||||
@ -3326,13 +3326,14 @@ EOF'
|
||||
|
||||
opensuse)
|
||||
# openSUSE - special handling for terminal/locale issues
|
||||
# Use --gpg-auto-import-keys to avoid interactive prompts that cause hangs
|
||||
msg_info "Initializing package manager for openSUSE..."
|
||||
pct exec "$CTID" -- bash -c "zypper --non-interactive refresh 2>&1" >/dev/null 2>&1 || true
|
||||
pct exec "$CTID" -- bash -c "zypper --gpg-auto-import-keys --non-interactive refresh 2>&1" >/dev/null 2>&1 || true
|
||||
|
||||
# Install packages - ncurses and terminfo are CRITICAL for terminal to work
|
||||
if ! pct exec "$CTID" -- bash -c "zypper --non-interactive install -y curl sudo mc jq glibc-locale ncurses terminfo-base 2>&1" >/dev/null 2>&1; then
|
||||
if ! pct exec "$CTID" -- bash -c "zypper --gpg-auto-import-keys --non-interactive install -y curl sudo mc jq glibc-locale ncurses terminfo-base 2>&1" >/dev/null 2>&1; then
|
||||
# Try without glibc-locale
|
||||
if ! pct exec "$CTID" -- bash -c "zypper --non-interactive install -y curl sudo mc jq ncurses terminfo-base 2>&1" >/dev/null 2>&1; then
|
||||
if ! pct exec "$CTID" -- bash -c "zypper --gpg-auto-import-keys --non-interactive install -y curl sudo mc jq ncurses terminfo-base 2>&1" >/dev/null 2>&1; then
|
||||
msg_error "zypper base packages installation failed"
|
||||
exit 1
|
||||
fi
|
||||
@ -3356,24 +3357,32 @@ chmod +x /etc/profile.d/term.sh" || true
|
||||
|
||||
gentoo)
|
||||
# Gentoo - OpenRC based, emerge is slow
|
||||
# Sync portage first (required for fresh templates)
|
||||
msg_info "Syncing Gentoo portage (this may take a while)..."
|
||||
pct exec "$CTID" -- bash -c "emerge --sync >/dev/null 2>&1 || emerge-webrsync >/dev/null 2>&1" || true
|
||||
# Use emerge-webrsync (faster, uses http instead of rsync)
|
||||
msg_info "Syncing Gentoo portage via webrsync (faster than rsync)..."
|
||||
pct exec "$CTID" -- bash -c "emerge-webrsync 2>&1" >/dev/null 2>&1 || {
|
||||
msg_warn "emerge-webrsync failed, trying emerge --sync..."
|
||||
pct exec "$CTID" -- bash -c "emerge --sync 2>&1" >/dev/null 2>&1 || true
|
||||
}
|
||||
|
||||
# Install essentials - emerge can be very slow
|
||||
if ! pct exec "$CTID" -- bash -c "emerge --quiet --noreplace app-misc/jq net-misc/curl app-misc/mc sys-libs/ncurses 2>&1" >/dev/null 2>&1; then
|
||||
msg_warn "Gentoo base packages installation incomplete - some packages may need manual setup"
|
||||
# Try just curl and jq as minimum
|
||||
pct exec "$CTID" -- bash -c "emerge --quiet --noreplace net-misc/curl app-misc/jq 2>&1" >/dev/null 2>&1 || true
|
||||
# Install curl FIRST - it's required for install.func to work
|
||||
msg_info "Installing essential packages for Gentoo..."
|
||||
if ! pct exec "$CTID" -- bash -c "emerge --quiet --noreplace net-misc/curl 2>&1" >/dev/null 2>&1; then
|
||||
msg_error "Failed to install curl on Gentoo - this is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Install remaining packages
|
||||
pct exec "$CTID" -- bash -c "emerge --quiet --noreplace app-misc/jq app-misc/mc sys-libs/ncurses 2>&1" >/dev/null 2>&1 || {
|
||||
msg_warn "Some Gentoo packages may need manual setup"
|
||||
}
|
||||
|
||||
# Set TERM for Gentoo
|
||||
pct exec "$CTID" -- bash -c "echo 'export TERM=xterm-256color' >> /etc/profile.d/term.sh && chmod +x /etc/profile.d/term.sh" || true
|
||||
;;
|
||||
|
||||
openeuler)
|
||||
# openEuler (RHEL-compatible, uses DNF)
|
||||
# Note: openEuler requires privileged container due to PVE limitation with /etc/redhat-release
|
||||
# Note: Template was patched with /etc/redhat-release in create_container
|
||||
msg_info "Initializing package manager for openEuler..."
|
||||
pct exec "$CTID" -- bash -c "dnf makecache --refresh 2>&1" >/dev/null 2>&1 || true
|
||||
|
||||
@ -4274,6 +4283,43 @@ create_lxc_container() {
|
||||
|
||||
LOGFILE="/tmp/pct_create_${CTID}_$(date +%Y%m%d_%H%M%S)_${SESSION_ID}.log"
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# openEuler Template Patch: Create /etc/redhat-release inside template
|
||||
# PVE's post_create_hook expects this file for RHEL-family OS detection
|
||||
# Without it, container creation fails with "error in setup task"
|
||||
# ------------------------------------------------------------------------------
|
||||
if [[ "${var_os:-}" == "openeuler" ]]; then
|
||||
msg_info "Patching openEuler template for PVE compatibility..."
|
||||
local TEMP_EXTRACT_DIR="/tmp/openeuler_template_patch_$$"
|
||||
local PATCHED_TEMPLATE="${TEMPLATE_PATH%.tar.xz}_patched.tar.xz"
|
||||
|
||||
# Only patch if not already patched
|
||||
if [[ ! -f "$PATCHED_TEMPLATE" ]]; then
|
||||
mkdir -p "$TEMP_EXTRACT_DIR"
|
||||
|
||||
# Extract template
|
||||
if tar -xf "$TEMPLATE_PATH" -C "$TEMP_EXTRACT_DIR" 2>/dev/null; then
|
||||
# Create /etc/redhat-release if it doesn't exist
|
||||
if [[ ! -f "$TEMP_EXTRACT_DIR/etc/redhat-release" ]]; then
|
||||
echo "openEuler release ${var_version:-25.03}" >"$TEMP_EXTRACT_DIR/etc/redhat-release"
|
||||
fi
|
||||
|
||||
# Repack template
|
||||
if tar -cJf "$PATCHED_TEMPLATE" -C "$TEMP_EXTRACT_DIR" . 2>/dev/null; then
|
||||
# Replace original with patched version
|
||||
mv "$PATCHED_TEMPLATE" "$TEMPLATE_PATH"
|
||||
msg_ok "openEuler template patched successfully"
|
||||
else
|
||||
msg_warn "Failed to repack template, trying without patch..."
|
||||
fi
|
||||
else
|
||||
msg_warn "Failed to extract template for patching, trying without patch..."
|
||||
fi
|
||||
|
||||
rm -rf "$TEMP_EXTRACT_DIR"
|
||||
fi
|
||||
fi
|
||||
|
||||
# # DEBUG: Show the actual command that will be executed
|
||||
# echo "[DEBUG] ===== PCT CREATE COMMAND DETAILS ====="
|
||||
# echo "[DEBUG] CTID: $CTID"
|
||||
|
||||
@ -906,13 +906,13 @@ EOF
|
||||
|
||||
# Try multiple patterns to catch different inittab formats
|
||||
# Pattern 1: Standard format "1:2345:respawn:/sbin/getty..."
|
||||
sed -i -E 's|^1:[0-9]*:respawn:[^ ]*(getty|agetty)[^$]*$|1:2345:respawn:/sbin/agetty --autologin root --noclear tty1 38400 linux|' /etc/inittab
|
||||
sed -i 's|^1:[0-9]*:respawn:.*/\(a\?getty\).*|1:2345:respawn:/sbin/agetty --autologin root --noclear tty1 38400 linux|' /etc/inittab
|
||||
|
||||
# Pattern 2: With console instead of tty1
|
||||
sed -i -E 's|^c1:[0-9]*:respawn:[^ ]*(getty|agetty).*console.*$|c1:2345:respawn:/sbin/agetty --autologin root --noclear console 38400 linux|' /etc/inittab
|
||||
sed -i 's|^c1:[0-9]*:respawn:.*/\(a\?getty\).*console.*|c1:2345:respawn:/sbin/agetty --autologin root --noclear console 38400 linux|' /etc/inittab
|
||||
|
||||
# Pattern 3: Devuan specific "co:2345:respawn:/sbin/getty..."
|
||||
sed -i -E 's|^co:[0-9]*:respawn:[^ ]*(getty|agetty).*$|co:2345:respawn:/sbin/agetty --autologin root --noclear console 38400 linux|' /etc/inittab
|
||||
sed -i 's|^co:[0-9]*:respawn:.*/\(a\?getty\).*|co:2345:respawn:/sbin/agetty --autologin root --noclear console 38400 linux|' /etc/inittab
|
||||
|
||||
# Pattern 4: LXC console pattern
|
||||
if ! grep -q 'autologin root' /etc/inittab; then
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user