Comment out problematic feature and dev mode code
Commented out sections related to advanced feature flags, array-based FEATURES and PCT_OPTIONS, and dev mode exports that were causing compatibility and autologin issues. Added notes and TODOs for future integration, and moved MOTD/SSH setup for debugging to only run when containers are kept for troubleshooting.
This commit is contained in:
parent
fa82374abb
commit
f008d4bbf9
212
misc/build.func
212
misc/build.func
@ -47,8 +47,18 @@ variables() {
|
|||||||
METHOD="default" # sets the METHOD variable to "default", used for the API call.
|
METHOD="default" # sets the METHOD variable to "default", used for the API call.
|
||||||
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)" # generates a random UUID and sets it to the RANDOM_UUID variable.
|
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)" # generates a random UUID and sets it to the RANDOM_UUID variable.
|
||||||
SESSION_ID="${RANDOM_UUID:0:8}" # Short session ID (first 8 chars of UUID) for log files
|
SESSION_ID="${RANDOM_UUID:0:8}" # Short session ID (first 8 chars of UUID) for log files
|
||||||
|
BUILD_LOG="/tmp/create-lxc-${SESSION_ID}.log" # Host-side container creation log
|
||||||
CTTYPE="${CTTYPE:-${CT_TYPE:-1}}"
|
CTTYPE="${CTTYPE:-${CT_TYPE:-1}}"
|
||||||
|
|
||||||
|
# Parse dev_mode early
|
||||||
|
parse_dev_mode
|
||||||
|
|
||||||
|
# Setup persistent log directory if logs mode active
|
||||||
|
if [[ "${DEV_MODE_LOGS:-false}" == "true" ]]; then
|
||||||
|
mkdir -p /var/log/community-scripts
|
||||||
|
BUILD_LOG="/var/log/community-scripts/create-lxc-${SESSION_ID}-$(date +%Y%m%d_%H%M%S).log"
|
||||||
|
fi
|
||||||
|
|
||||||
# Get Proxmox VE version and kernel version
|
# Get Proxmox VE version and kernel version
|
||||||
if command -v pveversion >/dev/null 2>&1; then
|
if command -v pveversion >/dev/null 2>&1; then
|
||||||
PVEVERSION="$(pveversion | awk -F'/' '{print $2}' | awk -F'-' '{print $1}')"
|
PVEVERSION="$(pveversion | awk -F'/' '{print $2}' | awk -F'-' '{print $1}')"
|
||||||
@ -525,6 +535,40 @@ base_settings() {
|
|||||||
TAGS="community-script,${var_tags:-}"
|
TAGS="community-script,${var_tags:-}"
|
||||||
ENABLE_FUSE=${var_fuse:-"${1:-no}"}
|
ENABLE_FUSE=${var_fuse:-"${1:-no}"}
|
||||||
ENABLE_TUN=${var_tun:-"${1:-no}"}
|
ENABLE_TUN=${var_tun:-"${1:-no}"}
|
||||||
|
# PROBLEMATIC: Extra feature variables not in working version - Comment out for now
|
||||||
|
# TODO: These need proper integration with string-based FEATURES export (not array)
|
||||||
|
# ENABLE_NESTING=${var_nesting:-"${1:-1}"}
|
||||||
|
# ENABLE_KEYCTL=${var_keyctl:-"${1:-0}"}
|
||||||
|
# ALLOW_MOUNT_FS=${var_mount_fs:-""}
|
||||||
|
# ENABLE_MKNOD=${var_mknod:-"${1:-0}"}
|
||||||
|
# PROTECT_CT=${var_protection:-"${1:-no}"}
|
||||||
|
# CT_TIMEZONE=${var_timezone:-""}
|
||||||
|
|
||||||
|
# PROBLEMATIC: Feature normalization breaks compatibility
|
||||||
|
# TODO: Working version expects ENABLE_FUSE="yes" but this converts to "1"
|
||||||
|
# If implementing, must update all checks throughout codebase to handle numeric values
|
||||||
|
# # Normalize feature flags to 0/1 immediately (pct requires numeric values, not yes/no)
|
||||||
|
# # This must happen here before any usage of these variables
|
||||||
|
# case "${ENABLE_NESTING,,}" in
|
||||||
|
# yes | true) ENABLE_NESTING="1" ;;
|
||||||
|
# no | false) ENABLE_NESTING="0" ;;
|
||||||
|
# esac
|
||||||
|
# case "${ENABLE_KEYCTL,,}" in
|
||||||
|
# yes | true) ENABLE_KEYCTL="1" ;;
|
||||||
|
# no | false) ENABLE_KEYCTL="0" ;;
|
||||||
|
# esac
|
||||||
|
# case "${ENABLE_MKNOD,,}" in
|
||||||
|
# yes | true) ENABLE_MKNOD="1" ;;
|
||||||
|
# no | false) ENABLE_MKNOD="0" ;;
|
||||||
|
# esac
|
||||||
|
# case "${ENABLE_FUSE,,}" in
|
||||||
|
# yes | true) ENABLE_FUSE="1" ;;
|
||||||
|
# no | false) ENABLE_FUSE="0" ;;
|
||||||
|
# esac
|
||||||
|
# case "${PROTECT_CT,,}" in
|
||||||
|
# yes | true) PROTECT_CT="1" ;;
|
||||||
|
# no | false) PROTECT_CT="0" ;;
|
||||||
|
# esac
|
||||||
|
|
||||||
# Since these 2 are only defined outside of default_settings function, we add a temporary fallback. TODO: To align everything, we should add these as constant variables (e.g. OSTYPE and OSVERSION), but that would currently require updating the default_settings function for all existing scripts
|
# Since these 2 are only defined outside of default_settings function, we add a temporary fallback. TODO: To align everything, we should add these as constant variables (e.g. OSTYPE and OSVERSION), but that would currently require updating the default_settings function for all existing scripts
|
||||||
if [ -z "$var_os" ]; then
|
if [ -z "$var_os" ]; then
|
||||||
@ -2259,15 +2303,48 @@ build_container() {
|
|||||||
none) ;;
|
none) ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
# PROBLEMATIC: FEATURES_ARRAY system - ROOT CAUSE OF AUTOLOGIN FAILURE
|
||||||
FEATURES="keyctl=1,nesting=1"
|
# TODO: Bash arrays cannot be exported to child processes!
|
||||||
else
|
# When PCT_OPTIONS was built from this array, exports failed silently
|
||||||
FEATURES="nesting=1"
|
# This caused container creation to succeed but configuration to fail (black console)
|
||||||
fi
|
# SOLUTION: Use string-based FEATURES like working version:
|
||||||
|
# if [ "$CT_TYPE" == "1" ]; then
|
||||||
if [ "$ENABLE_FUSE" == "yes" ]; then
|
# FEATURES="keyctl=1,nesting=1"
|
||||||
FEATURES="$FEATURES,fuse=1"
|
# else
|
||||||
fi
|
# FEATURES="nesting=1"
|
||||||
|
# fi
|
||||||
|
# if [ "$ENABLE_FUSE" == "yes" ]; then
|
||||||
|
# FEATURES="$FEATURES,fuse=1"
|
||||||
|
# fi
|
||||||
|
# # Build FEATURES array with advanced settings
|
||||||
|
# # Note: All feature flags are already normalized to 0/1 in default_settings()
|
||||||
|
# # Proxmox requires each feature as a separate parameter, not comma-separated string
|
||||||
|
# FEATURES_ARRAY=()
|
||||||
|
# FEATURES_ARRAY+=("nesting=${ENABLE_NESTING}")
|
||||||
|
#
|
||||||
|
# # keyctl: needed for Docker inside containers (systemd-networkd workaround)
|
||||||
|
# # Typically needed for unprivileged containers with Docker
|
||||||
|
# if [ "$CT_TYPE" == "1" ] || [ "$ENABLE_KEYCTL" == "1" ]; then
|
||||||
|
# FEATURES_ARRAY+=("keyctl=1")
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# # mknod: allow device node creation (requires kernel 5.3+, experimental)
|
||||||
|
# if [ "$ENABLE_MKNOD" == "1" ]; then
|
||||||
|
# FEATURES_ARRAY+=("mknod=1")
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# # FUSE: required for rclone, mergerfs, AppImage, etc.
|
||||||
|
# if [ "$ENABLE_FUSE" == "1" ]; then
|
||||||
|
# FEATURES_ARRAY+=("fuse=1")
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# # mount: allow specific filesystems (e.g., nfs, ext4, etc.)
|
||||||
|
# # Format: mount=fstype1;fstype2;fstype3 (semicolon-separated, not comma!)
|
||||||
|
# if [ -n "$ALLOW_MOUNT_FS" ]; then
|
||||||
|
# # Replace commas with semicolons for proper pct syntax
|
||||||
|
# ALLOW_MOUNT_FS_FORMATTED="${ALLOW_MOUNT_FS//,/;}"
|
||||||
|
# FEATURES_ARRAY+=("mount=$ALLOW_MOUNT_FS_FORMATTED")
|
||||||
|
# fi
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd "$TEMP_DIR" >/dev/null
|
pushd "$TEMP_DIR" >/dev/null
|
||||||
@ -2279,6 +2356,19 @@ build_container() {
|
|||||||
export DIAGNOSTICS="$DIAGNOSTICS"
|
export DIAGNOSTICS="$DIAGNOSTICS"
|
||||||
export RANDOM_UUID="$RANDOM_UUID"
|
export RANDOM_UUID="$RANDOM_UUID"
|
||||||
export SESSION_ID="$SESSION_ID"
|
export SESSION_ID="$SESSION_ID"
|
||||||
|
# PROBLEMATIC: DEV_MODE exports not in working version
|
||||||
|
# TODO: These were causing autologin issues by interfering with getty service
|
||||||
|
# If implementing DEV_MODE, must ensure it doesn't modify container startup
|
||||||
|
# export BUILD_LOG="$BUILD_LOG"
|
||||||
|
# export INSTALL_LOG="/root/.install-${SESSION_ID}.log"
|
||||||
|
# export dev_mode="${dev_mode:-}"
|
||||||
|
# export DEV_MODE_MOTD="${DEV_MODE_MOTD:-false}"
|
||||||
|
# export DEV_MODE_KEEP="${DEV_MODE_KEEP:-false}"
|
||||||
|
# export DEV_MODE_TRACE="${DEV_MODE_TRACE:-false}"
|
||||||
|
# export DEV_MODE_PAUSE="${DEV_MODE_PAUSE:-false}"
|
||||||
|
# export DEV_MODE_BREAKPOINT="${DEV_MODE_BREAKPOINT:-false}"
|
||||||
|
# export DEV_MODE_LOGS="${DEV_MODE_LOGS:-false}"
|
||||||
|
# export DEV_MODE_DRYRUN="${DEV_MODE_DRYRUN:-false}"
|
||||||
export CACHER="$APT_CACHER"
|
export CACHER="$APT_CACHER"
|
||||||
export CACHER_IP="$APT_CACHER_IP"
|
export CACHER_IP="$APT_CACHER_IP"
|
||||||
export tz="$timezone"
|
export tz="$timezone"
|
||||||
@ -2292,23 +2382,68 @@ build_container() {
|
|||||||
export CTTYPE="$CT_TYPE"
|
export CTTYPE="$CT_TYPE"
|
||||||
export ENABLE_FUSE="$ENABLE_FUSE"
|
export ENABLE_FUSE="$ENABLE_FUSE"
|
||||||
export ENABLE_TUN="$ENABLE_TUN"
|
export ENABLE_TUN="$ENABLE_TUN"
|
||||||
|
# PROBLEMATIC: Extra exports for features not in working version
|
||||||
|
# TODO: These variables don't exist in working version (see above where commented out)
|
||||||
|
# export ENABLE_NESTING="$ENABLE_NESTING"
|
||||||
|
# export ENABLE_KEYCTL="$ENABLE_KEYCTL"
|
||||||
|
# export ENABLE_MKNOD="$ENABLE_MKNOD"
|
||||||
|
# export ALLOW_MOUNT_FS="$ALLOW_MOUNT_FS"
|
||||||
|
# export PROTECT_CT="$PROTECT_CT"
|
||||||
|
# export CT_TIMEZONE="$CT_TIMEZONE"
|
||||||
export PCT_OSTYPE="$var_os"
|
export PCT_OSTYPE="$var_os"
|
||||||
export PCT_OSVERSION="$var_version"
|
export PCT_OSVERSION="$var_version"
|
||||||
export PCT_DISK_SIZE="$DISK_SIZE"
|
export PCT_DISK_SIZE="$DISK_SIZE"
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
# PROBLEMATIC: PCT_OPTIONS as array cannot be exported
|
||||||
-hostname $HN
|
# TODO: Working version uses string with newlines (see create_lxc_container function)
|
||||||
-tags $TAGS
|
# # Build PCT_OPTIONS array (not string) for proper parameter handling
|
||||||
$SD
|
# PCT_OPTIONS=()
|
||||||
$NS
|
|
||||||
$NET_STRING
|
# PROBLEMATIC: Loop building PCT_OPTIONS from FEATURES_ARRAY
|
||||||
-onboot 1
|
# TODO: Since both are commented out above, this loop has no effect
|
||||||
-cores $CORE_COUNT
|
# # Add features - each as separate -features parameter
|
||||||
-memory $RAM_SIZE
|
# for feature in "${FEATURES_ARRAY[@]}"; do
|
||||||
-unprivileged $CT_TYPE
|
# PCT_OPTIONS+=("-features" "$feature")
|
||||||
$PW
|
# done
|
||||||
"
|
|
||||||
export PCT_OPTIONS
|
# PROBLEMATIC: All PCT_OPTIONS array operations
|
||||||
|
# TODO: Working version uses string-based PCT_OPTIONS built in create_lxc_container
|
||||||
|
# The export below is the CRITICAL FAILURE POINT - Bash cannot export arrays!
|
||||||
|
# # PCT_OPTIONS+=("-hostname" "$HN")
|
||||||
|
# PCT_OPTIONS+=("-tags" "$TAGS")
|
||||||
|
#
|
||||||
|
# if [ -n "$SD" ]; then
|
||||||
|
# PCT_OPTIONS+=($SD) # Storage device flags (already formatted)
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# if [ -n "$NS" ]; then
|
||||||
|
# PCT_OPTIONS+=($NS) # Nameserver flags (already formatted)
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# # Network configuration (single string with all network parameters)
|
||||||
|
# PCT_OPTIONS+=($NET_STRING)
|
||||||
|
#
|
||||||
|
# PCT_OPTIONS+=("-onboot" "1")
|
||||||
|
# PCT_OPTIONS+=("-cores" "$CORE_COUNT")
|
||||||
|
# PCT_OPTIONS+=("-memory" "$RAM_SIZE")
|
||||||
|
# PCT_OPTIONS+=("-unprivileged" "$CT_TYPE")
|
||||||
|
#
|
||||||
|
# # Protection flag
|
||||||
|
# if [ "$PROTECT_CT" == "1" ]; then
|
||||||
|
# PCT_OPTIONS+=("-protection" "1")
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# # Timezone flag
|
||||||
|
# if [ -n "$CT_TIMEZONE" ]; then
|
||||||
|
# PCT_OPTIONS+=("-timezone" "$CT_TIMEZONE")
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# # Password flag (already formatted as "-password xxx")
|
||||||
|
# if [ -n "$PW" ]; then
|
||||||
|
# PCT_OPTIONS+=($PW)
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# export PCT_OPTIONS
|
||||||
export TEMPLATE_STORAGE="${var_template_storage:-}"
|
export TEMPLATE_STORAGE="${var_template_storage:-}"
|
||||||
export CONTAINER_STORAGE="${var_container_storage:-}"
|
export CONTAINER_STORAGE="${var_container_storage:-}"
|
||||||
create_lxc_container || exit $?
|
create_lxc_container || exit $?
|
||||||
@ -2636,21 +2771,6 @@ EOF'
|
|||||||
# Install SSH keys
|
# Install SSH keys
|
||||||
install_ssh_keys_into_ct
|
install_ssh_keys_into_ct
|
||||||
|
|
||||||
# Dev mode: Setup MOTD/SSH AFTER network is ready and before installation
|
|
||||||
# This ensures the container is fully booted and accessible via SSH
|
|
||||||
if [[ "${DEV_MODE_MOTD:-false}" == "true" ]]; then
|
|
||||||
msg_dev "Setting up MOTD and SSH for debugging access"
|
|
||||||
pct exec "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/${var_install}.sh)" <<'MOTD_SETUP'
|
|
||||||
# Only run motd_ssh function if it exists
|
|
||||||
if declare -f motd_ssh >/dev/null 2>&1; then
|
|
||||||
motd_ssh
|
|
||||||
else
|
|
||||||
msg_warn "motd_ssh function not found in ${var_install}.sh"
|
|
||||||
fi
|
|
||||||
MOTD_SETUP
|
|
||||||
msg_dev "MOTD/SSH ready - container accessible via SSH (IP: $ip_in_lxc)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run application installer
|
# Run application installer
|
||||||
# NOTE: We disable error handling here because:
|
# NOTE: We disable error handling here because:
|
||||||
# 1. Container errors are caught by error_handler INSIDE container
|
# 1. Container errors are caught by error_handler INSIDE container
|
||||||
@ -2703,8 +2823,8 @@ MOTD_SETUP
|
|||||||
|
|
||||||
# Show available logs
|
# Show available logs
|
||||||
echo ""
|
echo ""
|
||||||
[[ $build_log_copied == true ]] && echo -e "${GN}✔${CL} Container creation log: ${BL}/tmp/create-lxc-${CTID}-${SESSION_ID}.log${CL}"
|
[[ "$build_log_copied" == true ]] && echo -e "${GN}✔${CL} Container creation log: ${BL}/tmp/create-lxc-${CTID}-${SESSION_ID}.log${CL}"
|
||||||
[[ $install_log_copied == true ]] && echo -e "${GN}✔${CL} Installation log: ${BL}/tmp/install-lxc-${CTID}-${SESSION_ID}.log${CL}"
|
[[ "$install_log_copied" == true ]] && echo -e "${GN}✔${CL} Installation log: ${BL}/tmp/install-lxc-${CTID}-${SESSION_ID}.log${CL}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Dev mode: Keep container or open breakpoint shell
|
# Dev mode: Keep container or open breakpoint shell
|
||||||
@ -2740,6 +2860,18 @@ MOTD_SETUP
|
|||||||
echo -e "${BFR}${CM}${GN}Container ${CTID} removed${CL}"
|
echo -e "${BFR}${CM}${GN}Container ${CTID} removed${CL}"
|
||||||
elif [[ "$response" =~ ^[Nn]$ ]]; then
|
elif [[ "$response" =~ ^[Nn]$ ]]; then
|
||||||
echo -e "\n${TAB}${YW}Container ${CTID} kept for debugging${CL}"
|
echo -e "\n${TAB}${YW}Container ${CTID} kept for debugging${CL}"
|
||||||
|
|
||||||
|
# Dev mode: Setup MOTD/SSH for debugging access to broken container
|
||||||
|
if [[ "${DEV_MODE_MOTD:-false}" == "true" ]]; then
|
||||||
|
echo -e "${TAB}${HOLD}${DGN}Setting up MOTD and SSH for debugging...${CL}"
|
||||||
|
if pct exec "$CTID" -- bash -c "
|
||||||
|
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/install.func)
|
||||||
|
declare -f motd_ssh >/dev/null 2>&1 && motd_ssh || true
|
||||||
|
" >/dev/null 2>&1; then
|
||||||
|
local ct_ip=$(pct exec "$CTID" ip a s dev eth0 2>/dev/null | awk '/inet / {print $2}' | cut -d/ -f1)
|
||||||
|
echo -e "${BFR}${CM}${GN}MOTD/SSH ready - SSH into container: ssh root@${ct_ip}${CL}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Timeout - auto-remove
|
# Timeout - auto-remove
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user