Created
August 25, 2015 16:03
-
-
Save jonasbjork/92b41ceb7c52c1a50b64 to your computer and use it in GitHub Desktop.
Check wifi connection on RPi2 and reboot if no connection.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Script for checking wifi connection on my headless, hidden, Raspberry Pi 2 | |
| # The idea is to reboot the RPi2 when network connection is lost, so it can come | |
| # up again. Making administration efforts minimal. | |
| # Crontab: | |
| # 0,10,20,30,40,50 * * * * /home/pi/checkwifi.sh | |
| logger -t checkwifi "Checking wifi" | |
| # Change 192.168.0.1 to your router IP-address, or use Google DNS 8.8.8.8 | |
| ping -c4 192.168.76.1 > /dev/null | |
| if [ $? != 0 ] | |
| then | |
| logger -t checkwifi "Wifi not OK, rebooting" | |
| sudo /sbin/shutdown -r now | |
| fi | |
| logger -t checkwifi "Wifi OK, no reboot" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment