Update build.func

This commit is contained in:
CanbiZ 2025-08-04 13:57:41 +02:00
parent da63ff9201
commit 2f151a6389

View File

@ -1364,32 +1364,42 @@ EOF
if [ "$var_os" != "alpine" ]; then if [ "$var_os" != "alpine" ]; then
msg_info "Waiting for network in LXC container" msg_info "Waiting for network in LXC container"
for i in {1..10}; do for i in {1..10}; do
# 1. Primary check: ICMP ping (fastest, but may be blocked by ISP/firewall)
if pct exec "$CTID" -- ping -c1 -W1 deb.debian.org >/dev/null 2>&1; then if pct exec "$CTID" -- ping -c1 -W1 deb.debian.org >/dev/null 2>&1; then
msg_ok "Network in LXC is reachable" msg_ok "Network in LXC is reachable (ping)"
break break
fi fi
# Wait and retry if not reachable yet
if [ "$i" -lt 10 ]; then if [ "$i" -lt 10 ]; then
msg_warn "No network yet in LXC (try $i/10) waiting..." msg_warn "No network in LXC yet (try $i/10) waiting..."
sleep 3 sleep 3
else else
msg_error "No network in LXC after waiting." # After 10 unsuccessful ping attempts, try HTTP connectivity via wget as fallback
read -r -p "Set fallback DNS (1.1.1.1/8.8.8.8)? [y/N]: " choice msg_warn "Ping failed 10 times. Trying HTTP connectivity check (wget) as fallback..."
case "$choice" in if pct exec "$CTID" -- wget -q --spider http://deb.debian.org; then
[yY]*) msg_ok "Network in LXC is reachable (wget fallback)"
pct set "$CTID" --nameserver 1.1.1.1 else
pct set "$CTID" --nameserver 8.8.8.8 msg_error "No network in LXC after all checks."
if pct exec "$CTID" -- ping -c1 -W1 deb.debian.org >/dev/null 2>&1; then read -r -p "Set fallback DNS (1.1.1.1/8.8.8.8)? [y/N]: " choice
msg_ok "Network reachable after DNS fallback" case "$choice" in
else [yY]*)
msg_error "Still no network/DNS in LXC! Aborting customization." pct set "$CTID" --nameserver 1.1.1.1
exit 1 pct set "$CTID" --nameserver 8.8.8.8
fi # Final attempt with wget after DNS change
;; if pct exec "$CTID" -- wget -q --spider http://deb.debian.org; then
*) msg_ok "Network reachable after DNS fallback"
msg_error "Aborted by user no DNS fallback set." else
exit 1 msg_error "Still no network/DNS in LXC! Aborting customization."
;; exit_script
esac fi
;;
*)
msg_error "Aborted by user no DNS fallback set."
exit_script
;;
esac
fi
break
fi fi
done done
fi fi