km4ack / patmenu2

Tools for working with Pat Menu
GNU General Public License v3.0
21 stars 9 forks source link

check for internet before downloading gateway list #50

Closed km4ack closed 2 years ago

km4ack commented 2 years ago

If a pi boots into hotspot mode before connecting to a known good SSID, the gateway list download will fail if it is run at boot from cron. To avoid this, we need to add a check for internet when the getardoplist-cron script is called. This code should work at the beginning of the script:

#check for internet before attempting to download the list

internet=1    #set the test to false

while [ "$internet" = 1 ]; do
echo "check for internet connection"
ping -c 5 8.8.8.8
internet=$?
sleep 60    #wait one minute before trying again
done

echo "Internet connection detected"

If no connection is detected, the script will retry every 60 seconds.