mirror of
git://projects.qi-hardware.com/openwrt-packages.git
synced 2024-11-25 22:20:17 +02:00
67 lines
1.4 KiB
Bash
Executable File
67 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
if [ "$1" == "set" ] && [ "$#" == "4" ]; then
|
|
uci delete network.wwan
|
|
uci set network.wwan=interface
|
|
uci set network.wwan.proto=dhcp
|
|
|
|
uci delete wireless.@wifi-iface[0]
|
|
uci set wireless.@wifi-device[0].disabled=0
|
|
uci add wireless wifi-iface > /dev/null 2>&1
|
|
uci set wireless.@wifi-iface[0].device='radio0'
|
|
uci set wireless.@wifi-iface[0].network='wwan'
|
|
uci set wireless.@wifi-iface[0].mode='sta'
|
|
|
|
#none for an open network,
|
|
#wep for WEP,
|
|
#psk for WPA-PSK, or
|
|
#psk2
|
|
|
|
uci set wireless.@wifi-iface[0].ssid=$2
|
|
uci set wireless.@wifi-iface[0].key=$3
|
|
uci set wireless.@wifi-iface[0].encryption=$4
|
|
|
|
uci commit network
|
|
uci commit wireless
|
|
ifup wwan
|
|
sleep 2
|
|
|
|
exit 0
|
|
fi
|
|
|
|
|
|
if [ "$1" == "get" ]; then
|
|
ifconfig -a | grep wlan0 > /dev/null 2>&1
|
|
|
|
if [ "$?" != "0" ]; then
|
|
iw phy phy0 interface add wlan0 type station
|
|
ifconfig wlan0 up
|
|
sleep 1
|
|
fi
|
|
|
|
/opt/m1-wireless.lua
|
|
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$1" == "status" ]; then
|
|
sleep 1
|
|
IP=`ifconfig wlan0 2>/dev/null | grep "inet addr" | \
|
|
sed -e 's/^ *//g' | cut -d":" -f2 | cut -d" " -f1`
|
|
if [ "$?" != 0 ] || [ "${IP}" == "" ]; then
|
|
echo "Disconnected"
|
|
echo "0.0.0.0"
|
|
exit 1
|
|
fi
|
|
|
|
ESSID=`iwconfig wlan0 2>/dev/null | grep ESSID | cut -d":" -f 2 | sed -e 's/\"//g'`
|
|
|
|
echo "${ESSID}"
|
|
echo "${IP}"
|
|
|
|
exit 0
|
|
fi
|
|
|
|
echo "Usage: $0 [get/set/status] PARAMS..."
|
|
exit 1
|