#!/bin/bash
#
# incrond       This shell script enables the incrond daemon
#
# Author:       Ruben Kerkhof <ruben@rubenkerkhof.com>
#
# chkconfig:    - 97 03
#
# description:  This is a daemon which works like cron, but handles filesystem events
#		instead of time periods.
#               and can send notifications via mail, dbus or syslog.
# processname:  incrond
# pidfile:	/var/run/incrond.pid

# source function library

. /etc/init.d/functions

PIDFILE=/var/run/incrond.pid
LOCKFILE=/var/lock/subsys/incrond
RETVAL=0

start() {
	start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- incrond
	RETVAL=$?
	return $RETVAL
}

stop()
{
	stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root incrond
	RETVAL=$?
	return $RETVAL
}

restart()
{
	stop
	start
}

case "$1" in
  start)
	start
	;;
  stop) 
	stop
	;;
  restart) 
	restart
	;;
  condstop)
	if [ -e "$LOCKFILE" ]; then
		stop
	fi
	;;
  condrestart)
	if [ -e "$LOCKFILE" ]; then
		restart
	fi
	;;
  condreload)
	if [ -e "$LOCKFILE" ]; then
		restart
	fi
	;;
  status)
	status --pidfile "$PIDFILE" --expect-user root incrond
	RETVAL=$?
	;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|reload|condrestart|condreload}"
	exit 1
esac

exit $RETVAL
