#!/usr/bin/openrc-run

. /opt/etc/functions.openrc

PIDFILE="/var/run/glusterd-monitor.pid"
MONITOR="/opt/bin/autorestart"

depend() {
	need net
	after zfs localmount mounta bindmounts
	provide ${SVCNAME}
}

start()
{
	local _rc=1
	ebegin "Starting \"${SVCNAME}\""
	start-stop-daemon --background --pidfile ${PIDFILE} --make-pidfile \
			--start --exec ${MONITOR} -- glusterd 1 1 --- --no-daemon ${GLUSTERD_ARGS}
	_rc=$?
	eend ${_rc}
	return ${_rc}
}

stop()
{
	ebegin "Stopping service \"${SVCNAME}\""
	start-stop-daemon --stop --exec ${MONITOR} --retry SIGTERM/5 --pidfile ${PIDFILE}
	eend 0
	return 0
}
