#!/bin/sh

# PROVIDE: helma
# REQUIRE: DAEMON
# BEFORE:  LOGIN
#
# Add the following line to /etc/rc.conf[.local] to enable helma
#
# helma_enable (bool):          Set to "NO" by default.
#                               Set it to "YES" to enable helma.
# helma_config (str):           Custom config file for helma.
#                               (default /usr/local/etc/helma/helma.conf)

. /etc/rc.subr

name="helma"
rcvar=helma_enable
pidfile="/var/run/${name}.pid"

load_rc_config $name

# set default
: ${helma_enable="NO"}
: ${helma_config="/usr/local/etc/${name}/${name}.conf"}

start_cmd="/usr/local/bin/${name} ${helma_config}"

# Check for existence of needed config file
if [ ! -r ${helma_config} ]; then
    echo "Can't read config file ${helma_config}"
    exit 1
else
    . ${helma_config}
fi

command="$JAVA_BIN"

run_rc_command "$1"
