#!/bin/sh
# Start/stop the secrond daemon.
#
### BEGIN INIT INFO
# Provides:          secrond
# Required-Start:    $time
# Required-Stop:     $time
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Regular background program processing daemon
# Description:       Secrond is a light-weight cron implementation that allows running
#                    of user-specified programs at periodic scheduled times,
#                    also capable of handling tasks in intervals of seconds.
### END INIT INFO


SECRONDBIN=/usr/local/sbin/secrond
PIDFILE=/var/run/secrond.pid
INITSCRIPT=/etc/init.d/secrond
SIGUSR1=10


test -f $SECRONDBIN || exit 0


case "$1" in
start)  echo "Starting periodic command scheduler secrond"
        start-stop-daemon --start --pidfile $PIDFILE --name secrond --startas $SECRONDBIN
        ;;
stop)   echo "Stopping periodic command scheduler secrond"
        start-stop-daemon --stop --pidfile $PIDFILE --name secrond
        ;;
restart) echo "Restarting periodic command scheduler secrond"
        start-stop-daemon --stop --retry 5 --pidfile $PIDFILE --name secrond
        start-stop-daemon --start --pidfile $PIDFILE --name secrond --startas $SECRONDBIN
        ;;
reload|force-reload) echo "Reloading configuration file for periodic command scheduler secrond"
        if test -f $PIDFILE;
        then kill -$SIGUSR1 `cat $PIDFILE`; echo "reload signal sent";
        else echo "secrond not running";
        fi
        ;;
*)      echo "Usage: $INITSCRIPT {start|stop|restart|reload|force-reload}"
        exit 2
        ;;
esac
exit 0
