We have a remote pfsense router on a remote location with no employees. On this location we have several critical servers. We used to have a pretty stable internet conection, with our ISP being Comcast (up to 100 mbps download speeds).
Since a couple of months ago, we have been experiencing some problems, first, our UPS battery died so the whole system (modem, router and servers were offline), but after this we have had a couple of offline incidents, which we belive (but are not sure) may be linked to a hicup on the modem, which makes the router go offline and cannot recover.
On an effort to resolve this automatically so that no employee has to go to this remote location we found this script online, which will ping google (to see if theres an internet connection), and if the conection is lost the router will automatically reboot.
All the credit goes to the poster.