#!/bin/sh
#=================================================================
# Begin chronyid
#
# chkconfig:	2345 85 25
# Description : Deamon handle NTP protocol and keep clock in sync
#
#=================================================================

### BEGIN INIT INFO
# Provides:            chrony
# Required-Start:      network
# Should-Start:        ripd
# Default-Start:       2 3 4 5
# Default-Stop:        0 1 6
# Short-Description:   Starts chrony.
# Description:         Starts chronyd daemon.
# X-LFS-Provided-By:   BLFS
### END INIT INFO

. /lib/lsb/init-functions

PROG="chronyd"
BIN_FILE="/usr/sbin/$PROG"
PID_FILE=/run/chrony/$PROG.pid


case "$1" in
   start	)
      #to sync the clock quickly
      log_info_msg "Starting $PROG..."
      start_daemon ${BIN_FILE} -s
      evaluate_retval
      ;;

   stop		)
      log_info_msg "Stopping $PROG..."
      killproc -p $PID_FILE ${BIN_FILE}
      evaluate_retval
      ;;

   restart	)
      $0 stop
      sleep 1
      $0 start
      ;;

   condrestart	)
      pid=`cat $PID_FILE 2>/dev/null`
        if [ -n "${pid}"  -a -d /proc/$pid ]; then
          $0 restart
          fi
      ;;

   status	)
      statusproc ${BIN_FILE}
      ;;

   *)
      echo "Usage: $0 {start|stop|restart|status}"
      exit 1
      ;;
esac

# End /etc/init.d/chronyd
