@@ -125,7 +125,7 @@ function connectivitycheck(){
125125 if [ ! " $SKIP_PRELIM " == " 1" ] || [ " $TESTOPT " -eq 1 ];
126126 then
127127 boldtext " Preliminary test to $1 for web connectivity..."
128- if [ " $OS " == " linux" ] || [ " $OS " == " mac" ] && [ " $( ping -c 1 " $1 " ) " ];
128+ if [ " $OS " == " linux" ] || [ " $OS " == " mac" ] && [ " $( $PINGS -c 1 " $1 " ) " ];
129129 then
130130 # we are online
131131 green " $1 can be reached."
@@ -134,7 +134,7 @@ function connectivitycheck(){
134134 logger -s " $1 appears to be offline, you have no web access or the nettest config file wasn't properly generated. Exiting..."
135135 exit 1
136136 # windows returns garbage even if the ping fails, so a more explicit condition is necessary
137- elif [ " $OS " == " windows" ] && [ " $( ping -n 1 " $1 " | grep " Request timed out." ) " == " " ];
137+ elif [ " $OS " == " windows" ] && [ " $( $PINGS -n 1 " $1 " | grep " Request timed out." ) " == " " ];
138138 then
139139 green " $1 can be reached."
140140 else
@@ -159,7 +159,7 @@ function internal_network_check(){
159159 fi
160160
161161 # check external ip from internal_network_check() argument + ping test if conditions are met
162- if [ " $1 " == " $NAT_IP " ] && [ ! " $VPN " ] && [[ ! " $VPN " && " $( ping -c 1 " $INTERNAL_CHECK " ) " ]] ;
162+ if [ " $1 " == " $NAT_IP " ] && [ ! " $VPN " ] && [[ ! " $VPN " && " $( $PINGS -c 1 " $INTERNAL_CHECK " ) " ]] ;
163163 then
164164 INTERNAL_CONN=" yes"
165165 INTERNALscreen=$( green " $INTERNAL_CONN " )
@@ -488,6 +488,20 @@ then
488488 exit 0
489489fi
490490
491+ # macs are special with ping, so pull prefs ahead of time
492+ if [ " $OS " == ' linux' ] || [ " $OS " == ' windows' ] && [ " $PINGPROTOCOL " == ' -6' ];
493+ then
494+ PINGS=' ping -6'
495+ elif [ " $OS " == ' linux' ] || [ " $OS " == ' windows' ] && [ " $PINGPROTOCOL " == ' -4' ];
496+ then
497+ PINGS=' ping -4'
498+ elif [ " $OS " == ' mac' ] && [ " $PINGPROTOCOL " == ' -6' ];
499+ then
500+ PINGS=' ping6'
501+ else
502+ PINGS=' ping'
503+ fi
504+
491505# ask the user what they want to do
492506testoption
493507
@@ -501,19 +515,6 @@ then
501515 connectivitycheck " $CHECK2 "
502516fi
503517
504- # send all ouput to file (unused for now may activate in future)
505-
506- # filename=$(date +%Y%m%d-%H%M%S"nettest.txt")
507- # exec &> >(tee -a $filename)
508- # clear
509-
510- # send message to telegram that network test has begun (unused for now may activate in future)
511- # curl -s \
512- # -X POST \
513- # https://api.telegram.org/bot926576666:AAHWYsxbr6SRouzENRQ7_MJR-bNADCt5Wi4/sendMessage \
514- # -d text="Creating Network test file ${filename}" \
515- # -d chat_id=335712924 >> /dev/null
516-
517518iip=$( dig @resolver1.opendns.com ANY myip.opendns.com +short)
518519
519520# test for internal network connectivity
994995 function pingOptions {
995996 if [ " $OS " != ' windows' ];
996997 then
997- ping " $PINGPROTOCOL " -c 3 -q $1
998+ " $PINGS " -c 3 -q $1
998999 else
999- ping -n 3 $1
1000+ " $PINGS " -n 3 $1
10001001 fi
10011002 }
10021003
@@ -1012,9 +1013,9 @@ then
10121013
10131014 if [ " $OS " != ' windows' ];
10141015 then
1015- echo " $( ping " $PINGPROTOCOL " -c 20 -q " $i " | grep " packet loss" | awk -F ' ,' ' {print $3}' | awk ' {print $1}' ) " " packet loss" & spinner
1016+ echo " $( $PINGS -c 20 -q " $i " | grep " packet loss" | awk -F ' ,' ' {print $3}' | awk ' {print $1}' ) " " packet loss" & spinner
10161017 else
1017- ping " $i " | grep -o " Lost = .*" & spinner
1018+ " $PINGS " " $i " | grep -o " Lost = .*" & spinner
10181019 fi
10191020
10201021 echo
@@ -1035,9 +1036,9 @@ then
10351036
10361037 if [ " $OS " != ' windows' ];
10371038 then
1038- echo " $( ping " $PINGPROTOCOL " -c 20 -q $CHECK1 | grep " packet loss" | awk -F ' ,' ' {print $3}' | awk ' {print $1}' ) " " packet loss" & spinner
1039+ echo " $( $PINGS -c 20 -q $CHECK1 | grep " packet loss" | awk -F ' ,' ' {print $3}' | awk ' {print $1}' ) " " packet loss" & spinner
10391040 else
1040- ping -n 20 $CHECK1 | grep -o " Lost = .*" & spinner
1041+ " $PINGS " -n 20 $CHECK1 | grep -o " Lost = .*" & spinner
10411042 fi
10421043
10431044 else
0 commit comments