Skip to content

Instantly share code, notes, and snippets.

@markryd
Last active April 18, 2017 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markryd/f64abb84c1f2594fe84084e198e63a9d to your computer and use it in GitHub Desktop.
Save markryd/f64abb84c1f2594fe84084e198e63a9d to your computer and use it in GitHub Desktop.
nbn modem monitor
#!/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