Compact network check output: combine IPv4/IPv6 status into single line

This commit is contained in:
CanbiZ
2025-11-17 16:11:14 +01:00
parent 1c80a22685
commit 9607c83465
3 changed files with 16 additions and 9 deletions

View File

@@ -122,20 +122,23 @@ network_check() {
# Check IPv4 connectivity to Google, Cloudflare & Quad9 DNS servers.
if ping -c 1 -W 1 1.1.1.1 &>/dev/null || ping -c 1 -W 1 8.8.8.8 &>/dev/null || ping -c 1 -W 1 9.9.9.9 &>/dev/null; then
msg_ok "IPv4 Internet Connected"
ipv4_connected=true
ipv4_status="${GN}✔${CL} IPv4"
else
msg_error "IPv4 Internet Not Connected"
ipv4_status="${RD}✖${CL} IPv4"
fi
# Check IPv6 connectivity to Google, Cloudflare & Quad9 DNS servers.
if ping6 -c 1 -W 1 2606:4700:4700::1111 &>/dev/null || ping6 -c 1 -W 1 2001:4860:4860::8888 &>/dev/null || ping6 -c 1 -W 1 2620:fe::fe &>/dev/null; then
msg_ok "IPv6 Internet Connected"
ipv6_connected=true
ipv6_status="${GN}✔${CL} IPv6"
else
msg_error "IPv6 Internet Not Connected"
ipv6_status="${RD}✖${CL} IPv6"
fi
# Show combined status
msg_ok "Internet: ${ipv4_status} ${ipv6_status}"
# If both IPv4 and IPv6 checks fail, prompt the user
if [[ $ipv4_connected == false && $ipv6_connected == false ]]; then
read -r -p "No Internet detected, would you like to continue anyway? <y/N> " prompt