Skip to content

Instantly share code, notes, and snippets.

@Leo-PL
Created April 22, 2020 22:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Leo-PL/9e12e33999eb97d8c1b8043307c3c216 to your computer and use it in GitHub Desktop.
Save Leo-PL/9e12e33999eb97d8c1b8043307c3c216 to your computer and use it in GitHub Desktop.
Simple WAN watchdog for OpenWrt with LTE modem. Add to crontab.
#!/bin/sh
USB_GPIO=21
DELAY=1
gpio_value="/sys/class/gpio/gpio${USB_GPIO}/value"
echo 0 > ${gpio_value}
sleep ${DELAY}
echo 1 > ${gpio_value}
#!/bin/sh
HOSTS="8.8.8.8 8.8.4.4 1.1.1.1 1.0.0.1"
PING_WAIT=2
SLEEP_TIME=5
NETWORK="wan"
tries=0
while [[ $tries -lt 10 ]]
do
for host in ${HOSTS}
do
if /bin/ping -c 1 -W ${PING_WAIT} ${host} >/dev/null
then
exit 0
fi
done
tries=$((tries+1))
done
logger Ping watchdog triggered, restarting modem
ifdown ${NETWORK}
sleep ${SLEEP_TIME}
./reset_modem_hard.sh
sleep ${SLEEP_TIME}
ifup ${NETWORK}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment