mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-07-30 01:32:56 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 00c18ddad8 | |||
| 18cbd7fb50 |
@@ -10,8 +10,29 @@ fi
|
|||||||
# must write local failure artifacts instead of talking to the telemetry API
|
# must write local failure artifacts instead of talking to the telemetry API
|
||||||
# (the host is the single telemetry reporter).
|
# (the host is the single telemetry reporter).
|
||||||
export TELEMETRY_CONTEXT="container"
|
export TELEMETRY_CONTEXT="container"
|
||||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/core.func)
|
# A freshly booted container may not have DNS up yet. `source <(curl ...)` hides
|
||||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/error_handler.func)
|
# curl's exit code, so a failed download would silently source an empty stream.
|
||||||
|
_bootstrap_die() {
|
||||||
|
if declare -f msg_error >/dev/null 2>&1; then
|
||||||
|
msg_error "$1"
|
||||||
|
else
|
||||||
|
echo "FATAL: $1" >&2
|
||||||
|
fi
|
||||||
|
exit 115
|
||||||
|
}
|
||||||
|
|
||||||
|
_bootstrap_source() {
|
||||||
|
local url="$1" probe="$2" content
|
||||||
|
content=$(curl -fsSL --connect-timeout 10 --retry 5 --retry-connrefused --retry-delay 2 "$url") ||
|
||||||
|
_bootstrap_die "Failed to download ${url##*/}"
|
||||||
|
source /dev/stdin <<<"$content"
|
||||||
|
declare -f "$probe" >/dev/null 2>&1 ||
|
||||||
|
_bootstrap_die "${url##*/} loaded but incomplete (missing ${probe})"
|
||||||
|
}
|
||||||
|
|
||||||
|
_FUNC_BASE="https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc"
|
||||||
|
_bootstrap_source "$_FUNC_BASE/core.func" load_functions
|
||||||
|
_bootstrap_source "$_FUNC_BASE/error_handler.func" catch_errors
|
||||||
load_functions
|
load_functions
|
||||||
catch_errors
|
catch_errors
|
||||||
|
|
||||||
|
|||||||
+31
-12
@@ -88,19 +88,38 @@ variables() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func)
|
# `source <(curl ...)` hides the download exit code, so a failed fetch would
|
||||||
|
# silently source an empty stream and leave the helpers undefined.
|
||||||
|
_bootstrap_die() {
|
||||||
|
if declare -f msg_error >/dev/null 2>&1; then
|
||||||
|
msg_error "$1"
|
||||||
|
else
|
||||||
|
echo "FATAL: $1" >&2
|
||||||
|
fi
|
||||||
|
exit 115
|
||||||
|
}
|
||||||
|
|
||||||
if command -v curl >/dev/null 2>&1; then
|
_bootstrap_source() {
|
||||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/core.func)
|
local url="$1" probe="$2" content=""
|
||||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/error_handler.func)
|
if command -v curl >/dev/null 2>&1; then
|
||||||
load_functions
|
content=$(curl -fsSL --connect-timeout 10 --retry 5 --retry-connrefused --retry-delay 2 "$url") || content=""
|
||||||
catch_errors
|
elif command -v wget >/dev/null 2>&1; then
|
||||||
elif command -v wget >/dev/null 2>&1; then
|
content=$(wget -qO- --tries=5 --timeout=10 "$url") || content=""
|
||||||
source <(wget -qO- https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/core.func)
|
else
|
||||||
source <(wget -qO- https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/error_handler.func)
|
_bootstrap_die "Neither curl nor wget available"
|
||||||
load_functions
|
fi
|
||||||
catch_errors
|
[[ -n "$content" ]] || _bootstrap_die "Failed to download ${url##*/}"
|
||||||
fi
|
source /dev/stdin <<<"$content"
|
||||||
|
declare -f "$probe" >/dev/null 2>&1 ||
|
||||||
|
_bootstrap_die "${url##*/} loaded but incomplete (missing ${probe})"
|
||||||
|
}
|
||||||
|
|
||||||
|
_FUNC_BASE="https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc"
|
||||||
|
_bootstrap_source "$_FUNC_BASE/api.func" post_to_api
|
||||||
|
_bootstrap_source "$_FUNC_BASE/core.func" load_functions
|
||||||
|
_bootstrap_source "$_FUNC_BASE/error_handler.func" catch_errors
|
||||||
|
load_functions
|
||||||
|
catch_errors
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# SECTION 2: PRE-FLIGHT CHECKS & SYSTEM VALIDATION
|
# SECTION 2: PRE-FLIGHT CHECKS & SYSTEM VALIDATION
|
||||||
|
|||||||
+23
-2
@@ -37,8 +37,29 @@ fi
|
|||||||
# (the host is the single telemetry reporter).
|
# (the host is the single telemetry reporter).
|
||||||
export TELEMETRY_CONTEXT="container"
|
export TELEMETRY_CONTEXT="container"
|
||||||
|
|
||||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/core.func)
|
# A freshly booted container may not have DNS up yet. `source <(curl ...)` hides
|
||||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/error_handler.func)
|
# curl's exit code, so a failed download would silently source an empty stream.
|
||||||
|
_bootstrap_die() {
|
||||||
|
if declare -f msg_error >/dev/null 2>&1; then
|
||||||
|
msg_error "$1"
|
||||||
|
else
|
||||||
|
echo "FATAL: $1" >&2
|
||||||
|
fi
|
||||||
|
exit 115
|
||||||
|
}
|
||||||
|
|
||||||
|
_bootstrap_source() {
|
||||||
|
local url="$1" probe="$2" content
|
||||||
|
content=$(curl -fsSL --connect-timeout 10 --retry 5 --retry-connrefused --retry-delay 2 "$url") ||
|
||||||
|
_bootstrap_die "Failed to download ${url##*/}"
|
||||||
|
source /dev/stdin <<<"$content"
|
||||||
|
declare -f "$probe" >/dev/null 2>&1 ||
|
||||||
|
_bootstrap_die "${url##*/} loaded but incomplete (missing ${probe})"
|
||||||
|
}
|
||||||
|
|
||||||
|
_FUNC_BASE="https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc"
|
||||||
|
_bootstrap_source "$_FUNC_BASE/core.func" load_functions
|
||||||
|
_bootstrap_source "$_FUNC_BASE/error_handler.func" catch_errors
|
||||||
load_functions
|
load_functions
|
||||||
catch_errors
|
catch_errors
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user