#!/bin/sh

start() {
  if ps ax | grep -q ntpd ; then
    echo "NTP daemon already running.  NTP start aborted."
    exit 0
  fi
  if [ -x /usr/bin/ntpd -a -f /etc/ntp.conf ] ; then
    ntpdate -s `sed -n '/^server/p' /etc/ntp.conf | cut -d' ' -f2`
    ntpd -c /etc/ntp.conf
  fi
}

stop() {
  killall ntpd
}

case "$1" in
start)
  start
  ;;
stop)
  stop
  ;;
restart)
  stop
  sleep 3
  start
  ;;
*)
  echo $"Usage: $0 {start|stop|restart}"
  exit 1
  ;;
esac
exit 0
