#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: rslsync
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# rslsync_enable (bool):        Set to NO by default.
#                               Set it to YES to enable it.
# rslsync_user:        	        The user account rslsync daemon runs as
#                               what you want it to be. It uses 'rslsync'
#                               user by default. Do not sets it as empty or it
#                               will run as root.
# rslsync_group:                The group account rslsync daemon runs as
#                               what you want it to be. It uses 'rslsync'
#                               group by default. Do not sets it as empty or it
#                               will run as wheel.

. /etc/rc.subr
name="rslsync"
rcvar="${name}_enable"
load_rc_config ${name}

: ${rslsync_enable:="NO"}
: ${rslsync_user:="rslsync"}
: ${rslsync_group:="rslsync"}

pidfile="/var/run/rslsync/rslsync.pid"
command="/usr/local/bin/rslsync"
command_args="--config /usr/local/etc/rslsync.conf"

start_precmd=rslsync_prestart
rslsync_prestart() {
	if [ ! -d ${pidfile%/*} ]; then
		install -d -o ${rslsync_user} -g ${rslsync_group} ${pidfile%/*}
	fi
}

run_rc_command "$1"
