#!/bin/sh
#
# fam		file alteration monitor
#
# Author:	Daisuke SUZUKI <daisuke@linux.or.jp>
# chkconfig: 2345 90 10
# description: FAM - File Alteration Monitor
# processname: fam

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

#

SERVER=/usr/bin/fam
OPTIONS="-T 0"
LOCKD=/var/lock/subsys
PROGNAME=fam
prog="FAM"

[ -f $SERVER ] || exit 0

start() {
	echo -n $"Starting $prog: "
	daemon $SERVER $OPTIONS
	echo
	if [ -d $LOCKD ]; then
	    touch $LOCKD/$PROGNAME
	fi
}

stop() {
	echo -n $"Shutting down $prog: "
	killproc $SERVER
	echo
	if [ -d $LOCKD ]; then
	    rm -f $LOCKD/$PROGNAME
	fi
}

restart() {
	stop
	start
}

case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  restart)
	restart
	;;
  condrestart)
  	if [ -f $LOCKD/$PROGNAME ]; then
		restart ||:
	fi
	;;
  status)
  	status fam
	;;
  *)
	echo "Usage: fam {start|stop|restart|condrestart|status}"
	exit 1
esac

exit 0
