Try global mirrors first; add apt fallback

Reorder mirror probing in misc/build.func and misc/install.func to scan global (OTHERS) mirrors first and fall back to regional mirrors—pick up to 3 random reachable mirrors and try them. Rename related variables accordingly and keep the fallback logic intact. Update tools/pve/update-lxcs-cron.sh to define region-specific Debian mirror lists, detect container timezone to pick regional vs other mirrors, and implement a fallback loop that checks mirror connectivity, rewrites APT URIs to use a working mirror, and retries apt-get update before proceeding with dist-upgrade. These changes improve resilience against local CDN/local-regional outages by preferring globally reachable mirrors first and providing an automated mirror-switch fallback.
This commit is contained in:
CanbiZ (MickLesk)
2026-03-26 14:52:03 +01:00
parent 9db2169ee0
commit cd1c412822
2 changed files with 34 additions and 34 deletions

View File

@@ -4655,14 +4655,14 @@ EOF'
echo "$result" | xargs
}
# Phase 1: Scan regional mirrors, pick 3 random, try them
echo " [scan] Checking regional mirrors..."
REGIONAL_OK=$(scan_reachable "$REGIONAL")
REGIONAL_PICK=$(printf "%s\n" $REGIONAL_OK | shuf | head -3 | xargs)
R_COUNT=$(echo $REGIONAL_PICK | wc -w)
echo " [scan] $R_COUNT regional mirrors reachable (of $(echo $REGIONAL | wc -w))"
# Phase 1: Scan global mirrors first (independent of local CDN issues)
echo " [scan] Checking global mirrors..."
OTHERS_OK=$(scan_reachable "$OTHERS")
OTHERS_PICK=$(printf "%s\n" $OTHERS_OK | shuf | head -3 | xargs)
O_COUNT=$(echo $OTHERS_PICK | wc -w)
echo " [scan] $O_COUNT global mirrors reachable (of $(echo $OTHERS | wc -w))"
for mirror in $REGIONAL_PICK; do
for mirror in $OTHERS_PICK; do
echo " [try] $mirror ..."
try_mirrors "$mirror" && exit 0
done
@@ -4673,14 +4673,14 @@ EOF'
try_mirrors "ftp.debian.org" && exit 0
fi
# Phase 3: Scan rest-of-world mirrors, pick 3 random, try them
echo " [scan] Checking global mirrors..."
OTHERS_OK=$(scan_reachable "$OTHERS")
OTHERS_PICK=$(printf "%s\n" $OTHERS_OK | shuf | head -3 | xargs)
O_COUNT=$(echo $OTHERS_PICK | wc -w)
echo " [scan] $O_COUNT global mirrors reachable (of $(echo $OTHERS | wc -w))"
# Phase 3: Fall back to regional mirrors
echo " [scan] Checking regional mirrors..."
REGIONAL_OK=$(scan_reachable "$REGIONAL")
REGIONAL_PICK=$(printf "%s\n" $REGIONAL_OK | shuf | head -3 | xargs)
R_COUNT=$(echo $REGIONAL_PICK | wc -w)
echo " [scan] $R_COUNT regional mirrors reachable (of $(echo $REGIONAL | wc -w))"
for mirror in $OTHERS_PICK; do
for mirror in $REGIONAL_PICK; do
echo " [try] $mirror ..."
try_mirrors "$mirror" && exit 0
done