#!/bin/bash
#
CMD=$(basename $0)

[ $# != 1 ] && {
	echo "usage: $0 timeserver" >&2
	exit 1
}

server=$1

logger -t ALIX "service $server is up, try to sync time"
if out=$(rdate $server 2>&1)
then
	logger -t ALIX 'time synced'
	sh /etc/init.d/ntp restart
else
	stat=$?
	logger -t ALIX "error $stat on 'rdate $server': $out"
	exit $stat
fi
exit 0
