Simplify mirror logs and use http for custom mirror
Reduce noisy mirror-related output and clarify messages across misc/build.func and misc/install.func. Reword various apt/mirror status lines (hash mismatch, SSL/certificate, apt-get update failed, package install failed) and standardize success to "Using mirror"/msg_ok. Remove verbose scan/try/skip/count logs and suppression of detailed apt output to make output cleaner for automated runs. Also change the custom_mirror sed replacement to use http:// instead of https:// to support non-HTTPS local mirrors.
This commit is contained in:
@@ -4627,22 +4627,19 @@ EOF'
|
|||||||
APT_OUT=$(apt-get update 2>&1)
|
APT_OUT=$(apt-get update 2>&1)
|
||||||
APT_RC=$?
|
APT_RC=$?
|
||||||
if echo "$APT_OUT" | grep -qi "hashsum\|hash sum"; then
|
if echo "$APT_OUT" | grep -qi "hashsum\|hash sum"; then
|
||||||
echo " [fail] $1 (hash mismatch)"
|
echo " Mirror $1: hash mismatch"
|
||||||
echo "$APT_OUT" | grep -i "hash" | head -3 | sed "s/^/ /"
|
|
||||||
return 1
|
return 1
|
||||||
elif echo "$APT_OUT" | grep -qi "SSL\|certificate"; then
|
elif echo "$APT_OUT" | grep -qi "SSL\|certificate"; then
|
||||||
echo " [fail] $1 (SSL error)"
|
echo " Mirror $1: SSL/certificate error"
|
||||||
echo "$APT_OUT" | grep -i "SSL\|certificate" | head -3 | sed "s/^/ /"
|
|
||||||
return 1
|
return 1
|
||||||
elif [ $APT_RC -ne 0 ]; then
|
elif [ $APT_RC -ne 0 ]; then
|
||||||
echo " [fail] $1 (apt-get update error)"
|
echo " Mirror $1: apt-get update failed"
|
||||||
echo "$APT_OUT" | grep "^E:" | head -3 | sed "s/^/ /"
|
|
||||||
return 1
|
return 1
|
||||||
elif apt-get install -y $APT_BASE >/dev/null 2>&1; then
|
elif apt-get install -y $APT_BASE >/dev/null 2>&1; then
|
||||||
echo " [ok] $1"
|
echo " Using mirror: $1"
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
echo " [fail] $1 (package install error)"
|
echo " Mirror $1: package install failed"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -4652,40 +4649,29 @@ EOF'
|
|||||||
for m in $1; do
|
for m in $1; do
|
||||||
if timeout 2 bash -c "echo >/dev/tcp/$m/80" 2>/dev/null; then
|
if timeout 2 bash -c "echo >/dev/tcp/$m/80" 2>/dev/null; then
|
||||||
result="$result $m"
|
result="$result $m"
|
||||||
else
|
|
||||||
echo " [skip] $m (unreachable)"
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "$result" | xargs
|
echo "$result" | xargs
|
||||||
}
|
}
|
||||||
|
|
||||||
# Phase 1: Scan global mirrors first (independent of local CDN issues)
|
# Phase 1: Scan global mirrors first (independent of local CDN issues)
|
||||||
echo " [scan] Checking global mirrors..."
|
|
||||||
OTHERS_OK=$(scan_reachable "$OTHERS")
|
OTHERS_OK=$(scan_reachable "$OTHERS")
|
||||||
OTHERS_PICK=$(printf "%s\n" $OTHERS_OK | shuf | head -3 | xargs)
|
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 $OTHERS_PICK; do
|
for mirror in $OTHERS_PICK; do
|
||||||
echo " [try] $mirror ..."
|
|
||||||
try_mirrors "$mirror" && exit 0
|
try_mirrors "$mirror" && exit 0
|
||||||
done
|
done
|
||||||
|
|
||||||
# Phase 2: Try ftp.debian.org
|
# Phase 2: Try ftp.debian.org
|
||||||
if timeout 2 bash -c "echo >/dev/tcp/ftp.debian.org/80" 2>/dev/null; then
|
if timeout 2 bash -c "echo >/dev/tcp/ftp.debian.org/80" 2>/dev/null; then
|
||||||
echo " [try] ftp.debian.org ..."
|
|
||||||
try_mirrors "ftp.debian.org" && exit 0
|
try_mirrors "ftp.debian.org" && exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Phase 3: Fall back to regional mirrors
|
# Phase 3: Fall back to regional mirrors
|
||||||
echo " [scan] Checking regional mirrors..."
|
|
||||||
REGIONAL_OK=$(scan_reachable "$REGIONAL")
|
REGIONAL_OK=$(scan_reachable "$REGIONAL")
|
||||||
REGIONAL_PICK=$(printf "%s\n" $REGIONAL_OK | shuf | head -3 | xargs)
|
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 $REGIONAL_PICK; do
|
for mirror in $REGIONAL_PICK; do
|
||||||
echo " [try] $mirror ..."
|
|
||||||
try_mirrors "$mirror" && exit 0
|
try_mirrors "$mirror" && exit 0
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -4705,7 +4691,7 @@ EOF'
|
|||||||
}
|
}
|
||||||
pct exec "$CTID" -- bash -c "
|
pct exec "$CTID" -- bash -c "
|
||||||
for src in /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list; do
|
for src in /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list; do
|
||||||
[ -f \"\$src\" ] && sed -i \"s|URIs: http[s]*://[^/]*/|URIs: https://${custom_mirror}/|g; s|deb http[s]*://[^/]*/|deb https://${custom_mirror}/|g\" \"\$src\"
|
[ -f \"\$src\" ] && sed -i \"s|URIs: http[s]*://[^/]*/|URIs: http://${custom_mirror}/|g; s|deb http[s]*://[^/]*/|deb http://${custom_mirror}/|g\" \"\$src\"
|
||||||
done
|
done
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
apt-get update >/dev/null 2>&1 && apt-get install -y sudo curl mc gnupg2 jq >/dev/null 2>&1
|
apt-get update >/dev/null 2>&1 && apt-get install -y sudo curl mc gnupg2 jq >/dev/null 2>&1
|
||||||
|
|||||||
@@ -238,16 +238,13 @@ pkg_update() {
|
|||||||
local out
|
local out
|
||||||
out=$(apt-get update 2>&1)
|
out=$(apt-get update 2>&1)
|
||||||
if echo "$out" | grep -qi "hashsum\|hash sum"; then
|
if echo "$out" | grep -qi "hashsum\|hash sum"; then
|
||||||
msg_warn "Mirror failed: ${m} (hash mismatch)"
|
msg_warn "Mirror ${m}: hash mismatch, trying next..."
|
||||||
echo "$out" | grep -i "hash" | head -3 | sed 's/^/ /'
|
|
||||||
return 1
|
return 1
|
||||||
elif echo "$out" | grep -qi "SSL\|certificate"; then
|
elif echo "$out" | grep -qi "SSL\|certificate"; then
|
||||||
msg_warn "Mirror failed: ${m} (SSL error)"
|
msg_warn "Mirror ${m}: SSL/certificate error, trying next..."
|
||||||
echo "$out" | grep -i "SSL\|certificate" | head -3 | sed 's/^/ /'
|
|
||||||
return 1
|
return 1
|
||||||
elif echo "$out" | grep -q "^E:"; then
|
elif echo "$out" | grep -q "^E:"; then
|
||||||
msg_warn "Mirror failed: ${m} (apt-get update error)"
|
msg_warn "Mirror ${m}: apt-get update failed, trying next..."
|
||||||
echo "$out" | grep "^E:" | head -3 | sed 's/^/ /'
|
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
msg_ok "Using mirror: ${m}"
|
msg_ok "Using mirror: ${m}"
|
||||||
@@ -260,8 +257,6 @@ pkg_update() {
|
|||||||
for m in $1; do
|
for m in $1; do
|
||||||
if timeout 2 bash -c "echo >/dev/tcp/$m/80" 2>/dev/null; then
|
if timeout 2 bash -c "echo >/dev/tcp/$m/80" 2>/dev/null; then
|
||||||
result="$result $m"
|
result="$result $m"
|
||||||
else
|
|
||||||
msg_info "Mirror skip: ${m} (unreachable)"
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "$result" | xargs
|
echo "$result" | xargs
|
||||||
@@ -270,17 +265,12 @@ pkg_update() {
|
|||||||
local apt_ok=false
|
local apt_ok=false
|
||||||
|
|
||||||
# Phase 1: Scan global mirrors first (independent of local CDN issues)
|
# Phase 1: Scan global mirrors first (independent of local CDN issues)
|
||||||
msg_info "Scanning global mirrors..."
|
|
||||||
local others_ok
|
local others_ok
|
||||||
others_ok=$(_scan_reachable "$others")
|
others_ok=$(_scan_reachable "$others")
|
||||||
local others_pick
|
local others_pick
|
||||||
others_pick=$(printf '%s\n' $others_ok | shuf | head -3 | xargs)
|
others_pick=$(printf '%s\n' $others_ok | shuf | head -3 | xargs)
|
||||||
local o_count
|
|
||||||
o_count=$(echo "$others_pick" | wc -w)
|
|
||||||
msg_info "Found ${o_count} global mirrors to try"
|
|
||||||
|
|
||||||
for mirror in $others_pick; do
|
for mirror in $others_pick; do
|
||||||
msg_info "Trying mirror: ${mirror}"
|
|
||||||
if _try_apt_mirror "$mirror"; then
|
if _try_apt_mirror "$mirror"; then
|
||||||
apt_ok=true
|
apt_ok=true
|
||||||
break
|
break
|
||||||
@@ -290,7 +280,6 @@ pkg_update() {
|
|||||||
# Phase 2: Try ftp.debian.org
|
# Phase 2: Try ftp.debian.org
|
||||||
if [[ "$apt_ok" != true ]]; then
|
if [[ "$apt_ok" != true ]]; then
|
||||||
if timeout 2 bash -c "echo >/dev/tcp/ftp.debian.org/80" 2>/dev/null; then
|
if timeout 2 bash -c "echo >/dev/tcp/ftp.debian.org/80" 2>/dev/null; then
|
||||||
msg_info "Trying mirror: ftp.debian.org"
|
|
||||||
if _try_apt_mirror "ftp.debian.org"; then
|
if _try_apt_mirror "ftp.debian.org"; then
|
||||||
apt_ok=true
|
apt_ok=true
|
||||||
fi
|
fi
|
||||||
@@ -299,17 +288,12 @@ pkg_update() {
|
|||||||
|
|
||||||
# Phase 3: Fall back to regional mirrors
|
# Phase 3: Fall back to regional mirrors
|
||||||
if [[ "$apt_ok" != true ]]; then
|
if [[ "$apt_ok" != true ]]; then
|
||||||
msg_info "Scanning regional mirrors..."
|
|
||||||
local regional_ok
|
local regional_ok
|
||||||
regional_ok=$(_scan_reachable "$regional")
|
regional_ok=$(_scan_reachable "$regional")
|
||||||
local regional_pick
|
local regional_pick
|
||||||
regional_pick=$(printf '%s\n' $regional_ok | shuf | head -3 | xargs)
|
regional_pick=$(printf '%s\n' $regional_ok | shuf | head -3 | xargs)
|
||||||
local r_count
|
|
||||||
r_count=$(echo "$regional_pick" | wc -w)
|
|
||||||
msg_info "Found ${r_count} regional mirrors to try"
|
|
||||||
|
|
||||||
for mirror in $regional_pick; do
|
for mirror in $regional_pick; do
|
||||||
msg_info "Trying mirror: ${mirror}"
|
|
||||||
if _try_apt_mirror "$mirror"; then
|
if _try_apt_mirror "$mirror"; then
|
||||||
apt_ok=true
|
apt_ok=true
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user