#!/bin/bash
#
# ServHACluster	MicroColor ServHA Cluster Deamon
#
# chkconfig: 345 80 10
# description: MicroColor ServHA Cluster Deamon
# processname: servhamachine

# Source function library.
. /etc/rc.d/init.d/functions
RETVAL=0
BIN_PATH=/usr/local/servha/servhamachine
prog="mcservhad"
lockfile=/var/lock/subsys/$prog

start(){
	echo -n $"Starting MicroColor ServHA: "
	$BIN_PATH start
	RETVAL=$?
	if [ $RETVAL -eq 0 ];  then
		echo_success
	else
		echo_failure
	fi
	echo -e
	[ $RETVAL -eq 0 ] && touch $lockfile
   return $RETVAL
}

stop(){
	echo -n $"Stopping MicroColor ServHA: "
	if [ "x$runlevel" = x0 -o "x$runlevel" = x6 ] ; then
		echo -n $" system is shutting down. stop all resource trees.."
		$BIN_PATH stop	
	else
		$BIN_PATH stop nostoptree
	fi
	RETVAL=$?
if [ $RETVAL -eq 0 ];  then
		echo_success
	else
		echo_failure
	fi
   echo -e
   [ $RETVAL -eq 0 ] && rm -f $lockfile
   return $RETVAL
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
   status $BIN_PATH
	RETVAL=$?
	;;
  restart)
	stop
	start
	;;
  reload)
   reload
	;;
  *)
	echo $"Usage: $prog {start|stop|restart}"
	exit 1
esac

exit $RETVAL
