From 71ca43c7a2e7ca45f466034d3e2743329e895e7c Mon Sep 17 00:00:00 2001 From: tteckster Date: Wed, 21 Feb 2024 12:19:48 -0500 Subject: [PATCH] Update install.func The script now checks for both IPv4 and IPv6 Internet connectivity and displays the results. Only if both IPv4 and IPv6 checks fail, it will then prompt the user. --- misc/install.func | 50 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/misc/install.func b/misc/install.func index d6aaf6c4..3deb63d1 100644 --- a/misc/install.func +++ b/misc/install.func @@ -112,35 +112,33 @@ setting_up_container() { network_check() { set +e trap - ERR -# Check if IPv4 is being used - if ip -o -4 addr show | grep -q "scope global"; then - if ping -c 1 -W 1 1.1.1.1 &>/dev/null; then - msg_ok "IPv4 Internet Connected"; - else - msg_error "IPv4 Internet Not Connected"; - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi - fi + ipv4_connected=false + ipv6_connected=false + +# Check IPv4 connectivity + if ping -c 1 -W 1 1.1.1.1 &>/dev/null; then + msg_ok "IPv4 Internet Connected"; + ipv4_connected=true + else + msg_error "IPv4 Internet Not Connected"; fi -# Check if IPv6 is being used - if ip -o -6 addr show | grep -q "scope global"; then - if ping -6 google.com &>/dev/null; then - msg_ok "IPv6 Internet Connected"; +# Check IPv6 connectivity + if ping6 -c 1 -W 1 2606:4700:4700::1111 &>/dev/null; then + msg_ok "IPv6 Internet Connected"; + ipv6_connected=true + else + msg_error "IPv6 Internet Not Connected"; + fi + +# 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? " prompt + if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" else - msg_error "IPv6 Internet Not Connected"; - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi + echo -e " 🖧 Check Network Settings" + exit 1 fi fi