diff --git a/easy-wifi-switch b/easy-wifi-switch new file mode 100755 index 0000000..09b5cb5 --- /dev/null +++ b/easy-wifi-switch @@ -0,0 +1,26 @@ +#!/bin/sh + +# check config exist +wificfg="/mnt/sda1/trophy/wifi.cfg" + +if [ -f "$wificfg" ] +then + # load wifi config + source "$wificfg" + + echo "Updating wifi settings:" + echo " - SSID: $ssid" + echo " - Key: $key" + echo " - Encryption: $encryption" + echo " " + + # apply to OpenWrt UCI + # see: http://wiki.openwrt.org/doc/uci/wireless + /sbin/uci "set" "wireless.@wifi-iface[0].ssid=$ssid" + /sbin/uci "set" "wireless.@wifi-iface[0].key=$key" + /sbin/uci "set" "wireless.@wifi-iface[0].encryption=$encryption" + /sbin/uci commit wireless + wifi +else + echo "$wificfg was not found. Leaving wifi alone." +fi diff --git a/wifi.cfg b/wifi.cfg new file mode 100755 index 0000000..aaad688 --- /dev/null +++ b/wifi.cfg @@ -0,0 +1,20 @@ +# Enter your WiFi network information here. + +# Make sure each value comes between the double quotes, and that +# there are no spaces on either side of the equals sign. + +# Your WiFi network name. This is case-sensitive. +ssid="My Network Name" + +# Your WiFi network password. This is case-sensitive. +key="password123" + +# Your WiFi network encryption method. Assuming you have this set +# up at home, it is very unlikely you'll have to change this. +# Possible options are: +# psk - wpa personal +# psk2 - wpa2 personal +# wpa - wpa enterprise +# wpa2 - wpa2 enterprise +# none - unencrypted network +encryption="psk2" \ No newline at end of file