Skip to content

Instantly share code, notes, and snippets.

@D4rk4
Forked from navhaxs/99-keepwanalive
Last active May 22, 2019 21:15
Show Gist options
  • Save D4rk4/3578332cd5427a08f7cf40914a216060 to your computer and use it in GitHub Desktop.
Save D4rk4/3578332cd5427a08f7cf40914a216060 to your computer and use it in GitHub Desktop.
openwrt wan auto reconnect hotplug script
#!/bin/bash
# Place me in /etc/hotplug.d/iface/99-keepwanalive
IFNAME='wlan0'
if [ "$ACTION" = "ifdown" -a "$INTERFACE" = "$IFNAME" ]; then
COUNTER=0
PASS=0
while [ $PASS -eq 0 ]
do
grep "up" /sys/class/net/${IFNAME}/operstate > /dev/null
if [ $? != "up" ]; then
let COUNTER++
logger -t DEBUG "Attempt #${COUNTER} to reconnect ${IFNAME}"
ifup ${IFNAME}
sleep 15 #sec
else
PASS=1
fi
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment