summaryrefslogtreecommitdiffstats
path: root/usr/bin/autowifi
diff options
context:
space:
mode:
Diffstat (limited to 'usr/bin/autowifi')
-rwxr-xr-xusr/bin/autowifi34
1 files changed, 34 insertions, 0 deletions
diff --git a/usr/bin/autowifi b/usr/bin/autowifi
index 8815fb75..bbd6258f 100755
--- a/usr/bin/autowifi
+++ b/usr/bin/autowifi
@@ -20,4 +20,38 @@ connect_wifi(){
wifi up
}
+iwlist_scan(){
+ count=0
+
+ iwlist scan ${1:-} 2>/dev/null | ( while read line;
+ do
+ case "$line" in
+ *"Cell "*)
+ #echo
+ : $((count+=1))
+ echo MAC_${count}="${line#*Address: }"
+ ;;
+ *Channel:*)
+ echo CHANNEL_${count}="${line#*:}"
+ ;;
+ *Quality=*)
+ echo QUALITY_${count}="`printf '%s' ${line#*Quality=} | cut -d/ -f 1`"
+ ;;
+ *"Encryption key:"*)
+ echo ENCRYPTION_${count}="${line#*key:}"
+ ;;
+ *ESSID:*)
+ echo ESSID_${count}="${line#*ESSID:}"
+ ;;
+ *"IE: IEEE 802.11i/WPA2"*)
+ echo WPA2_${count}=1
+ ;;
+ *"IE: WPA Version 1"*)
+ echo WPA_${count}=1
+ ;;
+ *);;
+ esac
+ done; echo WIFI_COUNT=$count)
+}
+iwlist_scan > /tmp/${wifi}.scan
connect_wifi "$@"