Last active
April 22, 2018 14:04
-
-
Save nicholasadamou/3b846f1474f90031cf1967f94d38a0b1 to your computer and use it in GitHub Desktop.
Restart the network-manager if no network connection is found on the Raspberry Pi 2/3.
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 characters
#!/bin/bash | |
#see: http://alexba.in/blog/2015/01/14/automatically-reconnecting-wifi-on-a-raspberrypi/ | |
# The IP for the server you wish to ping (8.8.8.8 is a public Google DNS server) | |
SERVER=8.8.8.8 | |
#specify wlan interface | |
INTERFACE=wlan0 | |
# Only send two pings, sending output to /dev/null | |
ping -I ${INTERFACE} -c2 ${SERVER} > /dev/null | |
# If the return code from ping ($?) is not 0 (meaning there was an error) | |
if [ $? != 0 ]; | |
then | |
# Restart the Network Manager | |
sudo service network-manager restart | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment