#!/bin/bash
#
# incrond:     Starts the incrond Daemon
#
# chkconfig: - 90 40
# description: This program is an "inotify cron" system. It consists of
#              a daemon and a table manipulator. You can use it a similar
#              way as the regular cron. The difference is that the inotify
#              cron handles filesystem events rather than time periods. 
# processname: incrond

# Source function library.
. /etc/init.d/functions

prog=incrond

start() {
	if [ ! -f /var/lock/subsys/incrond ]; then
		echo -n $"Starting $prog: "
		daemon incrond
		RETVAL=$?
		echo
		if [ $RETVAL -eq 0 ]; then
			touch /var/lock/subsys/incrond
		fi
		return $RETVAL
	fi

	return 1
}

stop() {
	echo -n $"Shutting down $prog: "
	killproc incrond
	RETVAL=$?
	if [ $RETVAL -eq 0 ]; then
		rm -f /var/lock/subsys/incrond
	fi
	echo
	return $RETVAL
}

restart() {
	stop
	start
}

RETVAL=0

# See how we were called.
case "$1" in
  start)
	start
	RETVAL=$?
	;;
  stop)
	stop
	RETVAL=$?
	;;
  status)
	status ypbind
	RETVAL=$?
	;;
  restart)
	restart
	RETVAL=$?
	;;
  condrestart|try-restart)
	if [ -e /var/lock/subsys/incrond ]; then restart; fi
	;;
  *)
	echo $"Usage: $0 {start|stop|restart|condrestart|try-restart|status}"
	RETVAL=3
esac

exit $RETVAL
