#!/bin/sh

# PROVIDE: %%PORTNAME%%
# REQUIRE: SERVERS
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# librespeed_go_enable:		Set to NO by default.
#				Set it to YES to enable librespeed-go
# librespeed_go_pid:		Path of the pid file.
#				Default /var/run/%%PORTNAME%%/%%PORTNAME%%.pid
# librespeed_go_user:		The user account used to run the daemon.
#				Default: %%LIBRESPEED_USER%%
# librespeed_go_group:		The group used to run the daemon.
#				Default: %%LIBRESPEED_GROUP%%
# librespeed_go_daemonflags:	Flags passed to daemon(8)
#				Default -f which prevents any logging

. /etc/rc.subr

name="librespeed_go"
rcvar="${name}_enable"
command="/usr/sbin/daemon"

load_rc_config $name

: ${librespeed_go_enable:="NO"}
: ${librespeed_go_pid:="/var/run/%%PORTNAME%%/%%PORTNAME%%.pid"}
: ${librespeed_go_user:="%%LIBRESPEED_USER%%"}
: ${librespeed_go_group:="%%LIBRESPEED_GROUP%%"}
: ${librespeed_go_daemonflags:="-f"}

pidfile="$librespeed_go_pid"
procname="%%PREFIX%%/bin/%%PORTNAME%%"
command_args="$librespeed_go_daemonflags -p $pidfile $procname"

run_rc_command "$1"
