I’ve got a little script that will reset the network if it loses connection to my router, maybe that is all you need? If the device itself locks up this script won’t be of any use though (that would be damaged hardware though i presume and be easier fixed by changing the pi)
if ! [[ -a /tmp/pingfailed ]] && ! ping 192.168.2.1 -c5 >/dev/null
echo "Restarting dhcpcd; could not reach 192.168.2.1"
systemctl restart dhcpcd
To “install” the script do the following:
Now paste the above script and save and exit (ctrl-o and ctrl-x)
The script needs to be executed regularly for that we use cron:
sudo crontab -e
This should open an editor, post the following line at the bottom:
* * * * * /bin/bash /home/pi/pingfail.sh
Save and exit.
Now every minute the script is started.
It will wait 30 seconds (to give the network connection some time to come up after boot).
It will check if it can reach the ip address (set this to your router ip address).
If it can’t reach the ip it will restart dhcpcd. This is what needs to be done on Debian stretch and should therefore also work in piaware 3.6.3 sd-card image.
If you really want to just make it a
reboot -f instead but be aware the pi will reboot 30 seconds after startup if it can’t reach the specified ip.
Now if you only restart dhcpcd it will only do that every 300 seconds. For that it just uses a file to mark it did a restart and removes the file after 300 seconds.
The script is being launched every minute and the following launch will check for the existence of the file and if it exists not do anything.
I’m not quite sure what exactly your problem is do you have logs or can the describe the issue better?
(I made this script because my wifi router sometimes get’s temperamental and won’t allow devices to authenticate. The pi then sets a rather long timeout before trying again and that is annoying.)