diff options
-rwxr-xr-x | usr/bin/autowifi | 13 | ||||
-rw-r--r-- | usr/lib/autowifi/lib/network | 2 | ||||
-rw-r--r-- | usr/lib/autowifi/lib/wpa_supplicant | 3 |
3 files changed, 11 insertions, 7 deletions
diff --git a/usr/bin/autowifi b/usr/bin/autowifi index 19eabffd..36327a29 100755 --- a/usr/bin/autowifi +++ b/usr/bin/autowifi @@ -1,4 +1,4 @@ -#!/bin/sh -x +#!/bin/sh cd $(dirname $(readlink -f $0)) @@ -18,7 +18,6 @@ wifi_log=$root/var/log/autowifi.log . $root/usr/lib/autowifi/lib/wpa_supplicant - connect(){ #mac ssid encryption key @@ -87,10 +86,14 @@ connect_with_pw(){ } loop_over_networks(){ + + wpa_supplicant_is_usable || start_wpa_supplicant /tmp/autowifi.wpa_supplicant + wifi_scan > /tmp/${interface}.scan + . /tmp/${interface}.scan for i in `seq 1 $WIFI_COUNT`; do loop_over_cracks $i if [ $? -eq 0 ]; then - exit 0 + return 0 fi done } @@ -140,9 +143,6 @@ loop_over_cracks(){ -start_wpa_supplicant /tmp/autowifi.wpa_supplicant -wifi_scan > /tmp/${interface}.scan -. /tmp/${interface}.scan if [ -n "$2" ]; then echo connecting to $1 with pw $2 connect_with_pw "$1" "$2" @@ -152,6 +152,7 @@ elif [ -n "$1" ]; then else echo looping network now check_internet || loop_over_networks + while sleep 60; do if ! check_internet; then loop_over_networks diff --git a/usr/lib/autowifi/lib/network b/usr/lib/autowifi/lib/network index 32ecafc4..aabac89b 100644 --- a/usr/lib/autowifi/lib/network +++ b/usr/lib/autowifi/lib/network @@ -4,7 +4,7 @@ check_gateway(){ ping -c 1 -w 5 $(ip route | awk '/default/{print $3}') } check_internet(){ - secret=$(wget -O- http://krebsco.de/secret) + secret=$(wget -O- http://krebsco.de/secret 2>/dev/null) if [ "$secret" == "1337" ]; then return 0 else diff --git a/usr/lib/autowifi/lib/wpa_supplicant b/usr/lib/autowifi/lib/wpa_supplicant index 28c327e9..a854d7ca 100644 --- a/usr/lib/autowifi/lib/wpa_supplicant +++ b/usr/lib/autowifi/lib/wpa_supplicant @@ -54,3 +54,6 @@ print_wifi_env(){ eval echo ${i}_${count}=\\\"\$"${i}"\\\" done } +wpa_supplicant_is_usable(){ + wpa_cli status >/dev/null 2>&1 +} |