#!/bin/sh
#
# JBoss startup script.
#
# $FreeBSD: ports/java/jboss4/files/startup.sh,v 1.4 2006/06/13 17:43:14 glewis 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/diablo-jdk1.5.0/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

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

jboss4_restart ()
{
	checkyesno jboss4_enable &&
	{
		echo "Restarting jboss4."
		/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"
