This simple script just checks if your Raspberry Pi is connected to the Internet or not. So using this script is really easy, it will make Raspberry Pi reboot itself if it’s not connected to the Internet or do something else to get it connected again. This has saved me so many times when I have been using my headless Raspberry Pi setup and when my Raspberry Pi has been connected to Internet via 3G/4G USB modem and it has lost the connection once again.
#!/bin/bash ping -c 3 8.8.8.8 > /dev/null 2>&1 let a=$? if [ "$a" = "0" ]; then echo "We have connection." else echo "We have lost connection." fi
Leave a Reply