I'm new around these parts and to Linux. I wrote this script so my pi can act as a watchdog for my router based VPN. It pings my VPN's DNS that can only be reached if the VPN is active. If it fails it SSH's into the router and reboots it. It works, but this is my first time in this language (most of my background is in PowerShell) so I thought I'd post it somewhere so people can look it over and tell me how to make it better. Here's the script:
Code: Select all
ping -c 1 198.18.0.1 &> /dev/null
if [ $? -ne 0 ]; then
#echo "Router down. Reboot it" #Debugging
ssh 172.16.1.1 -l root "reboot"
else
#echo "VPN Currently Active" #Debugging
fiCode: Select all
0,10,20,30,40,50 * * * * /home/pi/scritps/watch.sh