#!/bin/sh
#
# JBoss startup script.
#
# $FreeBSD: ports/java/jboss3/files/startup.sh,v 1.2 2005/01/13 01:55:13 hq Exp $
#

# PROVIDE: jboss3
# REQUIRE: NETWORKING SERVERS

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

name="jboss3"
rcvar=`set_rcvar`

start_cmd="jboss3_start"
restart_cmd="jboss3_restart"
pidfile="/var/run/jboss3.pid"
procname="/usr/local/jdk1.4.2/bin/java"

[ -z "$jboss3_enable" ]	&& jboss3_enable="NO"
[ -z "$jboss3_flags" ]	&& jboss3_flags="-server"
[ -z "$jboss3_config" ]	&& jboss3_config=""

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

		/usr/local/bin/jboss3ctl -q ${jboss3_flags} ${jboss3_configflag} ${jboss3_config} start &&
		echo -n " jboss3"
	}
}

jboss3_restart ()
{
	checkyesno jboss3_enable &&
		/usr/local/bin/jboss3ctl -q ${jboss3_flags} ${jboss3_configflag} ${jboss3_config} restart
}

load_rc_config $name

[ -n "${jboss3_config}" ] && jboss3_configflag="-config"

run_rc_command "$1"
