Skip to content

Instantly share code, notes, and snippets.

@navhaxs
Created February 11, 2015 21:33
Show Gist options
  • Save navhaxs/8029bea3420cdbb11047 to your computer and use it in GitHub Desktop.
Save navhaxs/8029bea3420cdbb11047 to your computer and use it in GitHub Desktop.
openwrt wan auto reconnect hotplug script
# Place me in /etc/hotplug.d/iface/99-keepwanalive
if [ "$ACTION" = "ifdown" -a "$INTERFACE" = "wan" ]; then
COUNTER=0
PASS=0
while [ $PASS -eq 0 ]
do
grep "up" /sys/class/net/eth0/operstate > /dev/null
if [ $? != "up" ]; then
let COUNTER++
logger -t DEBUG "Attempt #${COUNTER} to reconnect wan"
ifup wan
sleep 15 #sec
else
PASS=1
fi
done
fi
@ThomasCr
Copy link

ThomasCr commented Jul 5, 2018

maybe just set once "ifup wan" without while loop and all other things...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment