From c9c5113e169c90a88a8a1f07748dba27a351fa29 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 7 May 2025 15:10:15 +0200 Subject: [PATCH] fixes --- misc/alpine-install.func | 12 ++++-------- misc/core.func | 35 +++++++++++++++++++++++++++++++++++ misc/install.func | 3 --- misc/tools.func | 35 ----------------------------------- 4 files changed, 39 insertions(+), 46 deletions(-) diff --git a/misc/alpine-install.func b/misc/alpine-install.func index 5c20bc5..7c7b5a3 100644 --- a/misc/alpine-install.func +++ b/misc/alpine-install.func @@ -4,15 +4,11 @@ # License: MIT # https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE -if command -v curl >/dev/null 2>&1; then - source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/core.func) - load_functions - echo "(alpine-install.func) Loaded core.func via curl" -elif command -v wget >/dev/null 2>&1; then - source <(wget -qO- https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/core.func) - load_functions - echo "(alpine-install.func) Loaded core.func via wget" +if ! command -v curl >/dev/null 2>&1; then + apk update && apk add curl >/dev/null 2>&1 fi +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/core.func) +load_functions # Function to set STD mode based on verbosity set_std_mode() { diff --git a/misc/core.func b/misc/core.func index 3819069..79f43ad 100644 --- a/misc/core.func +++ b/misc/core.func @@ -68,6 +68,41 @@ default_vars() { i=$RETRY_NUM } +__curl_err_handler() { + local exit_code="$1" + local cmd="${BASH_COMMAND:-unknown}" + if ! grep -q 'curl' <<<"$cmd"; then + return + fi + + case $exit_code in + 1) msg_error "Unsupported protocol in: $cmd" ;; + 2) msg_error "Failed curl initialization in: $cmd" ;; + 3) msg_error "Malformed URL in: $cmd" ;; + 5) msg_error "Could not resolve proxy in: $cmd" ;; + 6) msg_error "Could not resolve host in: $cmd" ;; + 7) msg_error "Failed to connect to host in: $cmd" ;; + 9) msg_error "Access denied to remote resource in: $cmd" ;; + 18) msg_error "Partial file transfer detected in: $cmd" ;; + 22) msg_error "HTTP error response in: $cmd" ;; + 23) msg_error "Write error during transfer in: $cmd" ;; + 26) msg_error "Read error from local file in: $cmd" ;; + 28) msg_error "Operation timed out in: $cmd" ;; + 35) msg_error "SSL connect error in: $cmd" ;; + 47) msg_error "Too many redirects in: $cmd" ;; + 51) msg_error "SSL certificate verification failed in: $cmd" ;; + 52) msg_error "Empty response from server in: $cmd" ;; + 55) msg_error "Send error during transfer in: $cmd" ;; + 56) msg_error "Receive error during transfer in: $cmd" ;; + 60) msg_error "SSL CA certificate not trusted in: $cmd" ;; + 67) msg_error "Login denied by server in: $cmd" ;; + 78) msg_error "Remote file not found (404) in: $cmd" ;; + *) msg_error "Unhandled curl error (exit $exit_code) in: $cmd" ;; + esac + + exit_script +} + # This function displays an informational message with logging support. declare -A MSG_INFO_SHOWN SPINNER_ACTIVE=0 diff --git a/misc/install.func b/misc/install.func index 417c7c1..19f7938 100644 --- a/misc/install.func +++ b/misc/install.func @@ -6,13 +6,10 @@ # https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE if ! command -v curl >/dev/null 2>&1; then - echo "[INFO] curl not found, setup." apt-get update && apt-get install -y curl >/dev/null 2>&1 fi - source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/core.func) load_functions -echo "(install.func) Loaded core.func via curl" # Function to set STD mode based on verbosity set_std_mode() { diff --git a/misc/tools.func b/misc/tools.func index d1c324e..b632665 100644 --- a/misc/tools.func +++ b/misc/tools.func @@ -928,38 +928,3 @@ function setup_gs() { msg_error "Ghostscript installation failed" fi } - -__curl_err_handler() { - local exit_code="$1" - local cmd="${BASH_COMMAND:-unknown}" - if ! grep -q 'curl' <<<"$cmd"; then - return - fi - - case $exit_code in - 1) msg_error "Unsupported protocol in: $cmd" ;; - 2) msg_error "Failed curl initialization in: $cmd" ;; - 3) msg_error "Malformed URL in: $cmd" ;; - 5) msg_error "Could not resolve proxy in: $cmd" ;; - 6) msg_error "Could not resolve host in: $cmd" ;; - 7) msg_error "Failed to connect to host in: $cmd" ;; - 9) msg_error "Access denied to remote resource in: $cmd" ;; - 18) msg_error "Partial file transfer detected in: $cmd" ;; - 22) msg_error "HTTP error response in: $cmd" ;; - 23) msg_error "Write error during transfer in: $cmd" ;; - 26) msg_error "Read error from local file in: $cmd" ;; - 28) msg_error "Operation timed out in: $cmd" ;; - 35) msg_error "SSL connect error in: $cmd" ;; - 47) msg_error "Too many redirects in: $cmd" ;; - 51) msg_error "SSL certificate verification failed in: $cmd" ;; - 52) msg_error "Empty response from server in: $cmd" ;; - 55) msg_error "Send error during transfer in: $cmd" ;; - 56) msg_error "Receive error during transfer in: $cmd" ;; - 60) msg_error "SSL CA certificate not trusted in: $cmd" ;; - 67) msg_error "Login denied by server in: $cmd" ;; - 78) msg_error "Remote file not found (404) in: $cmd" ;; - *) msg_error "Unhandled curl error (exit $exit_code) in: $cmd" ;; - esac - - exit_script -}