#!/bin/bash
n=1
while [ $n -eq 1 ]
do
if ping -q -c 1 -W 1 google.com >/dev/null; then
echo "Yipee... Network is up"
sudo /etc/init.d/ntp stop
sudo ntpd -q -g
sudo /etc/init.d/ntp start
n = 0
else
echo "The network is down"
sleep 10
fi
done