Update build.func
This commit is contained in:
parent
4613021586
commit
ced1173282
360
misc/build.func
360
misc/build.func
@ -47,23 +47,17 @@ 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
|
||||||
# PROBLEMATIC: BUILD_LOG and DEV_MODE initialization
|
BUILD_LOG="/tmp/create-lxc-${SESSION_ID}.log" # Host-side container creation log
|
||||||
# TODO: Working version doesn't have BUILD_LOG or DEV_MODE
|
|
||||||
# BUILD_LOG="/tmp/create-lxc-${SESSION_ID}.log" # Host-side container creation log
|
|
||||||
CTTYPE="${CTTYPE:-${CT_TYPE:-1}}"
|
CTTYPE="${CTTYPE:-${CT_TYPE:-1}}"
|
||||||
|
|
||||||
# PROBLEMATIC: parse_dev_mode function call (function doesn't exist)
|
|
||||||
# TODO: Comment out until DEV_MODE is properly implemented
|
|
||||||
# Parse dev_mode early
|
# Parse dev_mode early
|
||||||
# parse_dev_mode
|
parse_dev_mode
|
||||||
|
|
||||||
# PROBLEMATIC: DEV_MODE_LOGS directory setup
|
# Setup persistent log directory if logs mode active
|
||||||
# TODO: Working version doesn't use persistent logs
|
if [[ "${DEV_MODE_LOGS:-false}" == "true" ]]; then
|
||||||
# # Setup persistent log directory if logs mode active
|
mkdir -p /var/log/community-scripts
|
||||||
# if [[ "${DEV_MODE_LOGS:-false}" == "true" ]]; then
|
BUILD_LOG="/var/log/community-scripts/create-lxc-${SESSION_ID}-$(date +%Y%m%d_%H%M%S).log"
|
||||||
# mkdir -p /var/log/community-scripts
|
fi
|
||||||
# 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
|
||||||
@ -541,40 +535,35 @@ 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
|
ENABLE_NESTING=${var_nesting:-"${1:-1}"}
|
||||||
# TODO: These need proper integration with string-based FEATURES export (not array)
|
ENABLE_KEYCTL=${var_keyctl:-"${1:-0}"}
|
||||||
# ENABLE_NESTING=${var_nesting:-"${1:-1}"}
|
ALLOW_MOUNT_FS=${var_mount_fs:-""}
|
||||||
# ENABLE_KEYCTL=${var_keyctl:-"${1:-0}"}
|
ENABLE_MKNOD=${var_mknod:-"${1:-0}"}
|
||||||
# ALLOW_MOUNT_FS=${var_mount_fs:-""}
|
PROTECT_CT=${var_protection:-"${1:-no}"}
|
||||||
# ENABLE_MKNOD=${var_mknod:-"${1:-0}"}
|
CT_TIMEZONE=${var_timezone:-""}
|
||||||
# PROTECT_CT=${var_protection:-"${1:-no}"}
|
|
||||||
# CT_TIMEZONE=${var_timezone:-""}
|
|
||||||
|
|
||||||
# PROBLEMATIC: Feature normalization breaks compatibility
|
# Normalize feature flags to 0/1 immediately (pct requires numeric values, not yes/no)
|
||||||
# TODO: Working version expects ENABLE_FUSE="yes" but this converts to "1"
|
# This must happen here before any usage of these variables
|
||||||
# If implementing, must update all checks throughout codebase to handle numeric values
|
case "${ENABLE_NESTING,,}" in
|
||||||
# # Normalize feature flags to 0/1 immediately (pct requires numeric values, not yes/no)
|
yes | true) ENABLE_NESTING="1" ;;
|
||||||
# # This must happen here before any usage of these variables
|
no | false) ENABLE_NESTING="0" ;;
|
||||||
# case "${ENABLE_NESTING,,}" in
|
esac
|
||||||
# yes | true) ENABLE_NESTING="1" ;;
|
case "${ENABLE_KEYCTL,,}" in
|
||||||
# no | false) ENABLE_NESTING="0" ;;
|
yes | true) ENABLE_KEYCTL="1" ;;
|
||||||
# esac
|
no | false) ENABLE_KEYCTL="0" ;;
|
||||||
# case "${ENABLE_KEYCTL,,}" in
|
esac
|
||||||
# yes | true) ENABLE_KEYCTL="1" ;;
|
case "${ENABLE_MKNOD,,}" in
|
||||||
# no | false) ENABLE_KEYCTL="0" ;;
|
yes | true) ENABLE_MKNOD="1" ;;
|
||||||
# esac
|
no | false) ENABLE_MKNOD="0" ;;
|
||||||
# case "${ENABLE_MKNOD,,}" in
|
esac
|
||||||
# yes | true) ENABLE_MKNOD="1" ;;
|
case "${ENABLE_FUSE,,}" in
|
||||||
# no | false) ENABLE_MKNOD="0" ;;
|
yes | true) ENABLE_FUSE="1" ;;
|
||||||
# esac
|
no | false) ENABLE_FUSE="0" ;;
|
||||||
# case "${ENABLE_FUSE,,}" in
|
esac
|
||||||
# yes | true) ENABLE_FUSE="1" ;;
|
case "${PROTECT_CT,,}" in
|
||||||
# no | false) ENABLE_FUSE="0" ;;
|
yes | true) PROTECT_CT="1" ;;
|
||||||
# esac
|
no | false) PROTECT_CT="0" ;;
|
||||||
# case "${PROTECT_CT,,}" in
|
esac
|
||||||
# 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
|
||||||
@ -2309,48 +2298,35 @@ build_container() {
|
|||||||
none) ;;
|
none) ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# PROBLEMATIC: FEATURES_ARRAY system - ROOT CAUSE OF AUTOLOGIN FAILURE
|
# Build FEATURES array with advanced settings
|
||||||
# TODO: Bash arrays cannot be exported to child processes!
|
# Note: All feature flags are already normalized to 0/1 in default_settings()
|
||||||
# When PCT_OPTIONS was built from this array, exports failed silently
|
# Proxmox requires each feature as a separate parameter, not comma-separated string
|
||||||
# This caused container creation to succeed but configuration to fail (black console)
|
FEATURES_ARRAY=()
|
||||||
# SOLUTION: Use string-based FEATURES like working version:
|
FEATURES_ARRAY+=("nesting=${ENABLE_NESTING}")
|
||||||
# if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
# FEATURES="keyctl=1,nesting=1"
|
# keyctl: needed for Docker inside containers (systemd-networkd workaround)
|
||||||
# else
|
# Typically needed for unprivileged containers with Docker
|
||||||
# FEATURES="nesting=1"
|
if [ "$CT_TYPE" == "1" ] || [ "$ENABLE_KEYCTL" == "1" ]; then
|
||||||
# fi
|
FEATURES_ARRAY+=("keyctl=1")
|
||||||
# if [ "$ENABLE_FUSE" == "yes" ]; then
|
fi
|
||||||
# FEATURES="$FEATURES,fuse=1"
|
|
||||||
# fi
|
# mknod: allow device node creation (requires kernel 5.3+, experimental)
|
||||||
# # Build FEATURES array with advanced settings
|
if [ "$ENABLE_MKNOD" == "1" ]; then
|
||||||
# # Note: All feature flags are already normalized to 0/1 in default_settings()
|
FEATURES_ARRAY+=("mknod=1")
|
||||||
# # Proxmox requires each feature as a separate parameter, not comma-separated string
|
fi
|
||||||
# FEATURES_ARRAY=()
|
|
||||||
# FEATURES_ARRAY+=("nesting=${ENABLE_NESTING}")
|
# FUSE: required for rclone, mergerfs, AppImage, etc.
|
||||||
#
|
if [ "$ENABLE_FUSE" == "1" ]; then
|
||||||
# # keyctl: needed for Docker inside containers (systemd-networkd workaround)
|
FEATURES_ARRAY+=("fuse=1")
|
||||||
# # Typically needed for unprivileged containers with Docker
|
fi
|
||||||
# if [ "$CT_TYPE" == "1" ] || [ "$ENABLE_KEYCTL" == "1" ]; then
|
|
||||||
# FEATURES_ARRAY+=("keyctl=1")
|
# mount: allow specific filesystems (e.g., nfs, ext4, etc.)
|
||||||
# fi
|
# Format: mount=fstype1;fstype2;fstype3 (semicolon-separated, not comma!)
|
||||||
#
|
if [ -n "$ALLOW_MOUNT_FS" ]; then
|
||||||
# # mknod: allow device node creation (requires kernel 5.3+, experimental)
|
# Replace commas with semicolons for proper pct syntax
|
||||||
# if [ "$ENABLE_MKNOD" == "1" ]; then
|
ALLOW_MOUNT_FS_FORMATTED="${ALLOW_MOUNT_FS//,/;}"
|
||||||
# FEATURES_ARRAY+=("mknod=1")
|
FEATURES_ARRAY+=("mount=$ALLOW_MOUNT_FS_FORMATTED")
|
||||||
# fi
|
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
|
||||||
@ -2362,19 +2338,16 @@ 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
|
export BUILD_LOG="$BUILD_LOG"
|
||||||
# TODO: These were causing autologin issues by interfering with getty service
|
export INSTALL_LOG="/root/.install-${SESSION_ID}.log"
|
||||||
# If implementing DEV_MODE, must ensure it doesn't modify container startup
|
export dev_mode="${dev_mode:-}"
|
||||||
# export BUILD_LOG="$BUILD_LOG"
|
export DEV_MODE_MOTD="${DEV_MODE_MOTD:-false}"
|
||||||
# export INSTALL_LOG="/root/.install-${SESSION_ID}.log"
|
export DEV_MODE_KEEP="${DEV_MODE_KEEP:-false}"
|
||||||
# export dev_mode="${dev_mode:-}"
|
export DEV_MODE_TRACE="${DEV_MODE_TRACE:-false}"
|
||||||
# export DEV_MODE_MOTD="${DEV_MODE_MOTD:-false}"
|
export DEV_MODE_PAUSE="${DEV_MODE_PAUSE:-false}"
|
||||||
# export DEV_MODE_KEEP="${DEV_MODE_KEEP:-false}"
|
export DEV_MODE_BREAKPOINT="${DEV_MODE_BREAKPOINT:-false}"
|
||||||
# export DEV_MODE_TRACE="${DEV_MODE_TRACE:-false}"
|
export DEV_MODE_LOGS="${DEV_MODE_LOGS:-false}"
|
||||||
# export DEV_MODE_PAUSE="${DEV_MODE_PAUSE:-false}"
|
export DEV_MODE_DRYRUN="${DEV_MODE_DRYRUN:-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"
|
||||||
@ -2388,68 +2361,59 @@ 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
|
export ENABLE_NESTING="$ENABLE_NESTING"
|
||||||
# TODO: These variables don't exist in working version (see above where commented out)
|
export ENABLE_KEYCTL="$ENABLE_KEYCTL"
|
||||||
# export ENABLE_NESTING="$ENABLE_NESTING"
|
export ENABLE_MKNOD="$ENABLE_MKNOD"
|
||||||
# export ENABLE_KEYCTL="$ENABLE_KEYCTL"
|
export ALLOW_MOUNT_FS="$ALLOW_MOUNT_FS"
|
||||||
# export ENABLE_MKNOD="$ENABLE_MKNOD"
|
export PROTECT_CT="$PROTECT_CT"
|
||||||
# export ALLOW_MOUNT_FS="$ALLOW_MOUNT_FS"
|
export CT_TIMEZONE="$CT_TIMEZONE"
|
||||||
# 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"
|
||||||
|
|
||||||
# PROBLEMATIC: PCT_OPTIONS as array cannot be exported
|
# Build PCT_OPTIONS array (not string) for proper parameter handling
|
||||||
# TODO: Working version uses string with newlines (see create_lxc_container function)
|
PCT_OPTIONS=()
|
||||||
# # Build PCT_OPTIONS array (not string) for proper parameter handling
|
|
||||||
# PCT_OPTIONS=()
|
|
||||||
|
|
||||||
# PROBLEMATIC: Loop building PCT_OPTIONS from FEATURES_ARRAY
|
# Add features - each as separate -features parameter
|
||||||
# TODO: Since both are commented out above, this loop has no effect
|
for feature in "${FEATURES_ARRAY[@]}"; do
|
||||||
# # Add features - each as separate -features parameter
|
PCT_OPTIONS+=("-features" "$feature")
|
||||||
# for feature in "${FEATURES_ARRAY[@]}"; do
|
done
|
||||||
# PCT_OPTIONS+=("-features" "$feature")
|
|
||||||
# done
|
|
||||||
|
|
||||||
# PROBLEMATIC: All PCT_OPTIONS array operations
|
PCT_OPTIONS+=("-hostname" "$HN")
|
||||||
# TODO: Working version uses string-based PCT_OPTIONS built in create_lxc_container
|
PCT_OPTIONS+=("-tags" "$TAGS")
|
||||||
# The export below is the CRITICAL FAILURE POINT - Bash cannot export arrays!
|
|
||||||
# # PCT_OPTIONS+=("-hostname" "$HN")
|
if [ -n "$SD" ]; then
|
||||||
# PCT_OPTIONS+=("-tags" "$TAGS")
|
PCT_OPTIONS+=($SD) # Storage device flags (already formatted)
|
||||||
#
|
fi
|
||||||
# if [ -n "$SD" ]; then
|
|
||||||
# PCT_OPTIONS+=($SD) # Storage device flags (already formatted)
|
if [ -n "$NS" ]; then
|
||||||
# fi
|
PCT_OPTIONS+=($NS) # Nameserver flags (already formatted)
|
||||||
#
|
fi
|
||||||
# if [ -n "$NS" ]; then
|
|
||||||
# PCT_OPTIONS+=($NS) # Nameserver flags (already formatted)
|
# Network configuration (single string with all network parameters)
|
||||||
# fi
|
PCT_OPTIONS+=($NET_STRING)
|
||||||
#
|
|
||||||
# # Network configuration (single string with all network parameters)
|
PCT_OPTIONS+=("-onboot" "1")
|
||||||
# PCT_OPTIONS+=($NET_STRING)
|
PCT_OPTIONS+=("-cores" "$CORE_COUNT")
|
||||||
#
|
PCT_OPTIONS+=("-memory" "$RAM_SIZE")
|
||||||
# PCT_OPTIONS+=("-onboot" "1")
|
PCT_OPTIONS+=("-unprivileged" "$CT_TYPE")
|
||||||
# PCT_OPTIONS+=("-cores" "$CORE_COUNT")
|
|
||||||
# PCT_OPTIONS+=("-memory" "$RAM_SIZE")
|
# Protection flag
|
||||||
# PCT_OPTIONS+=("-unprivileged" "$CT_TYPE")
|
if [ "$PROTECT_CT" == "1" ]; then
|
||||||
#
|
PCT_OPTIONS+=("-protection" "1")
|
||||||
# # Protection flag
|
fi
|
||||||
# if [ "$PROTECT_CT" == "1" ]; then
|
|
||||||
# PCT_OPTIONS+=("-protection" "1")
|
# Timezone flag
|
||||||
# fi
|
if [ -n "$CT_TIMEZONE" ]; then
|
||||||
#
|
PCT_OPTIONS+=("-timezone" "$CT_TIMEZONE")
|
||||||
# # Timezone flag
|
fi
|
||||||
# if [ -n "$CT_TIMEZONE" ]; then
|
|
||||||
# PCT_OPTIONS+=("-timezone" "$CT_TIMEZONE")
|
# Password flag (already formatted as "-password xxx")
|
||||||
# fi
|
if [ -n "$PW" ]; then
|
||||||
#
|
PCT_OPTIONS+=($PW)
|
||||||
# # Password flag (already formatted as "-password xxx")
|
fi
|
||||||
# if [ -n "$PW" ]; then
|
|
||||||
# PCT_OPTIONS+=($PW)
|
export PCT_OPTIONS
|
||||||
# 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 $?
|
||||||
@ -2812,52 +2776,46 @@ EOF'
|
|||||||
if [[ $install_exit_code -ne 0 ]]; then
|
if [[ $install_exit_code -ne 0 ]]; then
|
||||||
msg_error "Installation failed in container ${CTID} (exit code: ${install_exit_code})"
|
msg_error "Installation failed in container ${CTID} (exit code: ${install_exit_code})"
|
||||||
|
|
||||||
# PROBLEMATIC: BUILD_LOG copy logic
|
# Copy both logs from container before potential deletion
|
||||||
# TODO: Working version doesn't use BUILD_LOG
|
local build_log_copied=false
|
||||||
# # Copy both logs from container before potential deletion
|
local install_log_copied=false
|
||||||
# local build_log_copied=false
|
|
||||||
# local install_log_copied=false
|
|
||||||
#
|
|
||||||
# if [[ -n "$CTID" && -n "${SESSION_ID:-}" ]]; then
|
|
||||||
# # Copy BUILD_LOG (creation log) if it exists
|
|
||||||
# if [[ -f "${BUILD_LOG}" ]]; then
|
|
||||||
# cp "${BUILD_LOG}" "/tmp/create-lxc-${CTID}-${SESSION_ID}.log" 2>/dev/null && build_log_copied=true
|
|
||||||
# fi
|
|
||||||
#
|
|
||||||
# # Copy INSTALL_LOG from container
|
|
||||||
# if pct pull "$CTID" "/root/.install-${SESSION_ID}.log" "/tmp/install-lxc-${CTID}-${SESSION_ID}.log" 2>/dev/null; then
|
|
||||||
# install_log_copied=true
|
|
||||||
# fi
|
|
||||||
#
|
|
||||||
# # Show available logs
|
|
||||||
# echo ""
|
|
||||||
# [[ "$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}"
|
|
||||||
# fi
|
|
||||||
|
|
||||||
# PROBLEMATIC: DEV_MODE keep/breakpoint logic
|
if [[ -n "$CTID" && -n "${SESSION_ID:-}" ]]; then
|
||||||
# TODO: Working version doesn't have DEV_MODE
|
# Copy BUILD_LOG (creation log) if it exists
|
||||||
# # Dev mode: Keep container or open breakpoint shell
|
if [[ -f "${BUILD_LOG}" ]]; then
|
||||||
# if [[ "${DEV_MODE_KEEP:-false}" == "true" ]]; then
|
cp "${BUILD_LOG}" "/tmp/create-lxc-${CTID}-${SESSION_ID}.log" 2>/dev/null && build_log_copied=true
|
||||||
# msg_dev "Keep mode active - container ${CTID} preserved"
|
fi
|
||||||
# return 0
|
|
||||||
# elif [[ "${DEV_MODE_BREAKPOINT:-false}" == "true" ]]; then
|
|
||||||
# msg_dev "Breakpoint mode - opening shell in container ${CTID}"
|
|
||||||
# echo -e "${YW}Type 'exit' to return to host${CL}"
|
|
||||||
# pct enter "$CTID"
|
|
||||||
# echo ""
|
|
||||||
# echo -en "${YW}Container ${CTID} still running. Remove now? (y/N): ${CL}"
|
|
||||||
# if read -r response && [[ "$response" =~ ^[Yy]$ ]]; then
|
|
||||||
# pct stop "$CTID" &>/dev/null || true
|
|
||||||
# pct destroy "$CTID" &>/dev/null || true
|
|
||||||
# msg_ok "Container ${CTID} removed"
|
|
||||||
# else
|
|
||||||
# msg_dev "Container ${CTID} kept for debugging"
|
|
||||||
# fi
|
|
||||||
# exit $install_exit_code
|
|
||||||
# fi
|
|
||||||
|
|
||||||
# Working version: Simple cleanup on failure
|
# Copy INSTALL_LOG from container
|
||||||
|
if pct pull "$CTID" "/root/.install-${SESSION_ID}.log" "/tmp/install-lxc-${CTID}-${SESSION_ID}.log" 2>/dev/null; then
|
||||||
|
install_log_copied=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Show available logs
|
||||||
|
echo ""
|
||||||
|
[[ "$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}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Dev mode: Keep container or open breakpoint shell
|
||||||
|
if [[ "${DEV_MODE_KEEP:-false}" == "true" ]]; then
|
||||||
|
msg_dev "Keep mode active - container ${CTID} preserved"
|
||||||
|
return 0
|
||||||
|
elif [[ "${DEV_MODE_BREAKPOINT:-false}" == "true" ]]; then
|
||||||
|
msg_dev "Breakpoint mode - opening shell in container ${CTID}"
|
||||||
|
echo -e "${YW}Type 'exit' to return to host${CL}"
|
||||||
|
pct enter "$CTID"
|
||||||
|
echo ""
|
||||||
|
echo -en "${YW}Container ${CTID} still running. Remove now? (y/N): ${CL}"
|
||||||
|
if read -r response && [[ "$response" =~ ^[Yy]$ ]]; then
|
||||||
|
pct stop "$CTID" &>/dev/null || true
|
||||||
|
pct destroy "$CTID" &>/dev/null || true
|
||||||
|
msg_ok "Container ${CTID} removed"
|
||||||
|
else
|
||||||
|
msg_dev "Container ${CTID} kept for debugging"
|
||||||
|
fi
|
||||||
|
exit $install_exit_code
|
||||||
|
fi
|
||||||
|
|
||||||
# Prompt user for cleanup with 60s timeout (plain echo - no msg_info to avoid spinner)
|
# Prompt user for cleanup with 60s timeout (plain echo - no msg_info to avoid spinner)
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user