summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorlassulus <lassulus@googlemail.com>2013-06-10 21:24:04 +0200
committerlassulus <lassulus@googlemail.com>2013-06-10 21:24:04 +0200
commitaf16433b46f5c60fc5153141d8d5f336c076160c (patch)
tree131dac2919ad75337df6bc9f22c863c75a8e7c2e /usr
parent2bcd40a23f5f326b7f332b22fb8633bc5f88003c (diff)
parent2ffb00bd97e0e8b47dc1def6f47ebc5295107360 (diff)
Merge branch 'master' of github.com:krebscode/autowifi
Diffstat (limited to 'usr')
-rwxr-xr-xusr/bin/autowifi13
-rw-r--r--usr/lib/autowifi/lib/network2
-rw-r--r--usr/lib/autowifi/lib/wpa_supplicant3
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
+}