#!/bin/sh

# $FreeBSD$
#
# PROVIDE: orthanc
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add these lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# orthanc_enable (bool):	Set to NO by default.
#				Set it to YES to enable Orthanc.
# orthanc_flags (str):		Set to %%ETCDIR%%/orthanc.json
#				by default.

. /etc/rc.subr

name=orthanc
rcvar=orthanc_enable
desc="Lightweight DICOM server for healthcare and medical research"

load_rc_config $name

: ${orthanc_enable:=NO}
: ${orthanc_config="%%ETCDIR%%/orthanc.json"}

start_precmd=orthanc_prestart
pidfile=/var/run/orthanc.pid
procname=%%PREFIX%%/sbin/Orthanc
command=/usr/sbin/daemon
command_args=" --output-file /var/log/orthanc --sighup --child-pidfile ${pidfile} --user orthanc ${procname} ${orthanc_flags} ${orthanc_config}"

orthanc_prestart()
{
	# Have to empty rc_flags so they don't get passed to daemon(8)
	rc_flags=""
}

run_rc_command "$1"
