Auto reboot OpenWrt

Hello friends, who knows, please help set up the script to restart OpenWRT when it does not see Google DNS.

3 Likes

Something like that

#!/bin/sh

# Common vars
CHECK_IP="8.8.8.8"
PING_MAX_RETRIES=4

fails_counter=0

# Main loop
while [ true ]; do
	if [ $fails_counter -eq $PING_MAX_RETRIES ]; then
		reboot
	fi
	fails_counter=0
	sleep 60
	while [ $fails_counter -lt $PING_MAX_RETRIES ]; do
		if /bin/ping -c 1 $CHECK_IP >/dev/null 2>&1
		then
			break
		fi
		fails_counter=$((fails_counter+1))
	done
done
1 Like

Thank you very much

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.