watchdog script for openwrt

sometimes my 3g based openwrt system gets in a broken state, and as it is going to be remote, I need a watchdog script to reboot it if the internet connection is broken

This is a bash script that runs from boot

---------------
#!/bin/sh

ping -4 -c 3 -I ppp0 www.google.com | grep -v '0 packets received' | grep 'packets received' || (ping -4 -c 3 -I ppp0 www.yahoo.com | grep -v '0 packets received' | grep 'packets received' || reboot)

sleep 60

/bin/sh /etc/config/watchdog.sh >> /dev/null 2>&1 &

---------------

it is called from /etc/rc.d/S95done

Comments

Unknown said…
this is my script
must wait before start 2 Mn on ubiquiti picostation 2 HP mode universal repeater and ping router was attached

#!/bin/sh

sleep 180

ping -4 -c 3 -I wlan0-1 192.168.154.254 | grep -v '0 packets received' | grep 'packets received' || (ping -4 -c 3 -I wlan0-1 www.yahoo.com | grep -v '0 packets received' | grep 'packets received' || reboot)

sleep 60

/bin/sh /etc/config/watchdog.sh >> /dev/null 2>&1 &
Unknown said…
the only problem is work at startup but after does nothing and i need working permanently
have you an idea ??
Unknown said…
finaly i do it that for my picostation 2 HP with openwrt Attitude Adjustment 12.09 mode universal repeater. sorry i have no time to translate can you do it for me !

pour que le router reboot automatiquement lorsque la connection est couper(mode universal repeater)
aller dans system a l'onglet startup, en bas ajouter ces lignes de commande dans local startup

#!/bin/sh

ping -4 -c 3 -I wlan0-1 192.168.154.254 | grep -v '0 packets received' | grep 'packets received' || (ping -4 -c 3 -I wlan0-1 www.yahoo.com | grep -v '0 packets received' | grep 'packets received' || reboot)

/bin/sh /etc/config/watchdog.sh >> /dev/null 2>&1 &

se connecter en SSH et aller dans /etc , vous trouvez ici le rc.local qu'il faut rendre executable comme ceci: chmod +x rc.local

pour finir dans system allez a scheduled task (cron) et ajouter ces commandes pour un ping toutes les 2Mn

*/2 * * * * /etc/rc.local

voila ces fini !! @sly2015

Popular posts from this blog

Baileys liquor Chocolate Chip and Cream desert

using t1n1wall, opnsense or pfsense on Google Compute Engine GCE

nginx decode base64 url for use with imgproxy