linting
This commit is contained in:
@@ -1405,13 +1405,16 @@ post_update_to_api_extended() {
|
|||||||
failed)
|
failed)
|
||||||
pb_status="failed"
|
pb_status="failed"
|
||||||
;;
|
;;
|
||||||
|
aborted)
|
||||||
|
pb_status="aborted"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
pb_status="unknown"
|
pb_status="unknown"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# For failed/unknown status, resolve exit code and error description
|
# For failed/aborted/unknown status, resolve exit code and error description
|
||||||
if [[ "$pb_status" == "failed" ]] || [[ "$pb_status" == "unknown" ]]; then
|
if [[ "$pb_status" == "failed" ]] || [[ "$pb_status" == "aborted" ]] || [[ "$pb_status" == "unknown" ]]; then
|
||||||
if [[ "$raw_exit_code" =~ ^[0-9]+$ ]]; then
|
if [[ "$raw_exit_code" =~ ^[0-9]+$ ]]; then
|
||||||
exit_code="$raw_exit_code"
|
exit_code="$raw_exit_code"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -38,14 +38,14 @@
|
|||||||
# - Captures app-declared resource defaults (CPU, RAM, Disk)
|
# - Captures app-declared resource defaults (CPU, RAM, Disk)
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
variables() {
|
variables() {
|
||||||
NSAPP=$(echo "${APP,,}" | tr -d ' ') # This function sets the NSAPP variable by converting the value of the APP variable to lowercase and removing any spaces.
|
NSAPP=$(echo "${APP,,}" | tr -d ' ') # This function sets the NSAPP variable by converting the value of the APP variable to lowercase and removing any spaces.
|
||||||
var_install="${NSAPP}-install" # sets the var_install variable by appending "-install" to the value of NSAPP.
|
var_install="${NSAPP}-install" # sets the var_install variable by appending "-install" to the value of NSAPP.
|
||||||
INTEGER='^[0-9]+([.][0-9]+)?$' # it defines the INTEGER regular expression pattern.
|
INTEGER='^[0-9]+([.][0-9]+)?$' # it defines the INTEGER regular expression pattern.
|
||||||
PVEHOST_NAME=$(hostname) # gets the Proxmox Hostname and sets it to Uppercase
|
PVEHOST_NAME=$(hostname) # gets the Proxmox Hostname and sets it to Uppercase
|
||||||
DIAGNOSTICS="yes" # sets the DIAGNOSTICS variable to "yes", used for the API call.
|
DIAGNOSTICS="yes" # sets the DIAGNOSTICS variable to "yes", used for the API call.
|
||||||
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
|
BUILD_LOG="/tmp/create-lxc-${SESSION_ID}.log" # Host-side container creation log
|
||||||
combined_log="/tmp/install-${SESSION_ID}-combined.log" # Combined log (build + install) for failed installations
|
combined_log="/tmp/install-${SESSION_ID}-combined.log" # Combined log (build + install) for failed installations
|
||||||
@@ -59,7 +59,7 @@ variables() {
|
|||||||
mkdir -p /var/log/community-scripts
|
mkdir -p /var/log/community-scripts
|
||||||
BUILD_LOG="/var/log/community-scripts/create-lxc-${SESSION_ID}-$(date +%Y%m%d_%H%M%S).log"
|
BUILD_LOG="/var/log/community-scripts/create-lxc-${SESSION_ID}-$(date +%Y%m%d_%H%M%S).log"
|
||||||
combined_log="/var/log/community-scripts/install-${SESSION_ID}-combined-$(date +%Y%m%d_%H%M%S).log"
|
combined_log="/var/log/community-scripts/install-${SESSION_ID}-combined-$(date +%Y%m%d_%H%M%S).log"
|
||||||
fi
|
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
|
||||||
@@ -4008,7 +4008,7 @@ build_container() {
|
|||||||
# Core exports for install.func
|
# Core exports for install.func
|
||||||
export DIAGNOSTICS="$DIAGNOSTICS"
|
export DIAGNOSTICS="$DIAGNOSTICS"
|
||||||
export RANDOM_UUID="$RANDOM_UUID"
|
export RANDOM_UUID="$RANDOM_UUID"
|
||||||
export EXECUTION_ID="$EXECUTION_ID"
|
export EXECUTION_ID="$EXECUTION_ID"
|
||||||
export SESSION_ID="$SESSION_ID"
|
export SESSION_ID="$SESSION_ID"
|
||||||
export CACHER="$APT_CACHER"
|
export CACHER="$APT_CACHER"
|
||||||
export CACHER_IP="$APT_CACHER_IP"
|
export CACHER_IP="$APT_CACHER_IP"
|
||||||
@@ -4780,7 +4780,6 @@ EOF'
|
|||||||
export VERBOSE="yes"
|
export VERBOSE="yes"
|
||||||
export var_verbose="yes"
|
export var_verbose="yes"
|
||||||
|
|
||||||
|
|
||||||
# Show rebuild summary
|
# Show rebuild summary
|
||||||
echo -e "${YW}Rebuilding with preserved settings:${CL}"
|
echo -e "${YW}Rebuilding with preserved settings:${CL}"
|
||||||
echo -e " Container ID: ${old_ctid} → ${CTID}"
|
echo -e " Container ID: ${old_ctid} → ${CTID}"
|
||||||
@@ -4869,7 +4868,7 @@ EOF'
|
|||||||
pct destroy "$CTID" &>/dev/null || true
|
pct destroy "$CTID" &>/dev/null || true
|
||||||
echo -e "${BFR}${CM}${GN}Container ${CTID} removed${CL}"
|
echo -e "${BFR}${CM}${GN}Container ${CTID} removed${CL}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
local old_ctid="$CTID"
|
local old_ctid="$CTID"
|
||||||
local old_ram="$RAM_SIZE"
|
local old_ram="$RAM_SIZE"
|
||||||
local old_cpu="$CORE_COUNT"
|
local old_cpu="$CORE_COUNT"
|
||||||
@@ -4882,7 +4881,6 @@ EOF'
|
|||||||
export var_verbose="yes"
|
export var_verbose="yes"
|
||||||
export RECOVERY_ATTEMPT=$((${RECOVERY_ATTEMPT:-0} + 1))
|
export RECOVERY_ATTEMPT=$((${RECOVERY_ATTEMPT:-0} + 1))
|
||||||
|
|
||||||
|
|
||||||
echo -e "${YW}Rebuilding with increased resources (attempt ${RECOVERY_ATTEMPT}/2):${CL}"
|
echo -e "${YW}Rebuilding with increased resources (attempt ${RECOVERY_ATTEMPT}/2):${CL}"
|
||||||
echo -e " Container ID: ${old_ctid} → ${CTID}"
|
echo -e " Container ID: ${old_ctid} → ${CTID}"
|
||||||
echo -e " RAM: ${old_ram} → ${GN}${RAM_SIZE}${CL} MiB (x2)"
|
echo -e " RAM: ${old_ram} → ${GN}${RAM_SIZE}${CL} MiB (x2)"
|
||||||
@@ -4891,7 +4889,7 @@ EOF'
|
|||||||
echo -e " Verbose: ${GN}enabled${CL}"
|
echo -e " Verbose: ${GN}enabled${CL}"
|
||||||
echo ""
|
echo ""
|
||||||
msg_info "Restarting installation..."
|
msg_info "Restarting installation..."
|
||||||
|
|
||||||
build_container
|
build_container
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
@@ -4925,16 +4923,13 @@ EOF'
|
|||||||
exit $install_exit_code
|
exit $install_exit_code
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
# Timeout - auto-remove
|
# Timeout - auto-remove
|
||||||
echo ""
|
echo ""
|
||||||
msg_info "No response - removing container ${CTID}"
|
msg_info "No response - removing container ${CTID}"
|
||||||
|
|
||||||
pct stop "$CTID" &>/dev/null || true
|
pct stop "$CTID" &>/dev/null || true
|
||||||
pct destroy "$CTID" &>/dev/null || true
|
pct destroy "$CTID" &>/dev/null || true
|
||||||
msg_ok "Container ${CTID} removed"
|
msg_ok "Container ${CTID} removed"
|
||||||
@@ -5355,7 +5350,6 @@ create_lxc_container() {
|
|||||||
exit 206
|
exit 206
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Report installation start to API early - captures failures in storage/template/create
|
# Report installation start to API early - captures failures in storage/template/create
|
||||||
post_to_api
|
post_to_api
|
||||||
|
|
||||||
@@ -6043,4 +6037,4 @@ fi
|
|||||||
trap 'local _ec=$?; if [[ $_ec -ne 0 ]]; then post_update_to_api "failed" "$_ec" 2>/dev/null || true; if declare -f ensure_log_on_host &>/dev/null; then ensure_log_on_host 2>/dev/null || true; fi; fi' ERR
|
trap 'local _ec=$?; if [[ $_ec -ne 0 ]]; then post_update_to_api "failed" "$_ec" 2>/dev/null || true; if declare -f ensure_log_on_host &>/dev/null; then ensure_log_on_host 2>/dev/null || true; fi; fi' ERR
|
||||||
trap 'post_update_to_api "failed" "129" 2>/dev/null || true; if [[ -n "${CTID:-}" ]] && command -v pct &>/dev/null; then pct stop "$CTID" 2>/dev/null || true; fi; exit 129' SIGHUP
|
trap 'post_update_to_api "failed" "129" 2>/dev/null || true; if [[ -n "${CTID:-}" ]] && command -v pct &>/dev/null; then pct stop "$CTID" 2>/dev/null || true; fi; exit 129' SIGHUP
|
||||||
trap 'post_update_to_api "failed" "130" 2>/dev/null || true; if [[ -n "${CTID:-}" ]] && command -v pct &>/dev/null; then pct stop "$CTID" 2>/dev/null || true; fi; exit 130' SIGINT
|
trap 'post_update_to_api "failed" "130" 2>/dev/null || true; if [[ -n "${CTID:-}" ]] && command -v pct &>/dev/null; then pct stop "$CTID" 2>/dev/null || true; fi; exit 130' SIGINT
|
||||||
trap 'post_update_to_api "failed" "143" 2>/dev/null || true; if [[ -n "${CTID:-}" ]] && command -v pct &>/dev/null; then pct stop "$CTID" 2>/dev/null || true; fi; exit 143' SIGTERM
|
trap 'post_update_to_api "failed" "143" 2>/dev/null || true; if [[ -n "${CTID:-}" ]] && command -v pct &>/dev/null; then pct stop "$CTID" 2>/dev/null || true; fi; exit 143' SIGTERM
|
||||||
|
|||||||
Reference in New Issue
Block a user