#!/bin/sh ROOT_UID=0 # Only users with $UID 0 have root privileges. E_NOTROOT=67 # Non-root exit error. # Run as root, of course. if [ "$UID" -ne "$ROOT_UID" ]; then echo "Must be root to run this script." exit $E_NOTROOT fi test_ip=192.168.0.100 ping_loss=`ping -c 1 -W 3 $test_ip | grep packet | awk '{print $6}'` if [ "$ping_loss" == "100%" ]; then echo Secure Router is no longer using IP $secure_router echo Need to restart ISP and the Secure Router # /sbin/shutdown -rf now exit 0 fi test_ip=192.168.0.101 ping_loss=`ping -c 1 -W 3 $test_ip | grep packet | awk '{print $6}'` if [ "$ping_loss" == "0%" ]; then echo Secure Router is using wrong IP $secure_router echo Need to restart ISP and the Secure Router # /sbin/shutdown -rf now exit 0 fi test_ip=www.google.com ping -c 1 -W 3 $test_ip if [ $? -ne 0 ]; then echo $test_ip is not reachable echo Need to restart ISP # /sbin/shutdown -rf now exit 0 fi exit 0