From ed0e6ed49c19a985bc950a51f3db5c1004096923 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Tue, 3 Mar 2026 13:30:25 +0100 Subject: [PATCH] linting --- misc/api.func | 7 +++++-- misc/build.func | 36 +++++++++++++++--------------------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/misc/api.func b/misc/api.func index 2abb61e60..84d439d32 100644 --- a/misc/api.func +++ b/misc/api.func @@ -1405,13 +1405,16 @@ post_update_to_api_extended() { failed) pb_status="failed" ;; + aborted) + pb_status="aborted" + ;; *) pb_status="unknown" ;; esac - # For failed/unknown status, resolve exit code and error description - if [[ "$pb_status" == "failed" ]] || [[ "$pb_status" == "unknown" ]]; then + # For failed/aborted/unknown status, resolve exit code and error description + if [[ "$pb_status" == "failed" ]] || [[ "$pb_status" == "aborted" ]] || [[ "$pb_status" == "unknown" ]]; then if [[ "$raw_exit_code" =~ ^[0-9]+$ ]]; then exit_code="$raw_exit_code" else diff --git a/misc/build.func b/misc/build.func index 5e2c72028..3f59c26f0 100644 --- a/misc/build.func +++ b/misc/build.func @@ -38,14 +38,14 @@ # - Captures app-declared resource defaults (CPU, RAM, Disk) # ------------------------------------------------------------------------------ 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. - 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. - 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. - 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. - + 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. + INTEGER='^[0-9]+([.][0-9]+)?$' # it defines the INTEGER regular expression pattern. + 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. + 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. + 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 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 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" - fi + fi # Get Proxmox VE version and kernel version if command -v pveversion >/dev/null 2>&1; then @@ -4008,7 +4008,7 @@ build_container() { # Core exports for install.func export DIAGNOSTICS="$DIAGNOSTICS" export RANDOM_UUID="$RANDOM_UUID" - export EXECUTION_ID="$EXECUTION_ID" + export EXECUTION_ID="$EXECUTION_ID" export SESSION_ID="$SESSION_ID" export CACHER="$APT_CACHER" export CACHER_IP="$APT_CACHER_IP" @@ -4780,7 +4780,6 @@ EOF' export VERBOSE="yes" export var_verbose="yes" - # Show rebuild summary echo -e "${YW}Rebuilding with preserved settings:${CL}" echo -e " Container ID: ${old_ctid} → ${CTID}" @@ -4869,7 +4868,7 @@ EOF' pct destroy "$CTID" &>/dev/null || true echo -e "${BFR}${CM}${GN}Container ${CTID} removed${CL}" echo "" - + local old_ctid="$CTID" local old_ram="$RAM_SIZE" local old_cpu="$CORE_COUNT" @@ -4882,7 +4881,6 @@ EOF' export var_verbose="yes" export RECOVERY_ATTEMPT=$((${RECOVERY_ATTEMPT:-0} + 1)) - echo -e "${YW}Rebuilding with increased resources (attempt ${RECOVERY_ATTEMPT}/2):${CL}" echo -e " Container ID: ${old_ctid} → ${CTID}" echo -e " RAM: ${old_ram} → ${GN}${RAM_SIZE}${CL} MiB (x2)" @@ -4891,7 +4889,7 @@ EOF' echo -e " Verbose: ${GN}enabled${CL}" echo "" msg_info "Restarting installation..." - + build_container return $? fi @@ -4925,16 +4923,13 @@ EOF' exit $install_exit_code fi ;; - - - - + esac else # Timeout - auto-remove echo "" msg_info "No response - removing container ${CTID}" - + pct stop "$CTID" &>/dev/null || true pct destroy "$CTID" &>/dev/null || true msg_ok "Container ${CTID} removed" @@ -5355,7 +5350,6 @@ create_lxc_container() { exit 206 fi - # Report installation start to API early - captures failures in storage/template/create 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 '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" "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 \ No newline at end of file +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