#!/bin/sh

# PROVIDE: pacemaker
# REQUIRE: corosync
# KEYWORD: shutdown

. /etc/rc.subr

name="pacemaker"
rcvar="pacemaker_enable"
start_precmd="pacemaker_precmd"

load_rc_config $name

: ${pacemaker_enable:=NO}
: ${pacemaker_ipc_buffer:=0}

pidfile="/var/run/pacemakerd.pid"
procname="%%PREFIX%%/sbin/pacemakerd"
command="/usr/sbin/daemon"
command_args="-f -p ${pidfile} ${procname}"

pacemaker_precmd()
{
	if [ `${SYSCTL_N} kern.ipc.maxsockbuf` -lt 18874368 ]; then
		err 3 "sysctl:kern.ipc.maxsockbuf must be at least 18874368"
	fi

	export PATH="${PATH}:/usr/local/sbin:/usr/local/bin"
	export PCMK_ipc_buffer=${pacemaker_ipc_buffer}

	# https://bugs.clusterlabs.org/show_bug.cgi?id=5397
	#
	#export PCMK_ipc_type=socket
}

run_rc_command "$1"
