mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-02-28 07:55:55 +01:00
feat: graceful fallback for apt-get update failures (#12386)
Add apt_update_safe() function that warns instead of aborting when apt-get update fails (e.g. enterprise repo 401 Unauthorized). Shows a helpful hint about disabling the enterprise repo when no subscription is active. Replaces direct apt-get update calls in build.func and install.func.
This commit is contained in:
committed by
GitHub
parent
9e9dfd6947
commit
a2dc3f44d3
@@ -4927,7 +4927,8 @@ create_lxc_container() {
|
||||
case "${_ans,,}" in
|
||||
y | yes)
|
||||
msg_info "Upgrading Proxmox LXC stack (pve-container, lxc-pve)"
|
||||
if $STD apt-get update && $STD apt-get install -y --only-upgrade pve-container lxc-pve; then
|
||||
apt_update_safe
|
||||
if $STD apt-get install -y --only-upgrade pve-container lxc-pve; then
|
||||
msg_ok "LXC stack upgraded."
|
||||
if [[ "$do_retry" == "yes" ]]; then
|
||||
msg_info "Retrying container creation after upgrade"
|
||||
|
||||
@@ -552,6 +552,53 @@ silent() {
|
||||
fi
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# apt_update_safe()
|
||||
#
|
||||
# - Runs apt-get update with graceful error handling
|
||||
# - On failure: shows warning with common causes instead of aborting
|
||||
# - Logs full output to active log file
|
||||
# - Returns 0 even on failure so the caller can continue
|
||||
# - Typical cause: enterprise repos returning 401 Unauthorized
|
||||
#
|
||||
# Usage:
|
||||
# apt_update_safe # Warn on failure, continue without aborting
|
||||
# ------------------------------------------------------------------------------
|
||||
apt_update_safe() {
|
||||
local logfile
|
||||
logfile="$(get_active_logfile)"
|
||||
|
||||
local _restore_errexit=false
|
||||
[[ "$-" == *e* ]] && _restore_errexit=true
|
||||
|
||||
set +Eeuo pipefail
|
||||
trap - ERR
|
||||
|
||||
apt-get update >>"$logfile" 2>&1
|
||||
local rc=$?
|
||||
|
||||
if $_restore_errexit; then
|
||||
set -Eeuo pipefail
|
||||
trap 'error_handler' ERR
|
||||
fi
|
||||
|
||||
if [[ $rc -ne 0 ]]; then
|
||||
msg_warn "apt-get update exited with code ${rc} — some repositories may have failed."
|
||||
|
||||
# Check log for common 401/403 enterprise repo issues
|
||||
if grep -qiE '401\s*Unauthorized|403\s*Forbidden|enterprise\.proxmox\.com' "$logfile" 2>/dev/null; then
|
||||
echo -e "${TAB}${INFO} ${YWB}Hint: Proxmox enterprise repository returned an auth error.${CL}"
|
||||
echo -e "${TAB} If you don't have a subscription, you can disable the enterprise"
|
||||
echo -e "${TAB} repo and use the no-subscription repo instead."
|
||||
fi
|
||||
|
||||
echo -e "${TAB}${INFO} ${YWB}Continuing despite partial update failure — packages may still be installable.${CL}"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# spinner()
|
||||
#
|
||||
|
||||
@@ -233,7 +233,7 @@ fi
|
||||
EOF
|
||||
chmod +x /usr/local/bin/apt-proxy-detect.sh
|
||||
fi
|
||||
$STD apt-get update
|
||||
apt_update_safe
|
||||
$STD apt-get -o Dpkg::Options::="--force-confold" -y dist-upgrade
|
||||
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
|
||||
msg_ok "Updated Container OS"
|
||||
|
||||
Reference in New Issue
Block a user