Skip to content

Instantly share code, notes, and snippets.

@clifton
Last active January 4, 2021 08:54
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 clifton/7575a9f2a1c64541561bb0e0704c39eb to your computer and use it in GitHub Desktop.
Save clifton/7575a9f2a1c64541561bb0e0704c39eb to your computer and use it in GitHub Desktop.
#!/bin/bash
# sudo crontab -e
# insert at top of crontab: SHELL=/bin/bash
# */1 * * * * /bin/check-net >> /var/log/check-net.log 2>&1
if ! (/usr/bin/dig +short myip.opendns.com @resolver1.opendns.com > /dev/null) ; then
echo $(date) - check-net failed. restarting...
killall wpa_supplicant
sleep 2
/usr/sbin/netplan apply
else
echo $(date) - internet looks OK
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment