flm01/mote/v2/openwrt/package/button/src/net_toggle

48 lines
832 B
Bash
Executable File

#!/bin/sh
# Copyright (c) 2010 flukso.net
to_wifi ()
{
uci set firewall.@zone[1].input=REJECT
uci set network.wan.ifname=ath0
uci set network.lan.ifname=eth0
uci set wireless.wifi0.disabled=0
uci set wireless.@wifi-iface[0].network=wan
uci set wireless.@wifi-iface[0].mode=sta
uci commit
logger 'toggled to wifi mode'
}
to_eth ()
{
uci set firewall.@zone[1].input=ACCEPT
uci set network.wan.ifname=eth0
uci set network.lan.ifname=ath0
uci set wireless.wifi0.disabled=1
uci set wireless.@wifi-iface[0].network=lan
uci set wireless.@wifi-iface[0].mode=ap
uci commit
logger 'toggled to eth mode'
}
MODE=$(uci get network.wan.ifname)
if [ $MODE == eth0 ]
then
to_wifi
elif [ $MODE == ath0 ]
then
to_eth
fi
gpioctl dirout 4
for i in 1 2 3 4 5
do
gpioctl clear 4
gpioctl set 4
done
/etc/init.d/network restart