@@ -92,7 +92,6 @@ elif command -v wget >/dev/null 2>&1; then
9292 source <( wget -qO- https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/error_handler.func)
9393 load_functions
9494 catch_errors
95- # echo "(build.func) Loaded core.func via wget"
9695fi
9796
9897# ==============================================================================
@@ -2279,7 +2278,7 @@ build_container() {
22792278 none) ;;
22802279 esac
22812280
2282- # Build FEATURES string (simple working version)
2281+ # Build FEATURES string
22832282 if [ " $CT_TYPE " == " 1" ]; then
22842283 FEATURES=" keyctl=1,nesting=1"
22852284 else
@@ -2290,9 +2289,7 @@ build_container() {
22902289 FEATURES=" $FEATURES ,fuse=1"
22912290 fi
22922291
2293- # NEW IMPLEMENTATION (Fixed): Build PCT_OPTIONS properly
2294- # Key insight: Bash cannot export arrays, so we build the options as a string
2295-
2292+ # Build PCT_OPTIONS as string for export
22962293 TEMP_DIR=$( mktemp -d)
22972294 pushd " $TEMP_DIR " > /dev/null
22982295 if [ " $var_os " == " alpine" ]; then
@@ -2382,11 +2379,6 @@ build_container() {
23822379 export TEMPLATE_STORAGE=" ${var_template_storage:- } "
23832380 export CONTAINER_STORAGE=" ${var_container_storage:- } "
23842381
2385- # # DEBUG: Show final PCT_OPTIONS being exported
2386- # echo "[DEBUG] PCT_OPTIONS to be exported:"
2387- # echo "$PCT_OPTIONS" | sed 's/^/ /'
2388- # echo "[DEBUG] Calling create_lxc_container..."
2389-
23902382 create_lxc_container || exit $?
23912383
23922384 LXC_CONFIG=" /etc/pve/lxc/${CTID} .conf"
@@ -2713,12 +2705,7 @@ EOF'
27132705 install_ssh_keys_into_ct
27142706
27152707 # Run application installer
2716- # NOTE: We disable error handling here because:
2717- # 1. Container errors are caught by error_handler INSIDE container
2718- # 2. Container creates flag file with exit code
2719- # 3. We read flag file and handle cleanup manually below
2720- # 4. We DON'T want host error_handler to fire for lxc-attach command itself
2721-
2708+ # Disable error trap - container errors are handled internally via flag file
27222709 set +Eeuo pipefail # Disable ALL error handling temporarily
27232710 trap - ERR # Remove ERR trap completely
27242711
@@ -2864,7 +2851,6 @@ destroy_lxc() {
28642851# ------------------------------------------------------------------------------
28652852# Storage discovery / selection helpers
28662853# ------------------------------------------------------------------------------
2867- # ===== Storage discovery / selection helpers (ported from create_lxc.sh) =====
28682854resolve_storage_preselect () {
28692855 local class=" $1 " preselect=" $2 " required_content=" "
28702856 case " $class " in
@@ -3249,10 +3235,6 @@ create_lxc_container() {
32493235 # Build regex patterns outside awk/grep for clarity
32503236 SEARCH_PATTERN=" ^${TEMPLATE_SEARCH} "
32513237
3252- # echo "[DEBUG] TEMPLATE_SEARCH='$TEMPLATE_SEARCH'"
3253- # echo "[DEBUG] SEARCH_PATTERN='$SEARCH_PATTERN'"
3254- # echo "[DEBUG] TEMPLATE_PATTERN='$TEMPLATE_PATTERN'"
3255-
32563238 mapfile -t LOCAL_TEMPLATES < <(
32573239 pveam list " $TEMPLATE_STORAGE " 2> /dev/null |
32583240 awk -v search=" ${SEARCH_PATTERN} " -v pattern=" ${TEMPLATE_PATTERN} " ' $1 ~ search && $1 ~ pattern {print $1}' |
@@ -3263,30 +3245,13 @@ create_lxc_container() {
32633245
32643246 msg_ok " Template search completed"
32653247
3266- # echo "[DEBUG] pveam available output (first 5 lines with .tar files):"
3267- # pveam available -section system 2>/dev/null | grep -E '\.(tar\.zst|tar\.xz|tar\.gz)$' | head -5 | sed 's/^/ /'
3268-
32693248 set +u
32703249 mapfile -t ONLINE_TEMPLATES < <( pveam available -section system 2> /dev/null | grep -E ' \.(tar\.zst|tar\.xz|tar\.gz)$' | awk ' {print $2}' | grep -E " ${SEARCH_PATTERN} .*${TEMPLATE_PATTERN} " | sort -t - -k 2 -V 2> /dev/null || true)
3271- # echo "[DEBUG] After filtering: ${#ONLINE_TEMPLATES[@]} online templates found"
32723250 set -u
32733251
32743252 ONLINE_TEMPLATE=" "
32753253 [[ ${# ONLINE_TEMPLATES[@]} -gt 0 ]] && ONLINE_TEMPLATE=" ${ONLINE_TEMPLATES[-1]} "
32763254
3277- # msg_debug "SEARCH_PATTERN='${SEARCH_PATTERN}' TEMPLATE_PATTERN='${TEMPLATE_PATTERN}'"
3278- # msg_debug "Found ${#LOCAL_TEMPLATES[@]} local templates, ${#ONLINE_TEMPLATES[@]} online templates"
3279- if [[ ${# ONLINE_TEMPLATES[@]} -gt 0 ]]; then
3280- # msg_debug "First 3 online templates:"
3281- count=0
3282- for idx in " ${! ONLINE_TEMPLATES[@]} " ; do
3283- # msg_debug " [$idx]: ${ONLINE_TEMPLATES[$idx]}"
3284- (( count++ ))
3285- [[ $count -ge 3 ]] && break
3286- done
3287- fi
3288- # msg_debug "ONLINE_TEMPLATE='$ONLINE_TEMPLATE'"
3289-
32903255 if [[ ${# LOCAL_TEMPLATES[@]} -gt 0 ]]; then
32913256 TEMPLATE=" ${LOCAL_TEMPLATES[-1]} "
32923257 TEMPLATE_SOURCE=" local"
@@ -3337,7 +3302,6 @@ create_lxc_container() {
33373302 if [[ ${# ONLINE_TEMPLATES[@]} -gt 0 ]]; then
33383303 TEMPLATE=" ${ONLINE_TEMPLATES[-1]} "
33393304 TEMPLATE_SOURCE=" online"
3340- # echo "[DEBUG] Found alternative: $TEMPLATE"
33413305 else
33423306 msg_error " No templates available for ${PCT_OSTYPE} ${PCT_OSVERSION} "
33433307 exit 225
@@ -3352,9 +3316,6 @@ create_lxc_container() {
33523316 fi
33533317 fi
33543318
3355- # echo "[DEBUG] Selected TEMPLATE='$TEMPLATE' SOURCE='$TEMPLATE_SOURCE'"
3356- # msg_debug "Selected TEMPLATE='$TEMPLATE' SOURCE='$TEMPLATE_SOURCE'"
3357-
33583319 TEMPLATE_PATH=" $( pvesm path $TEMPLATE_STORAGE :vztmpl/$TEMPLATE 2> /dev/null || true) "
33593320 if [[ -z " $TEMPLATE_PATH " ]]; then
33603321 TEMPLATE_BASE=$( awk -v s=" $TEMPLATE_STORAGE " ' $1==s {f=1} f && /path/ {print $2; exit}' /etc/pve/storage.cfg)
0 commit comments