#!/bin/sh

# PROVIDE: repmgrd
# REQUIRE: postgresql
# KEYWORD: shutdown
#
# Add these lines to /etc/rc.conf.local or /etc/rc.conf to enable this
# service:
#
# repmgrd_enable (bool):   Set to YES to enable repmgrd.  Default: NO
#
# repmgrd_config (path):   Default: /usr/local/etc/repmgr.conf
#

. /etc/rc.subr

name=repmgrd
rcvar=repmgrd_enable

load_rc_config $name

: ${repmgrd_enable:="NO"}
: ${repmgrd_user:="pgsql"}
: ${repmgrd_config="/usr/local/etc/repmgr.conf"}

command=/usr/local/bin/${name}
pidfile=/var/run/${name}.pid

touch $pidfile
chown $repmgrd_user $pidfile

command_args="-m -d -p $pidfile -f $repmgrd_config"

run_rc_command "$1"
