Jan 28, 2014

Auto reactivate wifi on raspberry pi

One of my raspberry pi was having trouble auto reconnectiong to home wifi when wifi router starts. I made a simple script to re-activate wifi.                                                                        
#!/bin/sh
stat=`/sbin/ifconfig wlan0 | /bin/grep -q "inet addr:"`

if [ $? -ne 0 ]
then
        echo "Wifi restarting..."
        /sbin/ifup --force wlan0
fi
It will have to be registered on crontab of root:
* * * * * wifi.sh

It will check the wifi every minute and reactive when the wifi is down.

You can also test it by manually deactivating it: sudo ifdown wlan0.
If it comes up by itself after one minute later, the setting is working.

No comments: