Last active
April 18, 2017 02:38
-
-
Save markryd/f64abb84c1f2594fe84084e198e63a9d to your computer and use it in GitHub Desktop.
nbn modem monitor
This file contains 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
#!/bin/bash | |
# check if we are already rebooting and exit | |
if [ -f /home/pi/heartbeat/rebooting ] ; then | |
exit 0 | |
fi | |
# ping and exit on success | |
ping -c 1 -w 5 8.8.8.8 &> /dev/null | |
if [ "$?" = 0 ] ; then | |
exit 0 | |
fi | |
touch /home/pi/heartbeat/rebooting | |
echo "Rebooting modem $(date)" >> /home/pi/heartbeat/heartbeat.log | |
/usr/local/bin/wemo switch "NBN modem" off | |
sleep 2s | |
/usr/local/bin/wemo switch "NBN modem" on | |
sleep 5m | |
rm /home/pi/heartbeat/rebooting | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment