#!/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: www)
# redmine_group (str):		Group to run puma with. (default: www)

. /etc/rc.subr

name="redmine"
rcvar=redmine_enable

pidfile="/usr/local/www/redmine/tmp/pids/puma.pid"

load_rc_config $name

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

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

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

run_rc_command "$1"
