-
-
Save thomasgroch/a6d9336e397732bbc647e90391de2591 to your computer and use it in GitHub Desktop.
Raspberry Pi WiFi reconnection script
This file contains 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 characters
#!/bin/bash | |
while true | |
do | |
# ping -c 1 192.168.0.1 | |
# #test $? -eq 1 && sudo /etc/ifplugd/ifplugd.action wlan0 up | |
# test $? -ne 0 && sudo /etc/ifplugd/action.d/action_wpa wlan0 up | |
ping -c2 192.168.0.1 > /dev/null | |
if [ $? != 0 ] | |
then | |
echo "No network connection, restarting wlan0" | |
/sbin/ifdown 'wlan0' | |
sleep 5 | |
/sbin/ifup --force 'wlan0' | |
fi | |
sleep 7 | |
done | |
This file contains 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 characters
sudo chmod 775 /usr/local/bin/checkwifi.sh | |
crontab -e | |
# every 5 minutes | |
*/5 * * * * /usr/bin/sudo -H /usr/local/bin/checkwifi.sh >> /dev/null 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment