
#!/bin/sh
# File	: chk_gw_and_restart_nw.sh
# By	: MaartenDeBoer.nl, 170704
# Subject	: Script to check GateWay otherwise restart networking
#(0.2),170705	: Added |tee -a ${LOG}
PGM="`basename $0|cut -d\.`"
VER="0.2"
LOG="${HOME}/log/${PGM}.log"

GW="192.168.178.1" 

ping -W 1 -c 1 ${GW}
EC=${?}

echo ${EC}
if [ ${EC} -ne 0 ]; then
  echo "`date` ${PGM}: No GW ping. Restarting networking ..."|tee -a ${LOG}
  sudo /etc/init.d/networking restart
fi

exit 0

