#!/bin/bash
#
# chkconfig: - 22 78
# description: Starts and stops cmirrord
# pidfile: /var/run/cmirrord.pid
#
# For Red-Hat-based distributions such as Fedora, RHEL, CentOS.
#
### BEGIN INIT INFO
# Provides: cmirrord
# Required-Start:       $network $time $local_fs
# Required-Stop:	$network $time $local_fs
# Short-Description:    Starts and stops cmirrord
# Description:	  Starts and stops the cluster mirror log daemon
### END INIT INFO

. /etc/init.d/functions

DAEMON="cmirrord"

LOCK_FILE="/var/lock/subsys/$DAEMON"

start()
{
        if [ -f $LOCK_FILE ]; then
                msg_already_running "$DAEMON"
                return
        fi
        msg_starting "$DAEMON"
        daemon /sbin/$DAEMON </dev/null
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch "$LOCK_FILE"
}

stop()
{
	if [ ! -f $LOCK_FILE ]; then
		msg_not_running "$DAEMON"
		return
	fi
	msg_stopping "$DAEMON"
	killproc --pidfile "$PID_FILE" "$DAEMON"
	rm -f "$LOCK_FILE"
}

RETVAL=0
# See how we were called.
case "$1" in
	start)
		start
		;;

	stop)
		stop
		;;

	restart)
		stop
		start
		;;

	status)
		status $DAEMON
		exit $?
		;;

	*)
		msg_usage "$0 {start|stop|restart|status}"
		;;
esac

exit $RETVAL
