#!/bin/sh
#
# incrond	Start/Stop the inotify cron-like daemon.
#
# chkconfig:	2345 40 60
#
# description:	inotify cron-like daemon.
#
# processname:	incrond
# config:	/etc/incron.conf
# pidfile:	/var/run/incrond.pid


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

# Get service config
[ -f /etc/sysconfig/incron ] && . /etc/sysconfig/incron

start() {
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/incrond ]; then
		msg_starting incrond
		daemon /usr/sbin/incrond
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/incrond
	else
		msg_already_running incrond
	fi
}

stop() {
	# Stop daemons.
	if [ -f /var/lock/subsys/incrond ]; then
		msg_stopping incrond
		killproc incrond
		rm -f /var/lock/subsys/incrond >/dev/null 2>&1
	else
		msg_not_running incrond
	fi
}

condrestart() {
	if [ -f /var/lock/subsys/incrond ]; then
		stop
		start
	else
		msg_not_running incrond
		RETVAL=$1
	fi
}

RETVAL=0
# See how we were called.
case "$1" in
  start)
  	start
	;;
  stop)
	stop
	;;
  restart)
	stop
	start
	;;
  try-restart)
	condrestart 0
	;;
  force-reload)
	condrestart 7
	;;
  status)
	status incrond
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
