#!/bin/bash
#
# sanlk-resetd - daemon gets events from specified sanlock lockspaces
#
# chkconfig: - 98 03
# description: The sanlk-resetd daemon gets events from specified sanlock lockspaces.
#

### BEGIN INIT INFO
# Provides: sanlk-resetd
# Required-Start: $time $syslog wdmd sanlock
# Required-Stop: $syslog
# Should-Start:
# Should-Stop:
# Default-Start: 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts and stops sanlk-resetd
# Description: starts and stops sanlk-resetd
### END INIT INFO

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

SERVICE=sanlk-resetd
LOCKFILE=/run/lock/subsys/$SERVICE

# Source config.
SourceIfNotEmpty /etc/sysconfig/$SERVICE

RETVAL=0

start() {
	start_daemon --lockfile "$LOCKFILE" --expect-user root -- $SERVICE $RESETD_OPTIONS
	RETVAL=$?
	return $RETVAL
}

stop() {
	stop_daemon --lockfile "$LOCKFILE" --expect-user root -- $SERVICE
	RETVAL=$?
	return $RETVAL
}

restart() {
	stop
	start
}

reload() {
	restart
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	status)
		status --expect-user root -- $SERVICE
		RETVAL=$?
		;;
	restart)
		restart
		;;
	reload)
		reload
		;;
	condstop)
		if [ -e "$LOCKFILE" ]; then
			stop
		fi
		;;
	condreload)
		if [ -e "$LOCKFILE" ]; then
			reload
		fi
		;;
	condrestart)
		if [ -e "$LOCKFILE" ]; then
			restart
		fi
		;;
	*)
		msg_usage "${0##*/} {start|stop|status|reload|restart|condstop|condrestart|condreload}"
		RETVAL=1
esac

exit $RETVAL

