#!/bin/sh
#=================================================================
#
# Begin atd
#
# Description:  Start at daemon
# chkconfig:	2345  99 5
#
#=================================================================

### BEGIN INIT INFO
# Provides:            $atd
# Required-Start:      $network
# Should-Start:
# Required-Stop:       
# Should-Stop:
# Default-Start:       3 4 5
# Default-Stop:        0 1 2 6
# Short-Description:   Starts atd daemon.
# Description:         Starts atd daemon.
### END INIT INFO

. /lib/lsb/init-functions

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

[ -r /etc/sysconfig/$PROG ] && . /etc/sysconfig/$PROG

case "$1" in
    start)
      log_info_msg "Starting $PROG daemon..."
      start_daemon ${BIN_FILE} $OPTS
      evaluate_retval
      ;;

    stop)
      log_info_msg "Stopping $PROG..."
      killproc ${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 $PROG
        ;;

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

