openwrt wan auto reconnect hotplug script
#!/bin/sh | |
# Place me in /etc/hotplug.d/iface/99-keepwanalive | |
if [ "$ACTION" = "ifdown" -a "$INTERFACE" = "wan6" ]; then | |
echo "Entering IF statement" >> /tmp/mylog | |
COUNTER="0" | |
FLAG="0" | |
while [ "$FLAG" = 0 ] | |
do | |
echo "Entered While" >> /tmp/mylog | |
sleep 1 | |
grep "unknown" /sys/class/net/pppoe-wan6/operstate | |
RESULT="$?" | |
echo "Result : $RESULT" >> /tmp/mylog | |
if [ "$RESULT" != 0 ]; then | |
let COUNTER++ | |
echo "Log from /etc/hotplug.d/iface/99-keepwanalive -- pppoe-wan6 Fou$ | |
logger -t DEBUG "Log from /etc/hotplug.d/iface/99-keepwanalive -- pppoe$ | |
logger -t DEBUG "Attempt #${COUNTER} to reconnect pppoe-wan6" | |
echo "Attempt #${COUNTER} to reconnect pppoe-wan6" >> /tmp/mylog | |
ifup wan6 | |
sleep 10 #sec | |
else | |
FLAG=1 | |
fi | |
done | |
fi |
This comment has been minimized.
This comment has been minimized.
Thank you! |
This comment has been minimized.
This comment has been minimized.
operstate is on my interface always unknown - also when it is connected. |
This comment has been minimized.
This comment has been minimized.
I'm new guy for openwrt and github too. I read your script is awesome! |
This comment has been minimized.
This comment has been minimized.
Here is my command code for l2tp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
98-mylog is just for debugging purposes
tail -f /tmp/mylog would keep you updated
For interface names ,
ls /sys/class/net ...
In my case in 14.07,
Interface wan6 was for pppoe