summaryrefslogtreecommitdiffstats
path: root/usr/bin/autowifi
blob: 8815fb7578ad7d0a5d0d463985829fbf5d52bf31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh -x
wifi=wlan0
iface=@wifi-iface[0]
radio=$(uci get wireless.${iface}.device)
connect_wifi(){
    # channel ssid encryption key
    uci set wireless.${iface}.mode=sta

    ifconfig $wifi up
    uci set wireless.${radio}.channel=$1
    uci set "wireless.${iface}.ssid=$2"
    if [ $3 == "none" ] ; then
        uci set wireless.${iface}.encryption=none
        uci -q delete wireless.${iface}.key
    else
        uci set "wireless.${iface}.key=$4"
        uci set wireless.${iface}.encryption=$3
    fi 
    uci commit wireless
    wifi up
}

connect_wifi "$@"