Merge branch 'main' of https://github.com/community-scripts/ProxmoxVED
This commit is contained in:
commit
46b155ba95
@ -27,7 +27,7 @@ msg_ok "Installed Dependencies"
|
|||||||
|
|
||||||
msg_info "Installing Babybuddy"
|
msg_info "Installing Babybuddy"
|
||||||
cd /opt
|
cd /opt
|
||||||
RELEASE=$(curl -fsSL https://api.github.com/repos/babybuddys/babybuddy/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
RELEASE=$(community_curl https://api.github.com/repos/babybuddys/babybuddy/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
||||||
wget -q "https://github.com/babybuddy/babybuddy/archive/refs/tags/v${RELEASE}.zip"
|
wget -q "https://github.com/babybuddy/babybuddy/archive/refs/tags/v${RELEASE}.zip"
|
||||||
unzip -q v${RELEASE}.zip
|
unzip -q v${RELEASE}.zip
|
||||||
mv babybuddy-${RELEASE} /opt/babybuddy
|
mv babybuddy-${RELEASE} /opt/babybuddy
|
||||||
|
@ -279,7 +279,6 @@ echo_default() {
|
|||||||
|
|
||||||
# This function is called when the user decides to exit the script. It clears the screen and displays an exit message.
|
# This function is called when the user decides to exit the script. It clears the screen and displays an exit message.
|
||||||
exit_script() {
|
exit_script() {
|
||||||
[[ -n "${SPINNER_PID:-}" ]] && kill "$SPINNER_PID" &>/dev/null || true
|
|
||||||
clear
|
clear
|
||||||
echo -e "\n${CROSS}${RD}User exited script${CL}\n"
|
echo -e "\n${CROSS}${RD}User exited script${CL}\n"
|
||||||
exit
|
exit
|
||||||
|
@ -71,6 +71,35 @@ default_vars() {
|
|||||||
i=$RETRY_NUM
|
i=$RETRY_NUM
|
||||||
}
|
}
|
||||||
|
|
||||||
|
community_curl() {
|
||||||
|
local url="$1"
|
||||||
|
shift
|
||||||
|
local max_retries=3
|
||||||
|
local delay=2
|
||||||
|
local attempt=1
|
||||||
|
local result exit_code
|
||||||
|
|
||||||
|
msg_info "Fetching: $url"
|
||||||
|
|
||||||
|
while :; do
|
||||||
|
result=$(curl -fsSL --retry 0 "$url" "$@" 2>/dev/null)
|
||||||
|
exit_code=$?
|
||||||
|
if [[ $exit_code -eq 0 ]]; then
|
||||||
|
printf '%s' "$result"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ((attempt >= max_retries)); then
|
||||||
|
__curl_err_handler "$exit_code"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
msg_info "Curl failed (attempt $attempt of $max_retries). Retrying in ${delay}s..."
|
||||||
|
sleep "$delay"
|
||||||
|
((attempt++))
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
__curl_err_handler() {
|
__curl_err_handler() {
|
||||||
local exit_code="$1"
|
local exit_code="$1"
|
||||||
local cmd="${BASH_COMMAND:-unknown}"
|
local cmd="${BASH_COMMAND:-unknown}"
|
||||||
@ -103,7 +132,7 @@ __curl_err_handler() {
|
|||||||
*) msg_error "Unhandled curl error (exit $exit_code) in: $cmd" ;;
|
*) msg_error "Unhandled curl error (exit $exit_code) in: $cmd" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit_script
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function displays an informational message with logging support.
|
# This function displays an informational message with logging support.
|
||||||
@ -172,27 +201,3 @@ msg_error() {
|
|||||||
local msg="$1"
|
local msg="$1"
|
||||||
printf "\r\e[2K%s %b\n" "${CROSS}" "${RD}${msg}${CL}" >&2
|
printf "\r\e[2K%s %b\n" "${CROSS}" "${RD}${msg}${CL}" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ -n "$BASH_VERSION" ]] && [[ "$OSTYPE" != "alpine"* ]]; then
|
|
||||||
__last_command=""
|
|
||||||
__last_result=0
|
|
||||||
|
|
||||||
# Enable extended tracing
|
|
||||||
set -o errtrace
|
|
||||||
set -o functrace
|
|
||||||
|
|
||||||
# Track the last command and its exit code
|
|
||||||
trap '__last_result=$?; __last_command=$BASH_COMMAND' DEBUG
|
|
||||||
|
|
||||||
# Global error handler
|
|
||||||
trap '__global_err_handler "$__last_result" "$__last_command"' ERR
|
|
||||||
|
|
||||||
__global_err_handler() {
|
|
||||||
local exit_code="$1"
|
|
||||||
local cmd="$2"
|
|
||||||
[[ $cmd == curl* ]] && __curl_err_handler "$exit_code"
|
|
||||||
}
|
|
||||||
else
|
|
||||||
# Alpine oder nicht-Bash: Hinweis bei Curl-Fehlern nicht verfügbar
|
|
||||||
export BASH_FALLBACK_CURL_HANDLER=1
|
|
||||||
fi
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user