#!/bin/sh
#
# $FreeBSD: ports/www/resin3/files/resin.sh.in,v 1.7 2006/08/28 21:25:05 hq Exp $
#

# PROVIDE: resin3
# REQUIRE: LOGIN
# KEYWORD: shutdown

#
# Add the following line to /etc/rc.conf to enable resin3:
#
# resin3_enable="YES"
#

. /etc/rc.subr

name=resin3
rcvar=`set_rcvar`

command="/usr/local/sbin/resin3ctl"
command_args="start"
pidfile=/usr/local/resin3/resin3.pid

# set defaults

resin3_enable=${resin3_enable:-"NO"}
resin3_user=${resin3_user:-"www"}
resin3_group=${resin3_group:-"www"}

load_rc_config ${name}

if test -n "${resin3_java_version}" ; then
    JAVA_HOME=$(JAVA_VERSION="${resin3_java_version}" JAVAVM_DRYRUN=1 /usr/local/bin/java | grep JAVA_HOME | cut -d= -f2)
    procname=$(JAVA_VERSION="${resin3_java_version}" JAVAVM_DRYRUN=1 /usr/local/bin/java | grep JAVAVM_PROG | cut -d= -f2)
else
    JAVA_HOME=$(JAVAVM_DRYRUN=1 /usr/local/bin/java | grep JAVA_HOME | cut -d= -f2)
    procname=$(JAVAVM_DRYRUN=1 /usr/local/bin/java | grep JAVAVM_PROG | cut -d= -f2)
fi

export JAVA_HOME

run_rc_command "$1"
