#!/bin/sh
#
# JBoss startup script.
#
# $FreeBSD: ports/java/jboss4/files/startup.sh,v 1.3 2004/12/22 20:44:23 hq Exp $
#

# PROVIDE: jboss4
# REQUIRE: NETWORKING SERVERS

# Add the following lines to /etc/rc.conf to enable jboss4:
# jboss4_enable (bool):		Set to "NO" by default.
#				Set it to "YES" to enable jboss4
# jboss4_flags (str):		Set to "-server" by default.
#				Extra JVM flags.
# jboss4_config (str):		Set to "" by default
#				JBoss server config, eg {all|default|minimal|standard}
#
. /etc/rc.subr

name="jboss4"
rcvar=`set_rcvar`

start_cmd="jboss4_start"
restart_cmd="jboss4_restart"
pidfile="/var/run/jboss4.pid"
procname="/usr/local/jdk1.4.2/bin/java"

[ -z "$jboss4_enable" ]	&& jboss4_enable="NO"
[ -z "$jboss4_flags" ]	&& jboss4_flags="-server"
[ -z "$jboss4_config" ]	&& jboss4_config=""

jboss4_start ()
{
	checkyesno jboss4_enable &&
	{
		if [ ! -f ${pidfile} ]
		then
			touch ${pidfile}
			chown www:www ${pidfile}
		fi

		/usr/local/bin/jboss4ctl -q ${jboss4_flags} ${jboss4_configflag} ${jboss4_config} start &&
		echo -n " jboss4"
	}
}

jboss4_restart ()
{
	checkyesno jboss4_enable &&
		/usr/local/bin/jboss4ctl -q ${jboss4_flags} ${jboss4_configflag} ${jboss4_config} restart
}

load_rc_config $name

[ -n "${jboss4_config}" ] && jboss4_configflag="-config"

run_rc_command "$1"
