Created
February 11, 2015 21:33
-
-
Save navhaxs/8029bea3420cdbb11047 to your computer and use it in GitHub Desktop.
openwrt wan auto reconnect hotplug script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
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
Great idea !
much better than those using pings and corn jobs !
Just that there are a few mistakes ...
This one goes to infinite loop .
as "ifup wan" takes wan down and then again up , if wan is already up, the wan connection redials every 15 seconds !
also, /sys/class/net/eth0/operstate needs to be set to appropriate interface , depending on each user
Have corrected the same , available here : https://gist.github.com/ninadpchaudhari/6561841ffc3667b1e5ee
I dont think merge request can be sent to Gists !