#!/bin/sh

# PROVIDE: redmine
# REQUIRE: LOGIN
# KEYWORD: shutdown

# Add the following line to /etc/rc.conf[.local] to enable redmine
#
# redmine_enable (bool):        Set to "NO" by default.
#                               Set it to "YES" to enable redmine.
# redmine_args (str):           Custom additional arguments to be passed
#                               to redmine.
# redmine_user (str):		User account to run puma with. (default: %%WWWOWN%%)
# redmine_group (str):		Group to run puma with. (default: %%WWWGRP%%)

. /etc/rc.subr

name="redmine"
rcvar=redmine_enable

pidfile="%%WWWDIR%%/tmp/pids/puma.pid"

load_rc_config $name

# add /usr/local/bin to path
export PATH=$PATH:%%PREFIX%%/bin

# set defaults
: ${redmine_args="--bind tcp://0.0.0.0:3000 -e production"}
: ${redmine_enable="NO"}
: ${redmine_user="%%WWWOWN%%"}
: ${redmine_group="%%WWWGRP%%"}

command=/usr/sbin/daemon
command_args="-c -f -P ${pidfile} -S \
	%%PREFIX%%/bin/puma --dir %%WWWDIR%% --no-config ${redmine_args}"

run_rc_command "$1"
