#!/bin/sh

PATH=/sbin:/bin

test -f /usr/sbin/ntpdate || exit 0

if test -f /etc/default/ntpdate ; then
. /etc/default/ntpdate
else
NTPSERVERS="pool.ntp.org"
fi

test -n "$NTPSERVERS" || exit 0

. /lib/lsb/init-functions

case "$1" in
start|force-reload)
  log_begin_msg "Synchronizing clock to $NTPSERVERS..."
  /usr/sbin/ntpdate -b -s $NTPOPTIONS $NTPSERVERS
  log_end_msg $?
  ;;
restart|reload)
  # Drop -b to slew clock rather than step it if called after system is up
  log_begin_msg "Synchronizing clock to $NTPSERVERS..."
  /usr/sbin/ntpdate -s $NTPOPTIONS $NTPSERVERS
  log_end_msg $?
  ;;
stop)
  ;;
*)
  log_success_msg "Usage: /etc/init.d/ntpdate {start|stop|restart|reload|force-reload}"
  exit 1
esac

exit 0
