#!/bin/sh
#
# cvslockd		This shell script takes care of starting and stopping cvslockd.
#
# chkconfig:	2345 80 30
# description:	cvslockd is a cvs locking server
#
# processname:	cvslockd

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

# Source oident configureation.
if [ -f /etc/sysconfig/cvslockd ]; then
	. /etc/sysconfig/cvslockd
fi

start() {
	# Start daemons.
	if [ -f /var/lock/subsys/cvslockd ]; then
		msg_already_running "cvslockd"
		return
	fi

	msg_starting "cvslockd"
	daemon /usr/bin/cvslockd
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/cvslockd
}

stop() {
	# Stop daemons.
	if [ ! -f /var/lock/subsys/cvslockd ]; then
		msg_not_running "cvslockd"
		return
	fi

	msg_stopping "cvslockd"
	killproc cvslockd
	rm -f /var/lock/subsys/cvslockd >/dev/null 2>&1
}

condrestart() {
	if [ ! -f /var/lock/subsys/cvslockd ]; then
		msg_not_running "cvslockd"
		RETVAL=$1
		return
	fi

	stop
	start
}

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 cvslockd
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
