Skip to content

Instantly share code, notes, and snippets.

@SandroMachado
Created May 14, 2017 20:15
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SandroMachado/87e591fc42f368636b251b566485ae46 to your computer and use it in GitHub Desktop.
Save SandroMachado/87e591fc42f368636b251b566485ae46 to your computer and use it in GitHub Desktop.
Script to reboot the raspberry pi if there is no network available
#!/bin/bash
while true
do
wget -q --tries=10 --timeout=20 --spider http://google.com
if [[ $? -eq 0 ]]; then
echo "Online"
else
echo "Offline"
echo raspberry | sudo -S sudo reboot
fi
sleep 300
done
@tblong
Copy link

tblong commented May 25, 2019

Hey @SandroMachado, would you be willing to include an explicit license on this gist so I can give proper credit and make a couple of improvements?

Thanks,
Tyler

@SandroMachado
Copy link
Author

@tblong please feel free to use it.

@tblong
Copy link

tblong commented May 29, 2019

Thanks @SandroMachado for giving me the base for what I needed. The changes needed for my situation were posed here:
https://gist.github.com/tblong/eec5ae1353f9ad9277845efc1760b4bb

@adotagarwal
Copy link

I've updated @SandroMachado and @tblong's scripts to unload and reload the sdio driver, which resolves the network issue without rebooting the entire system: https://gist.github.com/adotagarwal/b6e4bb09e051638271fa3aff910f8eb4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment