diff options
author | makefu <github@syntax-fehler.de> | 2013-06-10 20:30:41 +0200 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2013-06-10 20:30:41 +0200 |
commit | 20b1c6c2158fb12b6422c170d4a2a0f402864308 (patch) | |
tree | d31541c882bdb63624466877d3edc2db641c55a1 /usr/bin/autowifi_old | |
parent | 910446fb3b32314f9a1efbab5d948d76021a8c7c (diff) |
finish refactoring new wpa_supplicant autowifi
Diffstat (limited to 'usr/bin/autowifi_old')
-rwxr-xr-x | usr/bin/autowifi_old | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/usr/bin/autowifi_old b/usr/bin/autowifi_old new file mode 100755 index 00000000..55eaefcd --- /dev/null +++ b/usr/bin/autowifi_old @@ -0,0 +1,65 @@ +#!/bin/sh -x +# States (LED): +# Blinking - running wifi plugins +# Turned off - connected to wifi +# Turned on - waiting for next scan round + +wifi=wlan0 +iface=@wifi-iface[0] +radio=$(uci get wireless.${iface}.device) + +# for connect_wifi +. /usr/lib/autowifi/lib/openwrt + +# for iwlist_scan +. /usr/lib/autowifi/lib/iwlist + +# for check_internet and check_gateway +. /usr/lib/autowifi/lib/network + +crack_wifi(){ + #SSID MAC CHANNEL ENCRYPTION WPA WPA2 + all_led timer + if [ "$4" == off ];then + encr=open + elif [ "$6" -eq 1 ]; then + encr=psk2 + elif [ "$5" -eq 1 ]; then + encr=psk + elif [ "$4" == on ]; then + encr=wep + fi + for hack in $(find /usr/lib/autowifi/plugins -type f); do + key=$($hack "$@"); + ret=$? + if [ $ret -eq 0 ];then + connect_wifi "$3" "$1" $encr "$key" + sleep 20 + if check_gateway; then + (cat /etc/autowifi/wifi_keys | grep -v "$1|$2|" ; echo "$1|$2|$key" ) | sort | uniq > /etc/autowifi/wifi_keys2 + mv /etc/autowifi/wifi_keys2 /etc/autowifi/wifi_keys + echo "yay gateway" + check_internet && all_led none && return 0 + fi + fi + done + return 1 +} +loop_over_networks(){ + . /tmp/${wifi}.scan + for i in `seq 1 $WIFI_COUNT`; do + eval grep -q \${MAC_${i}} /etc/autowifi/blacklist && continue + eval crack_wifi \"\${ESSID_${i}}\" \"\${MAC_${i}}\" \${CHANNEL_${i}} \${ENCRYPTION_${i}} \${WPA_${i}} \${WPA2_${i}} && break + done +} + +iwlist_scan > /tmp/${wifi}.scan +loop_over_networks + +while sleep 60; do + if ! check_internet; then + all_led on + iwlist_scan > /tmp/${wifi}.scan + loop_over_networks + fi +done |