Last active
August 23, 2016 22:15
-
-
Save jaka/ec5372ef62f1ff340e18f766f49b9fd0 to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
setif() { | |
iw dev | grep -q "Interface $1" | |
local status=$? | |
[ "$2" = "down" ] && [ "$status" = "0" ] && { | |
[ -d "/sys/class/net/$1/master" ] && ip link set dev "$1" nomaster | |
iw dev "$1" del | |
return | |
} | |
[ "$2" = "up" ] && [ "$status" = "1" ] && { | |
wifi | |
action= | |
return | |
} | |
} | |
while true; do | |
sleep 30 | |
action= | |
[ "`ip ro sh ta 92 | wc -l`" = "1" ] && action=up || action=down | |
for _iface in `uci -q show wireless | grep "wifi-iface$"`; do | |
[ "`uci -q get ${_iface%=*}.needuplink`" = "1" ] && setif "`uci -q get ${_iface%=*}.ifname`" $action | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment