inteno-netmodes: netmode-handler: code for handlig non inteno uplink

This commit is contained in:
Sukru Senli 2017-06-10 14:41:07 +02:00
parent d87d1f01eb
commit 72d4a7f61f

View file

@ -45,27 +45,34 @@ is_inteno_macaddr()
false
}
switch_mode() {
[ "$repeaterready" == "1" ] || return
defroute=$(ip r | grep default | awk '{print$3}')
ping -c 1 -W 1 $defroute >/dev/null 2>&1
uplinkmac=$(grep "$defroute" /proc/net/arp | awk '{print$4}')
# will be auto-configured if the uplink device is Inteno
is_inteno_macaddr $uplinkmac && return
ubus call leds set '{"state" : "allflash"}'
echo "Switching to 'extender' mode" > /dev/console
uci -q set netmode.setup.curmode='repeater'
uci set netmode.setup.repeaterready=0
uci commit netmode
/etc/init.d/netmode reload
echo "Restarting network services" > /dev/console
ubus call network reload
wifi reload nodat
ubus call router.network reload
ubus call leds set '{"state" : "normal"}'
}
test_ip() {
if [ -n "$(echo $ip | grep -E '^(192\.168|10\.|172\.1[6789]\.|172\.2[0-9]\.|172\.3[01]\.)')" ]; then
# private IP
if [ "$repeaterready" == "1" ]; then
defroute=$(ip r | grep default | awk '{print$3}')
ping -c 1 -W 1 $defroute >/dev/null 2>&1
uplinkmac=$(grep "$defroute" /proc/net/arp | awk '{print$4}')
if ! is_inteno_macaddr $uplinkmac; then
ubus call leds set '{"state" : "allflash"}'
echo "Switching to 'extender' mode" > /dev/console
uci -q set netmode.setup.curmode='repeater'
uci set netmode.setup.repeaterready=0
uci commit netmode
/etc/init.d/netmode reload
echo "Restarting network services" > /dev/console
ubus call network reload
wifi reload nodat
ubus call router.network reload
ubus call leds set '{"state" : "normal"}'
fi
fi
#switch_mode
set_disabled 1
else
# public IP