diff --git a/misc/alpine-install.func b/misc/alpine-install.func index 597d58c6a..49b83dbae 100644 --- a/misc/alpine-install.func +++ b/misc/alpine-install.func @@ -105,7 +105,16 @@ network_check() { update_os() { msg_info "Updating Container OS" $STD apk -U upgrade - source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/tools.func) + local tools_content + tools_content=$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/tools.func) || { + msg_error "Failed to download tools.func" + exit 6 + } + source /dev/stdin <<<"$tools_content" + if ! declare -f fetch_and_deploy_gh_release >/dev/null 2>&1; then + msg_error "tools.func loaded but incomplete — missing expected functions" + exit 6 + fi msg_ok "Updated Container OS" post_progress_to_api } diff --git a/misc/api.func b/misc/api.func index da5a51ed0..977e326c5 100644 --- a/misc/api.func +++ b/misc/api.func @@ -875,6 +875,9 @@ categorize_error() { # Network errors (curl/wget) 6 | 7 | 22 | 35) echo "network" ;; + # Docker / Privileged mode required + 10) echo "config" ;; + # Timeout errors 28 | 124 | 211) echo "timeout" ;; diff --git a/misc/build.func b/misc/build.func index 7c6baa33c..a6cd78b52 100644 --- a/misc/build.func +++ b/misc/build.func @@ -297,7 +297,7 @@ validate_container_id() { # Falls back gracefully if pvesh unavailable or returns empty if command -v pvesh &>/dev/null; then local cluster_ids - cluster_ids=$(pvesh get /cluster/resources --type vm --output-format json 2>/dev/null | + cluster_ids=$(pvesh get /cluster/resources --type vm --output-format json 2>/dev/null | grep -oP '"vmid":\s*\K[0-9]+' 2>/dev/null || true) if [[ -n "$cluster_ids" ]] && echo "$cluster_ids" | grep -qw "$ctid"; then return 1 @@ -5273,6 +5273,6 @@ api_exit_script() { if command -v pveversion >/dev/null 2>&1; then trap 'api_exit_script' EXIT fi -trap 'ensure_log_on_host; post_update_to_api "failed" "$?"' ERR +trap 'local _ec=$?; if [[ $_ec -ne 0 ]]; then ensure_log_on_host; post_update_to_api "failed" "$_ec"; fi' ERR trap 'ensure_log_on_host; post_update_to_api "failed" "130"; exit 130' SIGINT trap 'ensure_log_on_host; post_update_to_api "failed" "143"; exit 143' SIGTERM diff --git a/misc/install.func b/misc/install.func index 8ec1838fa..ed7205c7d 100644 --- a/misc/install.func +++ b/misc/install.func @@ -228,7 +228,16 @@ EOF msg_ok "Updated Container OS" post_progress_to_api - source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/tools.func) + local tools_content + tools_content=$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/tools.func) || { + msg_error "Failed to download tools.func" + exit 6 + } + source /dev/stdin <<<"$tools_content" + if ! declare -f fetch_and_deploy_gh_release >/dev/null 2>&1; then + msg_error "tools.func loaded but incomplete — missing expected functions" + exit 6 + fi } # ==============================================================================