#! /bin/sh

set -e

# Source function library.
if [ -f /etc/init.d/functions ] ; then
  . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
  . /etc/rc.d/init.d/functions
else
  exit 0
fi

DESC="crond"
NAME="crond"
DAEMON="/usr/sbin/$NAME"

case "$1" in
  start)
    echo -n "Starting $DESC: "
    start-stop-daemon -S -m -p /var/run/$NAME.pid -x $NAME
    echo_success
    echo
    ;;
  stop)
    echo -n "Stopping $DESC: "
    start-stop-daemon -K -x $NAME
    echo_success
    echo
    ;;
  restart)
    echo "Restarting $DESC: "
    $0 stop
    sleep 1
    $0 start
    echo
    ;;
  *)
    echo "Usage: $0 {start|stop|restart}" >&2
    exit 1
    ;;
esac

exit 0
