diff --git a/bin/wifi_drop.sh b/bin/wifi_drop.sh deleted file mode 100755 index 84b78b4..0000000 --- a/bin/wifi_drop.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -while true ; do - if ifconfig wlan0 | grep -q "inet addr:" ; then - sleep 60 - else - echo "Network connection down! Attempting reconnection." - ifdown --force wlan0 - sleep 10 - ifup --force wlan0 - sleep 10 - fi -done - diff --git a/bin/wifi_wlan_check b/bin/wifi_wlan_check new file mode 100755 index 0000000..c92c4f8 --- /dev/null +++ b/bin/wifi_wlan_check @@ -0,0 +1,134 @@ +#!/bin/bash +################################################################## +# NOTE! THIS IS A MODIFIED VERSION OF THE ORIGINAL PROGRAM +# WRITTEN BY KEVIN REED. TO GET THE ORIGINAL PROGRAM SEE +# THE URL BELOW: +# +# A Project of TNET Services, Inc +# +# Title: WiFi_Check +# Author: Kevin Reed (Dweeber) +# dweeber.dweebs@gmail.com +# Project: Raspberry Pi Stuff +# +# Copyright: Copyright (c) 2012 Kevin Reed +# https://github.com/dweeber/WiFi_Check +# +# Purpose: +# +# Script checks to see if WiFi has a network IP and if not +# restart WiFi +# +# Uses a lock file which prevents the script from running more +# than one at a time. If lockfile is old, it removes it +# +# Instructions: +# +# o Install where you want to run it from like /usr/local/bin +# o chmod 0755 /usr/local/bin/WiFi_Check +# o Add to crontab +# +# Run Every 5 mins - Seems like ever min is over kill unless +# this is a very common problem. If once a min change */5 to * +# once every 2 mins */5 to */2 ... +# +# */5 * * * * /usr/local/bin/WiFi_Check +# +################################################################## +# Settings +# Which Interface do you want to check/fix +wlan=wlan0 +# Which address do you want to ping to see if you can connect +pingip1=192.168.1.1 +pingip2=192.168.0.1 +# Where and what you want to call the Lockfile +#lockfile="/var/run/WiFi_Check_${wlan}.pid" +lockfile="/var/run/WiFi_Check.pid" +################################################################## +echo +echo "Starting WiFi check for $wlan" +date +echo + +# Check to see if there is a lock file +if [ -e $lockfile ]; then + # A lockfile exists... Lets check to see if it is still valid + pid=`cat $lockfile` + if kill -0 &>1 > /dev/null $pid; then + # Still Valid... lets let it be... + #echo "Process still running, Lockfile valid" + exit 1 + else + # Old Lockfile, Remove it + #echo "Old lockfile, Removing Lockfile" + rm $lockfile + fi +fi +# If we get here, set a lock file using our current PID# +#echo "Setting Lockfile" +echo $$ > $lockfile + +# We can perform check +echo "Performing Network check for $wlan" +if ifconfig $wlan | grep -q "inet addr:" ; then + echo "Network $wlan is Okay" +else + echo "Network $wlan are down!" + echo " Try reconnecting $wlan ." + ifdown $wlan + sleep 5 + ifup --force $wlan + ifconfig $wlan | grep "inet addr" + + if ifconfig $wlan | grep -q "inet addr:" ; then + echo "Network $wlan is Okay" + else + echo "Try reconnecting $wlan:1 ." + ifdown $wlan:1 + sleep 5 + ifup --force $wlan:1 + ifconfig $wlan | grep "inet addr" + + if ifconfig $wlan | grep -q "inet addr:" ; then + echo "Network $wlan is Okay" + else + echo "Try reconnecting $wlan:2." + ifdown $wlan:2 + sleep 5 + ifup --force $wlan:2 + ifconfig $wlan | grep "inet addr" + fi + fi +fi + +#OLD# # We can perform check +#OLD# #echo "Performing Network check for $wlan1" +#OLD# /bin/ping -c 2 -I $wlan1 $pingip1 > /dev/null 2> /dev/null +#OLD# if [ $? -ge 1 ] ; then +#OLD# echo "Performing Network check for $wlan2" +#OLD# /bin/ping -c 2 -I $wlan2 $pingip2 > /dev/null 2> /dev/null +#OLD# if [ $? -ge 1 ] ; then +#OLD# echo "Network connection down! Attempting reconnection." +#OLD# /sbin/ifdown $wlan1 +#OLD# sleep 5 +#OLD# /sbin/ifup --force $wlan1 +#OLD# else +#OLD# echo "Network $wlan2 is Okay" +#OLD# fi +#OLD# else +#OLD# echo "Network $wlan1 is Okay" +#OLD# fi + +echo +echo "Current Setting:" +ifconfig $wlan | grep "inet addr:" +echo + + +# Check is complete, Remove Lock file and exit +#echo "process is complete, removing lockfile" +rm $lockfile +exit 0 + +################################################################## +# End of Script diff --git a/install.sh b/install.sh index d39e54a..3dc072a 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,5 @@ #!/bin/bash ln -s `pwd`/bin/* ~/bin/. -ln -s ~/bin/notify_boot.sh ~/. diff --git a/tpl/etc/network/interfaces b/tpl/etc/network/interfaces new file mode 100644 index 0000000..e89cb08 --- /dev/null +++ b/tpl/etc/network/interfaces @@ -0,0 +1,31 @@ +auto lo +iface lo inet loopback + +#iface eth0 inet dhcp +iface eth0 inet static +address 192.168.1.30 +netmask 255.255.255.0 +broadcast 192.168.1.255 +gateway 192.168.1.1 + +auto wlan0 +allow-hotplug wlan0 +iface wlan0 inet manual +wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf +iface default inet dhcp + +auto wlan0:1 +iface wlan0:1 inet manual +iface default inet static + address 192.168.1.33 + netmask 255.255.255.0 + broadcast 192.168.1.255 + gateway 192.168.1.1 + +auto wlan0:2 +iface wlan0:2 inet manual +iface default inet static + address 192.168.0.33 + netmask 255.255.255.0 + broadcast 192.168.0.255 + gateway 192.168.0.1