Created
October 31, 2020 13:50
-
-
Save mattkasun/9a0e90d9d31b2c935d3f6d6e71dbece9 to your computer and use it in GitHub Desktop.
wireguard watchdog script
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
| #!/bin/bash | |
| tries=0 | |
| while [[ $tries -lt 3 ]] | |
| do | |
| if /bin/ping -c 1 10.200.200.1 | |
| then | |
| # echo "wg working" | |
| logger -n winterfell -i -t "wg-watchdog" -p user.notice "wireguard working" | |
| exit 0 | |
| fi | |
| ## echo "wg fail" | |
| tries=$((tries+1)) | |
| done | |
| #echo "restarting wg" | |
| sudo systemctl restart wg-quick@wg0 | |
| logger -n winterfell -i -t "wg-watchdog" -p user.notice "wireguard restarted" | |
| #crontab entry | |
| #*/15 * * * * /home/mkasun/bin/wg-watchdog.sh |
I have a one-liner in cron
*/1 * * * * root if ! /bin/ping -c 1 10.10.10.11; then systemctl restart wg-quick@wg9; fi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am surprised we need to do that :(
This is my version of the script: