#!/bin/sh
#
# Copyright (C) 2005 Red Hat, Inc.
#
# This program is Free Software.  You may modify and/or redistribute it under
# the terms of the GNU General Public License version 2, or (at your option)
# any later version.
#
# description:  Starts and stops Red Hat Cluster Monitoring Daemon
# chkconfig: 2345 99 01
#

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

# Grab the network config file
. /etc/sysconfig/network

# Grab cluster start config if it exists
[ -f /etc/sysconfig/cluster ] && . /etc/sysconfig/cluster

PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH

ID="Cluster Monitoring Daemon"
CLUMOND="clumond"
CFG_FILE="/etc/cluster/cluster.conf"
PIDFILE="/var/run/clumond.pid"

#
# Only root wants to run this...
#
[ `id -u` = 0 ] || exit 0

#
# If we're not configured, then don't start anything.
#
[ "${NETWORKING}" = "yes" ] || exit 0
[ -f "$CFG_FILE" ] || exit 0


case $1 in
	start)
		echo -n $"Starting $ID: "
		daemon $CLUMOND
		rtrn=$?
		;;

	restart)
		$0 stop
		$0 start 
		rtrn=$?
		;;

	status)
		status $CLUMOND
		rtrn=$?
		;;

	stop)
		echo -n "Shutting down $ID: "
		killproc $CLUMOND SIGTERM
		sleep 8
		rtrn=$?
		;;

        condrestart)
               if [ -f ${PIDFILE} ] ; then
		   $0 restart
		   rtrn=$?
	       fi
	       ;;

	*)
		echo $"Usage: $0 {start|stop|restart|status}"
		rtrn=1
		;;

esac

exit $rtrn
