#!/bin/sh
#
# Minimal init script for htpdate

PIDFILE="/var/run/htpdate.pid"
SERVERS="www.google.com www.yahoo.com www.linux.org www.freebsd.org"

# See how we were called.
case "$1" in
  start)
	echo -n "Starting htpdate: "
	# Set the time first before daemonizing, because the time offset
	# might take too long for smooth time adjustment
	/usr/bin/htpdate -s $SERVERS
	/usr/bin/htpdate -D -i $PIDFILE $SERVERS
	echo
	;;
  stop)
	echo -n "Shutting down htpdate: "
	if [ -f $PIDFILE ]
	then
		kill `cat $PIDFILE`
	else
		echo "$PIDFILE not found"
	fi
	echo
	rm -f /var/run/htpdate.pid
	;;
  restart)
	$0 stop
	$0 start
	;;
  *)
	echo "Usage: $0 {start|stop|restart}"
	exit 1
esac

exit 0
