#!/bin/sh
# ................................................... Openwrt ............
DATE=`date +%Y-%m-%d-%H:%M:%S`


for ip in  $(cat /usr/local/script/check_ip.txt) 
do
	PING=`ping -c 1 ${ip} |grep -v grep|grep '64 bytes' |wc -l`
	echo $PING
	if [ ${PING} -ne 0 ];then
		exit 0
	fi
done

echo $DATE network restart >>/usr/local/script/reconnect.log
/sbin/ifup wan

sleep 60

for ip in  $(cat /usr/local/script/check_ip.txt)
do
        PING=`ping -c 1 ${ip} |grep -v grep|grep '64 bytes' |wc -l`
        echo $PING
        if [ ${PING} -ne 0 ];then
                exit 0
        fi
done

echo $DATE network reboot >>/var/log/my_watchdog.log
reboot
