#!/bin/sh
# /etc/init.d/ntp
#
# Written by Russell Cumber<Russell.Cumber@daktronics.com>

set -e

DAEMON=/usr/local/sbin/ntp
DAEMONOPTS="-dakconfig"
NAME=ntp
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin

test -x $DAEMON || exit 0

case "$1" in
  start)
    echo -n "Running app: $NAME  "
    [ -d /var/run/ntp ] || mkdir -p /var/run/ntp
    start-stop-daemon --start --background -m --pidfile /var/run/ntp/ntp.pid --exec $DAEMON -- $DAEMONOPTS
    echo "."
    ;;
  stop)
    echo -n "Stopping app: $NAME  "
    #echo -n " - Force Kill  "
    #killall -9 ntp
    #start-stop-daemon --stop --pidfile /var/run/ntp/ntp.pid --oknodo --exec $DAEMON
    rm -f /var/run/ntp/ntp.pid
    echo "."
    ;;
  restart)
    echo -n "Restarting app: $NAME  "
   # start-stop-daemon --stop --pidfile /var/run/ntp/ntp.pid --oknodo --exec $DAEMON
    rm -f /var/run/ntp/ntp.pid
    start-stop-daemon --start --background -m --pidfile /var/run/ntp/ntp.pid --exec $DAEMON -- $DAEMONOPTS
    echo "."
    ;;
 # reload|force-reload)
  #  echo "Reloading $NAME configuration files  "
 #   start-stop-daemon --stop --pidfile /var/run/ntp/ntp.pid --signal 1 --exec $DAEMON
 #   echo "."
 #   ;;
  *)
    echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
    exit 1
    ;;
esac

exit 0
