Quicker and simpler wifi check

So I needed a way on bootup to see if I was connected to the home wifi or not.

 

Figured when i’m away from home I wont be able to “see” the home network so why not just test to see if its in range on bootup, and if its not assume we’re out enjoying the great outdoors and disable the home network.  This means I can have the router enable the Access Point rather than work as a bridge when i’m home

Create a new file: nano /usb/sbin/wificheck.sh

put this in the file

uci set wireless.@wifi-iface[0].disabled=0
uci commit wireless
wifi

sleep 5
if iw dev wlan0 scan| grep -qi NETWORKNAMEHERE; then
logger “Home network found (NETWORKNAME), leaving network online”
else
logger “Away from Home – Disabling home wifi”
uci set wireless.@wifi-iface[0].disabled=1
uci commit wireless;
wifi
fi

save the file

then run chmod +x /usb/sbin/wificheck.sh

nano /etc/rc.local

add the line

/usr/sbin/wificheck.sh

save the file

reboot

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s