#!/bin/sh

# PROVIDE: jamulus-server
# REQUIRE: DAEMON NETWORKING
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable jamulus_server:
# jamulus_server_enable   : set to "YES" to enable the daemon, default is "NO"
# jamulus_server_uname    : user to run jamulus-server as, default is "%%USER%%"
# jamulus_server_flags    : extra flags to pass to daemon(8), default is ""
# jamulus_server_args     : any arguments to pass to jamulus-server, default is ""
#    - list of all possible arguments: https://jamulus.io/wiki/Command-Line-Options

. /etc/rc.subr

name=jamulus_server
rcvar=jamulus_server_enable

load_rc_config $name

jamulus_server_enable=${jamulus_server_enable:-"NO"}
jamulus_server_uname=${jamulus_server_uname:-"%%USER%%"}
jamulus_server_flags=${jamulus_server_flags:-""}
jamulus_server_args=${jamulus_server_args:-""}

logfile="/var/log/${name}.log"

procname=%%PREFIX%%/bin/jamulus-server
command="/usr/sbin/daemon"
command_args="-u ${jamulus_server_uname} -o ${logfile} -t ${name} %%PREFIX%%/bin/jamulus-server -s ${jamulus_server_args}"

run_rc_command "$1"
