Skip to content

Instantly share code, notes, and snippets.

@myrtleTree33
Created October 23, 2014 15:05
Show Gist options
  • Save myrtleTree33/4edbc88b82c31a48d597 to your computer and use it in GitHub Desktop.
Save myrtleTree33/4edbc88b82c31a48d597 to your computer and use it in GitHub Desktop.
Auto reconnect a Raspberry Pi by pinging google. Does ifdown and ifup is connection is down.
#!/bin/bash
HOST=google.com
while :
do
if ping -c 1 $HOST &> /dev/null
then
echo 1
else
echo 0
# Restart connection if unavailable
sudo ifdown wlan0 && sudo ifup wlan0
fi
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment