Last active
October 16, 2016 17:30
-
-
Save yorch/aeb4aa1f0f190eadce414e5ade4a9fec to your computer and use it in GitHub Desktop.
Revisions
-
yorch revised this gist
Oct 16, 2016 . No changes.There are no files selected for viewing
-
yorch created this gist
Oct 16, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #!/bin/bash HOST=www.google.com while true ; do if ifconfig wlan0 | grep -q "inet addr:" ; then #$printf "WLAN connected, IP: %s\n" $(hostname -I) sleep 60 else echo "Network connection down! Attempting reconnection." # First try ifconfig wlan0 down sleep 3 ifconfig wlan0 up sleep 10 iwconfig wlan0 essid any sleep 10 ping -c 1 -W 10 $HOST &>/dev/null if [ $? -eq 0 ]; then exit else # Second try service networking restart iwconfig wlan0 essid any sleep 10 ping -c 1 -W 10 $HOST &>/dev/null fi sleep 30 fi done