The Raspberry Pi is an awesome little platform with uses from education to home automation. If you rely upon it to host a process or application wirelessly, you will sooner or later find it unavailable on the network. If you search the Internet you’ll find several “solutions”, some work a little, some not at all.
I’ve developed a script and a process to keep it running which will shut off power management for the wireless adapter and try to ping the gateway on interval. If the ping fails for a certain number of times, it will reset the adapter. If it continues to fail it can (optionally) reboot the Pi.
Install with the following command:
curl -L wifi.brewpiremix.com | sudo bash
If you wish to enable the reboot function, edit these lines:
# Reboot on failure
REBOOT=false
Add change to:
# Reboot on failure
REBOOT=true
After that change, reboot, or restart the daemon with the following command:
sudo systemctl restart wificheck
The git repository may be found here.