ports/113844: update java/jboss4 to 4.2.0.GA

Jonathan Chen jonc at chen.org.nz
Tue Jun 19 04:10:04 UTC 2007


>Number:         113844
>Category:       ports
>Synopsis:       update java/jboss4 to 4.2.0.GA
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 19 04:10:03 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Jonathan Chen
>Release:        FreeBSD 6.2-STABLE i386
>Organization:
>Environment:
System: FreeBSD osiris.chen.org.nz 6.2-STABLE FreeBSD 6.2-STABLE #0: Thu May 24 21:03:33 NZST 2007 root at osiris.chen.org.nz:/usr/obj/usr/src/sys/OSIRIS i386
>Description:
Update java/jboss4 to 4.2.0.GA
>How-To-Repeat:
>Fix:

Update to 4.2.0.GA, with patches taken from:
   http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/113192

However, this version corrects a packing-list problem, and ensures that
the control script is invoked during shutdown.

diff -ruN /usr/ports/java/jboss4/Makefile ./Makefile
--- /usr/ports/java/jboss4/Makefile	Mon May 21 10:12:30 2007
+++ ./Makefile	Tue Jun 19 15:25:21 2007
@@ -6,8 +6,7 @@
 #
 
 PORTNAME=	${APP_TITLE:L}
-PORTVERSION=	4.0.5.GA
-PORTREVISION=	1
+PORTVERSION=	4.2.0.GA
 PORTEPOCH=	1
 CATEGORIES=	java devel
 MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
@@ -17,13 +16,14 @@
 MAINTAINER=	jonc at chen.org.nz
 COMMENT=	Open-source J2EE application server (4.x family)
 
-BUILD_DEPENDS=	ant:${PORTSDIR}/devel/apache-ant
-
 LATEST_LINK=	jboss4
 USE_JAVA=	yes
-JAVA_VERSION=	1.4+
+JAVA_VERSION=	1.5+
+USE_ANT=	yes
+MAKE_ARGS=	-buildfile build/build.xml
 
-USE_RC_SUBR=	YES
+USE_RC_SUBR=	jboss4.sh
+SUB_FILES=	pkg-install pkg-deinstall pkg-message daemonctl.c daemonctl.1
 
 .if !defined(NOPORTDOCS)
 PORTDOCS=	*
@@ -37,7 +37,7 @@
 CONTROL_SCRIPT_NAME=	${APP_SHORTNAME}ctl
 CONTROL_SCRIPT=	${PREFIX}/bin/${CONTROL_SCRIPT_NAME}
 CONTROL_SCRIPT_MANPAGE_TITLE=	${CONTROL_SCRIPT_NAME:U}
-STARTUP_SCRIPT_NAME=	${APP_SHORTNAME}.sh
+STARTUP_SCRIPT_NAME=	${APP_SHORTNAME}
 STARTUP_SCRIPT=	${PREFIX}/etc/rc.d/${STARTUP_SCRIPT_NAME}
 USER=		www
 GROUP=		www
@@ -53,49 +53,43 @@
 DAEMONCTL_FILES=daemonctl.c daemonctl.1 startup.sh pkg-message
 MAN1=		${CONTROL_SCRIPT_NAME}.1
 
-JBOSSOUTPUT=	${WRKSRC}/build/output/${PORTNAME}-${PORTVERSION:S/.s/SP/}
+JBOSSOUTPUT=	${WRKSRC}/build/output/${PORTNAME}-${PORTVERSION}
 APP_HOME_FILES=	bin client lib server
 
 PLIST_FILES=	${CONTROL_SCRIPT:S,^${PREFIX}/,,} \
-		${STARTUP_SCRIPT:S,^${PREFIX}/,,} \
 		${STDOUT_LOG:S,^${PREFIX}/,,} \
 		${STDERR_LOG:S,^${PREFIX}/,,}
 
-PKGMESSAGE=	${WRKDIR}/pkg-message.fmt
+PKGMESSAGE=	${WRKDIR}/pkg-message
 
-.include <bsd.port.pre.mk>
+SUB_LIST=	APP_HOME=${APP_HOME} \
+		APP_SHORTNAME=${APP_SHORTNAME} \
+		APP_TITLE=${APP_TITLE} \
+		CONTROL_SCRIPT=${CONTROL_SCRIPT} \
+		CONTROL_SCRIPT_MANPAGE_TITLE=${CONTROL_SCRIPT_MANPAGE_TITLE} \
+		CONTROL_SCRIPT_NAME=${CONTROL_SCRIPT_NAME} \
+		GROUP=${GROUP} \
+		JAVA=${JAVA} \
+		JAVA_CP=${JAVA_CP} \
+		JAVA_HOME=${JAVA_HOME} \
+		JAVA_MAIN=${JAVA_MAIN} \
+		JAVA_OPTS=${JAVA_OPTS} \
+		JAVA_PORT_VERSION=${JAVA_PORT_VERSION} \
+		JAVA_PORT_OS_DESCRIPTION=${JAVA_PORT_OS_DESCRIPTION} \
+		JAR_FILE=${JAR_FILE} \
+		LOG_DIR=${LOG_DIR} \
+		PID_FILE=${PID_FILE} \
+		PKGNAME=${PKGNAME} \
+		PORTNAME=${PORTNAME} \
+		PORTVERSION=${PORTVERSION} \
+		PREFIX=${PREFIX} \
+		STARTUP_SCRIPT=${STARTUP_SCRIPT} \
+		STDERR_LOG=${STDERR_LOG} \
+		STDOUT_LOG=${STDOUT_LOG} \
+		STOP_TIMEOUT=${STOP_TIMEOUT} \
+		USER=${USER}
 
-do-configure:
-	@(cd ${DAEMONCTL_DIR} && ${CP} ${DAEMONCTL_FILES} ${WRKDIR})
-	@(cd ${WRKDIR} && ${REINPLACE_CMD} \
-		-e "s|%%RC_SUBR%%|${RC_SUBR}|g;" \
-		-e "s|%%APP_HOME%%|${APP_HOME}|g;" \
-		-e "s|%%APP_SHORTNAME%%|${APP_SHORTNAME}|g;" \
-		-e "s|%%APP_TITLE%%|${APP_TITLE}|g;" \
-		-e "s|%%CONTROL_SCRIPT%%|${CONTROL_SCRIPT}|g;" \
-		-e "s|%%CONTROL_SCRIPT_MANPAGE_TITLE%%|${CONTROL_SCRIPT_MANPAGE_TITLE}|g;" \
-		-e "s|%%CONTROL_SCRIPT_NAME%%|${CONTROL_SCRIPT_NAME}|g;" \
-		-e "s|%%GROUP%%|${GROUP}|g;" \
-		-e "s|%%JAVA%%|${JAVA}|g;" \
-		-e "s|%%JAVA_CP%%|${JAVA_CP}|g;" \
-		-e "s|%%JAVA_HOME%%|${JAVA_HOME}|g;" \
-		-e "s|%%JAVA_MAIN%%|${JAVA_MAIN}|g;" \
-		-e "s|%%JAVA_OPTS%%|${JAVA_OPTS}|g;" \
-		-e "s|%%JAVA_PORT_VERSION%%|${JAVA_PORT_VERSION}|g;" \
-		-e "s|%%JAVA_PORT_OS_DESCRIPTION%%|${JAVA_PORT_OS_DESCRIPTION}|g;" \
-		-e "s|%%JAR_FILE%%|${JAR_FILE}|g;" \
-		-e "s|%%LOG_DIR%%|${LOG_DIR}|g;" \
-		-e "s|%%PID_FILE%%|${PID_FILE}|g;" \
-		-e "s|%%PKGNAME%%|${PKGNAME}|g;" \
-		-e "s|%%PORTNAME%%|${PORTNAME}|g;" \
-		-e "s|%%PORTVERSION%%|${PORTVERSION}|g;" \
-		-e "s|%%PREFIX%%|${PREFIX}|g;" \
-		-e "s|%%STARTUP_SCRIPT%%|${STARTUP_SCRIPT}|g;" \
-		-e "s|%%STDERR_LOG%%|${STDERR_LOG}|g;" \
-		-e "s|%%STDOUT_LOG%%|${STDOUT_LOG}|g;" \
-		-e "s|%%STOP_TIMEOUT%%|${STOP_TIMEOUT}|g;" \
-		-e "s|%%USER%%|${USER}|g;" ${DAEMONCTL_FILES})
-	@${FMT} -s 80 ${WRKDIR}/pkg-message >${PKGMESSAGE}
+.include <bsd.port.pre.mk>
 
 post-configure:
 	@${ECHO_MSG} "Installation settings:"
@@ -111,21 +105,22 @@
 	@${ECHO_MSG} "   Starting after install:   ${AUTO_START}"
 	@${ECHO_MSG} "   Stop time-out:            ${STOP_TIMEOUT} sec."
 
-do-build:
-	(cd ${WRKDIR} && ${CC} ${CFLAGS} -o ${CONTROL_SCRIPT_NAME} daemonctl.c)
-	(cd ${WRKSRC}/build && ${SETENV} JAVA_HOME="${JAVA_HOME}" PATH="${JAVA_HOME}/bin:${PATH}" ${SH} build.sh)
+post-patch:
+	@${ECHO_MSG} -n ">> Removing unneeded files..."
+	@${FIND} ${WRKSRC} -name '*.orig' -delete
+	@${ECHO_MSG} " [ DONE ]"
 
 pre-install:
 	@${SETENV} PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL
 
 do-install:
+	cd ${WRKDIR} && ${CC} ${CFLAGS} -o ${CONTROL_SCRIPT_NAME} daemonctl.c
 	${MKDIR} ${APP_HOME} && ${CHOWN} ${USER}:${GROUP} ${APP_HOME}
 	${MKDIR} ${LOG_DIR} && ${CHOWN} ${USER}:${GROUP} ${LOG_DIR}
 	(cd ${JBOSSOUTPUT} && ${FIND} ${APP_HOME_FILES} |\
 		${CPIO} -pdmu -R ${USER}:${GROUP} ${APP_HOME})
 	${INSTALL} -o ${USER} -g ${GROUP} -m 06754\
 		${WRKDIR}/${CONTROL_SCRIPT_NAME} ${CONTROL_SCRIPT}
-	${INSTALL_SCRIPT} ${WRKDIR}/startup.sh ${STARTUP_SCRIPT}
 	${INSTALL} -o ${USER} -g ${GROUP} -m 0640 /dev/null ${STDOUT_LOG}
 	${INSTALL} -o ${USER} -g ${GROUP} -m 0640 /dev/null ${STDERR_LOG}
 	${INSTALL} -o ${USER} -g ${GROUP} -m 0640 /dev/null ${PID_FILE}
diff -ruN /usr/ports/java/jboss4/distinfo ./distinfo
--- /usr/ports/java/jboss4/distinfo	Fri Nov 10 10:08:17 2006
+++ ./distinfo	Wed Jun 13 09:25:28 2007
@@ -1,3 +1,3 @@
-MD5 (jboss-4.0.5.GA-src.tar.gz) = d93ab59f52a5c196520673d272cb7a42
-SHA256 (jboss-4.0.5.GA-src.tar.gz) = 087aa32185d3867c993d3b318675dbb6c4ce71e410730d24e5d358e4206ae3d8
-SIZE (jboss-4.0.5.GA-src.tar.gz) = 78808549
+MD5 (jboss-4.2.0.GA-src.tar.gz) = 1b6d458f1945a6203dfbed87ac83dda3
+SHA256 (jboss-4.2.0.GA-src.tar.gz) = 88a1308b30dbd6fdb6bd6fd69050c55285cf0d410a3ed942646a8593e76003b0
+SIZE (jboss-4.2.0.GA-src.tar.gz) = 108677264
diff -ruN /usr/ports/java/jboss4/files/daemonctl.1 ./files/daemonctl.1
--- /usr/ports/java/jboss4/files/daemonctl.1	Tue Jun 22 04:42:59 2004
+++ ./files/daemonctl.1	Thu Jan  1 12:00:00 1970
@@ -1,78 +0,0 @@
-.Dd February 21, 2002
-.Dt %%CONTROL_SCRIPT_MANPAGE_TITLE%% 1
-.Os FreeBSD
-.Sh NAME
-.Nm %%CONTROL_SCRIPT_NAME%%
-.Nd %%APP_TITLE%% server control interface
-.Sh SYNOPSIS
-.Nm
-.Op Fl java-options
-.Ar {start|restart|stop}
-.Sh DESCRIPTION
-The
-.Nm
-program provides an restricted interface to the %%APP_TITLE%%
-application server. The
-.Nm
-program is only accessible to users in the 'www' group, and will
-only invoke the %%JAVA_PORT_OS_DESCRIPTION%% %%JAVA_PORT_VERSION%% JVM.
-.Pp
-Any Java options listed are handed off directly to the JVM. Any
-classpath options will be ignored.
-.Pp
-The program expects exactly one of the following terminating commands:
-.Bl -tag -width indent
-.It Ar start
-Start %%APP_TITLE%%, if it is not already running.
-.It Ar restart
-Restart %%APP_TITLE%%. If it is already running, then it will be stopped and
-then started right after that. Otherwise it will just be started up.
-.It Ar stop
-Stop %%APP_TITLE%%, if it is actually running.
-.El
-.Sh ERRORS
-The following error conditions are detected. They will be checked in the
-specified order. In each case an error message is printed with the name of the
-control program prepended.
-.Pp
-If no argument is passed, then a simple help message is printed and the
-program exists with error code 0.
-.Pp
-If at least one argument is passed, but it is different from
-.Ar start ,
-.Ar restart
-or
-.Ar stop
-then the help message is printed as well, and the program exits with error
-code 1.
-.Pp
-The following errors conditions are defined:
-.Bl -tag -width indent
-.It Em Illegal program argument (error code 1)
-.It Em PID file not found (error code 2)
-.It Em PID file too large (error code 3)
-.It Em PID file contains illegal character (error code 4)
-.It Em Kill of process failed (error code 5)
-.It Em %%APP_TITLE%% is already running (error code 6)
-.It Em %%APP_TITLE%% is not running (error code 7)
-.It Em Unable to chdir to the %%APP_TITLE%% home directory (error code 8)
-.It Em Unable to open the stdout log file (error code 9)
-.It Em Unable to open the stderr log file (error code 10)
-.It Em Unable to start %%APP_TITLE%% (error code 11)
-.El
-.Sh FILES
-.Bl -tag -width -indent
-.It Pa %%PID_FILE%%
-The %%APP_TITLE%% PID file that is used to store the process ID of the
-currently running process in. It is emptied as soon as the server is stopped
-and filled with the process ID when it is started. It should never be writable
-for anyone but
-.Em www ,
-.It Pa %%STARTUP_SCRIPT%%
-A script that starts the
-.Nm
-program. It is used to start %%APP_TITLE%% at startup time.
-.El
-.Sh AUTHORS
-.An Ernst de Haan Aq znerd at FreeBSD.org
-.An Jonathan Chen Aq jonc at chen.org.nz
diff -ruN /usr/ports/java/jboss4/files/daemonctl.1.in ./files/daemonctl.1.in
--- /usr/ports/java/jboss4/files/daemonctl.1.in	Thu Jan  1 12:00:00 1970
+++ ./files/daemonctl.1.in	Wed Jun 13 09:25:28 2007
@@ -0,0 +1,78 @@
+.Dd February 21, 2002
+.Dt %%CONTROL_SCRIPT_MANPAGE_TITLE%% 1
+.Os FreeBSD
+.Sh NAME
+.Nm %%CONTROL_SCRIPT_NAME%%
+.Nd %%APP_TITLE%% server control interface
+.Sh SYNOPSIS
+.Nm
+.Op Fl java-options
+.Ar {start|restart|stop}
+.Sh DESCRIPTION
+The
+.Nm
+program provides an restricted interface to the %%APP_TITLE%%
+application server. The
+.Nm
+program is only accessible to users in the 'www' group, and will
+only invoke the %%JAVA_PORT_OS_DESCRIPTION%% %%JAVA_PORT_VERSION%% JVM.
+.Pp
+Any Java options listed are handed off directly to the JVM. Any
+classpath options will be ignored.
+.Pp
+The program expects exactly one of the following terminating commands:
+.Bl -tag -width indent
+.It Ar start
+Start %%APP_TITLE%%, if it is not already running.
+.It Ar restart
+Restart %%APP_TITLE%%. If it is already running, then it will be stopped and
+then started right after that. Otherwise it will just be started up.
+.It Ar stop
+Stop %%APP_TITLE%%, if it is actually running.
+.El
+.Sh ERRORS
+The following error conditions are detected. They will be checked in the
+specified order. In each case an error message is printed with the name of the
+control program prepended.
+.Pp
+If no argument is passed, then a simple help message is printed and the
+program exists with error code 0.
+.Pp
+If at least one argument is passed, but it is different from
+.Ar start ,
+.Ar restart
+or
+.Ar stop
+then the help message is printed as well, and the program exits with error
+code 1.
+.Pp
+The following errors conditions are defined:
+.Bl -tag -width indent
+.It Em Illegal program argument (error code 1)
+.It Em PID file not found (error code 2)
+.It Em PID file too large (error code 3)
+.It Em PID file contains illegal character (error code 4)
+.It Em Kill of process failed (error code 5)
+.It Em %%APP_TITLE%% is already running (error code 6)
+.It Em %%APP_TITLE%% is not running (error code 7)
+.It Em Unable to chdir to the %%APP_TITLE%% home directory (error code 8)
+.It Em Unable to open the stdout log file (error code 9)
+.It Em Unable to open the stderr log file (error code 10)
+.It Em Unable to start %%APP_TITLE%% (error code 11)
+.El
+.Sh FILES
+.Bl -tag -width -indent
+.It Pa %%PID_FILE%%
+The %%APP_TITLE%% PID file that is used to store the process ID of the
+currently running process in. It is emptied as soon as the server is stopped
+and filled with the process ID when it is started. It should never be writable
+for anyone but
+.Em www ,
+.It Pa %%STARTUP_SCRIPT%%
+A script that starts the
+.Nm
+program. It is used to start %%APP_TITLE%% at startup time.
+.El
+.Sh AUTHORS
+.An Ernst de Haan Aq znerd at FreeBSD.org
+.An Jonathan Chen Aq jonc at chen.org.nz
diff -ruN /usr/ports/java/jboss4/files/daemonctl.c ./files/daemonctl.c
--- /usr/ports/java/jboss4/files/daemonctl.c	Mon Jan  3 17:13:21 2005
+++ ./files/daemonctl.c	Thu Jan  1 12:00:00 1970
@@ -1,557 +0,0 @@
-/*
- * -*- mode: Fundamental; tab-width: 4; -*-
- * ex:ts=4
- *
- * Daemon control program, with Java Startup options.
- *
- *	Original by Ernst de Haan <znerd at freebsd.org>
- *	www/jakarta-tomcat4/files/daemonctl.c
- *
- * $FreeBSD: ports/java/jboss4/files/daemonctl.c,v 1.3 2004/12/22 20:44:23 hq Exp $
- */
-
-#include <assert.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <syslog.h>
-#include <unistd.h>
-#include <sys/errno.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/uio.h>
-
-#define	TRUE	1
-#define	FALSE	0
-
-/* The interval in seconds between the checks to make sure the process
-   died after a kill */
-#define STOP_TIME_INTERVAL		1
-
-#define ERR_ILLEGAL_ARGUMENT				1
-#define ERR_PID_FILE_NOT_FOUND				2
-#define ERR_KILL_FAILED						5
-#define ERR_ALREADY_RUNNING					6
-#define ERR_NOT_RUNNING						7
-#define ERR_CHDIR_TO_APP_HOME				8
-#define ERR_ACCESS_JAR_FILE					17
-#define ERR_STDOUT_LOGFILE_OPEN				9
-#define ERR_STDERR_LOGFILE_OPEN				10
-#define ERR_FORK_FAILED						11
-#define ERR_STAT_JAVA_HOME					12
-#define ERR_JAVA_HOME_NOT_DIR				13
-#define ERR_STAT_JAVA_CMD					14
-#define ERR_JAVA_CMD_NOT_FILE				15
-#define ERR_JAVA_CMD_NOT_EXECUTABLE			16
-
-/*
-	Function declarations.
- */
-static void printUsage (void);
-static int readPID (void);
-static void writePID (int pid);
-static void clearPID (void);
-static void start (int javaOpt, char * javaArgs [], int jbossOpt, char * jbossArgs []);
-static void stop (void);
-static void restart (int javaOpt, char * javaArgs [], int jbossOpt, char * jbossArgs []);
-static void logOutput (char *);
-
-/*
-	Globals
- */
-static int isQuiet = FALSE;
-static char * optQuiet = "-q",			/* quiet option */
-			* optConfig = "-config";	/* jboss configuration option */
-
-/**
- * Main function. This function is called when this program is executed.
- *
- * @param argc
- *    the number of arguments plus one, so always greater than 0.
- *
- * @param argv
- *    the arguments in an array of character pointers, where the last argument
- *    element is followed by a NULL element.
- */
-int
-main (
- int argc,
- char *argv [])
-{
-	/* Declare variables, like all other good ANSI C programs do :) */
-	int i, javaOpt, jbossOpt;
-	char *argument, **javaArgs, **jbossArgs;
-
-	/* Parse the arguments */
-	if (argc < 2)
-	{
-		printUsage ();
-		return 0;
-	}
-
-	/* XXX: Fix for setting up the environment for the java wrapper script */
-	setuid (geteuid ());
-	setgid (getegid ());
-
-	/*
-		Build up java and jboss option blocks.
-	 */
-	javaOpt = jbossOpt = 0;
-	for (i = 1; i < argc; i++)
-	{
-		if (strcmp (argv [i], optQuiet) == 0)
-		{
-			isQuiet = TRUE;
-
-		} else if (strcmp (argv [i], optConfig) == 0)
-		{
-			jbossOpt += 2;
-			if (++i >= argc)
-			{
-				printUsage ();
-				return ERR_ILLEGAL_ARGUMENT;
-			}
-
-		} else if (*argv [i] == '-')
-		{
-			javaOpt++;
-		}
-	}
-	if (javaOpt == 0)
-		javaArgs = NULL;
-	else
-	{
-		int j = 0;
-		javaArgs = malloc (sizeof (char *) * javaOpt);
-		for (i = 0; i < argc; i++)
-		{
-			if (strcmp (argv [i], optQuiet) &&
-				strcmp (argv [i], optConfig) &&
-				*argv [i] == '-')
-			{
-				javaArgs [j++] = argv [i];
-			}
-		}
-	}
-	if (jbossOpt == 0)
-		jbossArgs = NULL;
-	else
-	{
-		int j = 0;
-		jbossArgs = malloc (sizeof (char *) * jbossOpt);
-		for (i = 0; i < argc; i++)
-		{
-			if (strcmp (argv [i], optConfig) == 0)
-			{
-				jbossArgs [j++] = "-c";
-				jbossArgs [j++] = argv [++i];
-			}
-		}
-	}
-
-	/*
-		Decide on just what to call.
-	 */
-	argument = argv [argc - 1];
-	if (strcmp ("start", argument) == 0)
-	{
-		start (javaOpt, javaArgs, jbossOpt, jbossArgs);
-
-	} else if (strcmp ("stop", argument) == 0)
-	{
-		stop ();
-
-	} else if (strcmp ("restart", argument) == 0)
-	{
-		restart (javaOpt, javaArgs, jbossOpt, jbossArgs);
-
-	} else {
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Illegal argument \"%s\".\n", argument);
-		printUsage ();
-		exit (ERR_ILLEGAL_ARGUMENT);
-	}
-
-	return EXIT_SUCCESS;
-}
-
-/**
- * Prints usage information to stdout.
- */
-static void
-printUsage (void)
-{
-	printf ("Usage: %%CONTROL_SCRIPT_NAME%% [java-options] [-config jbossconfig] {start|stop|restart}\n");
-}
-
-/**
- * Reads a PID from the PID file.
- *
- * @return
- *    the PID, or -1 if the file was empty.
- */
-static int
-readPID (void)
-{
-	FILE * file;
-	int pid;
-
-	logOutput (">> Reading PID file (%%PID_FILE%%)...");
-	file = fopen ("%%PID_FILE%%", "r");
-	if (!file)
-	{
-		logOutput (" [ FAILED ]\n");
-		perror ("%%CONTROL_SCRIPT_NAME%%: Unable to open %%PID_FILE%% for reading: ");
-		exit (ERR_PID_FILE_NOT_FOUND);
-	}
-	if (fscanf (file, "%d", &pid) < 1)
-		pid = -1;
-	fclose (file);
-
-	logOutput (" [ DONE ]\n");
-	return pid;
-}
-
-/**
- * Writes a process ID to the specified file. The file is identified by a file
- * handle.
- *
- * @param pid
- *    the PID to store, always greater than 0.
- */
-static void
-writePID (
- int pid)
-{
-	FILE * file;
-
-	logOutput (">> Writing PID file...");
-	file = fopen ("%%PID_FILE%%", "w");
-	if (!file)
-	{
-		logOutput (" [ FAILED ]\n");
-		perror ("%%CONTROL_SCRIPT_NAME%%: Unable to open %%PID_FILE%% for writing: ");
-		exit (ERR_PID_FILE_NOT_FOUND);
-	}
-	fprintf (file, "%d\n", pid);
-	fclose (file);
-
-	logOutput (" [ DONE ]\n");
-}
-
-/**
-	Truncate the PID file.
- */
-static void
-clearPID (void)
-{
-	if (truncate ("%%PID_FILE%%", 0) != 0)
-	{
-		perror ("%%CONTROL_SCRIPT_NAME%%: Unable to clear %%PID_FILE%%: ");
-		exit (ERR_PID_FILE_NOT_FOUND);
-	}
-}
-
-/**
- * Checks if the specified process is running.
- *
- * @param pid
- *    the process id, greater than 0.
- *
- * @return
- *    0 if the specified process is not running, a different value otherwise.
- */
-static int
-existsProcess (
- int pid)
-{
-	int result;
-
-	/* Check preconditions */
-	assert (pid > 0);
-
-	/* See if the process exists */
-   	result = kill (pid, 0);
-
-	/* If the result is 0, then the process exists */
-	return result == 0;
-}
-
-/**
- * Kills the process identified by the specified ID.
- *
- * @param pid
- *    the process id, greater than 0.
- */
-static void
-killProcess (
- int pid)
-{
-	int result;
-	unsigned int waited;
-	unsigned int forced;
-	unsigned int interval = STOP_TIME_INTERVAL;
-	unsigned int timeout  = %%STOP_TIMEOUT%%;
-
-	/* Check preconditions */
-	assert (pid > 0);
-
-	if (!isQuiet)
-		printf (">> Terminating process %d...", pid);
-	result = kill (pid, SIGTERM);
-	if (result < 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to kill process %d: ", pid);
-		perror (NULL);
-		exit (ERR_KILL_FAILED);
-	}
-
-	/* Wait until the process is actually killed */
-    result = existsProcess (pid);
-	for (waited=0; result == 1 && waited < timeout; waited += interval)
-	{
-		logOutput (".");
-		fflush (stdout);
-		sleep (interval);
-    	result = existsProcess (pid);
-	}
-
-	/* If the process still exists, then have no mercy and kill it */
-	forced = 0;
-	if (result == 1)
-	{
-		/* Force the process to die */
-		result = kill (pid, SIGKILL);
-		if (result == 0) {
-			forced = 1;
-			logOutput (" [ KILLED ]\n");
-			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Process %d did not terminate within %%STOP_TIMEOUT%% sec. Killed.\n", pid);
-		} else if (result != ESRCH) {
-			logOutput (" [ FAILED ]\n");
-			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to kill process %d: ", pid);
-			perror (NULL);
-			exit (ERR_KILL_FAILED);
-		}
-	}
-
-	if (forced == 0) {
-		logOutput (" [ DONE ]\n");
-	}
-}
-
-/**
- * Starts the daemon.
- */
-static void
-start (
- int javaOpt,
- char * javaArgs [],
- int jbossOpt,
- char * jbossArgs [])
-{
-	int i, argc;
-	char ** argv;
-	int pid;
-	int result;
-	int stdoutLogFile;
-	int stderrLogFile;
-	struct stat sb;
-
-	pid = readPID ();
-
-	logOutput (">> Starting %%APP_TITLE%% %%PORTVERSION%%...");
-	if (pid != -1)
-	{
-		/* Check if the process actually exists */
-		result = existsProcess (pid);
-		if (result == 1)
-		{
-			logOutput (" [ FAILED ]\n");
-			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: %%APP_TITLE%% %%PORTVERSION%% is already running, PID is %d.\n", pid);
-			exit (ERR_ALREADY_RUNNING);
-		}
-	}
-
-	/* Check if the JDK home directory is actually a directory */
-	result = stat ("%%JAVA_HOME%%", &sb);
-	if (result != 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to stat %%JAVA_HOME%%: ");
-		perror (NULL);
-		exit (ERR_STAT_JAVA_HOME);
-	}
-	if (!S_ISDIR (sb.st_mode)) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Java home directory %%JAVA_HOME%% is not a directory.\n");
-		exit (ERR_JAVA_HOME_NOT_DIR);
-	}
-
-	/* Check if the Java command is actually an executable regular file */
-	result = stat ("%%JAVA%%", &sb);
-	if (result != 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to stat %%JAVA%%: ");
-		perror (NULL);
-		exit (ERR_STAT_JAVA_CMD);
-	}
-	if (!S_ISREG (sb.st_mode)) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Java command %%JAVA%% is not a regular file.\n");
-		exit (ERR_JAVA_CMD_NOT_FILE);
-	}
-	result = access ("%%JAVA%%", X_OK);
-	if (result != 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Java command %%JAVA%% is not executable: ");
-		perror (NULL);
-		exit (ERR_JAVA_CMD_NOT_EXECUTABLE);
-	}
-
-	/* Change directory */
-	result = chdir ("%%APP_HOME%%");
-	if (result < 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to access directory %%APP_HOME%%: ");
-		perror (NULL);
-		exit (ERR_CHDIR_TO_APP_HOME);
-	}
-
-	/* See if the JAR file exists */
-	result = access ("%%APP_HOME%%/%%JAR_FILE%%", R_OK);
-	if (result < 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to access JAR file %%APP_HOME%%/%%JAR_FILE%%: ");
-		perror (NULL);
-		exit (ERR_ACCESS_JAR_FILE);
-	}
-
-	/* Open the stdout log file */
-	stdoutLogFile = open ("%%STDOUT_LOG%%", O_WRONLY);
-	if (stdoutLogFile < 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to open %%STDOUT_LOG%% for writing: ");
-		perror (NULL);
-		exit (ERR_STDOUT_LOGFILE_OPEN);
-	}
-	lseek (stdoutLogFile, (off_t) 0, SEEK_END);
-
-	/* Open the stderr log file */
-	stderrLogFile = open ("%%STDERR_LOG%%", O_WRONLY);
-	if (stderrLogFile < 0) {
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to open %%STDERR_LOG%% for writing: ");
-		perror (NULL);
-		exit (ERR_STDERR_LOGFILE_OPEN);
-	}
-	lseek (stderrLogFile, (off_t) 0, SEEK_END);
-
-	/* Split this process in two */
-	switch (pid = fork ())
-	{
-	case -1:
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to fork: ");
-		perror (NULL);
-		exit (ERR_FORK_FAILED);
-		break;
-
-	case 0:
-		/* Redirect stdout to log file */
-		dup2 (stdoutLogFile, STDOUT_FILENO);
-
-		/* Redirect stderr to log file */
-		dup2 (stderrLogFile, STDERR_FILENO);
-
-		/* TODO: Support redirection of both stdout and stderr to the same
-				 file using pipe (2) */
-
-		/*
-			Build the argument vector, with the java/jboss options if any.
-		 */
-		argv = malloc (sizeof (char *) * (javaOpt + jbossOpt + 5));
-		argc = 0;
-		argv [argc++] = "%%JAVA%%";
-		for (i = 0; i < javaOpt; i++)
-			argv [argc++] = javaArgs [i];
-		argv [argc++] = "-cp";
-		argv [argc++] = "%%JAVA_CP%%";
-		argv [argc++] = "%%JAVA_MAIN%%";
-		for (i = 0; i < jbossOpt; i++)
-			argv [argc++] = jbossArgs [i];
-		argv [argc++] = NULL;
-
-		/* Execute the command */
-		execv (argv [0], argv);
-		perror (NULL);
-		break;
-
-	default:
-		logOutput (" [ DONE ]\n");
-		writePID (pid);
-	}
-}
-
-/**
- * Stops the daemon.
- */
-static void
-stop (void)
-{
-	int pid;
-
-	pid = readPID ();
-
-	logOutput (">> Checking if %%APP_TITLE%% %%PORTVERSION%% is running...");
-
-	/* If there is a PID, see if the process still exists */
-	if (pid != -1)
-	{
-		int result = kill (pid, 0);
-		if (result != 0 && errno == ESRCH)
-		{
-			clearPID ();
-			pid = -1;
-		}
-	}
-
-	/* If there is no running process, produce an error */
-	if (pid == -1)
-	{
-		logOutput (" [ FAILED ]\n");
-		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: %%APP_TITLE%% %%PORTVERSION%% is currently not running.\n");
-		exit (ERR_NOT_RUNNING);
-	}
-	logOutput (" [ DONE ]\n");
-
-	/* Terminate the process */
-	killProcess (pid);
-	clearPID ();
-}
-
-
-/**
- * Restarts the process. If it not currently running, then it will fail.
- */
-static void
-restart (
- int javaOpt,
- char * javaArgs [],
- int jbossOpt,
- char * jbossArgs [])
-{
-	stop ();
-	start (javaOpt, javaArgs, jbossOpt, jbossArgs);
-}
-
-/**
-	Output log to stdout.
- */
-static void
-logOutput (
- char * string)
-{
-	if (!isQuiet)
-		printf (string);
-}
diff -ruN /usr/ports/java/jboss4/files/daemonctl.c.in ./files/daemonctl.c.in
--- /usr/ports/java/jboss4/files/daemonctl.c.in	Thu Jan  1 12:00:00 1970
+++ ./files/daemonctl.c.in	Wed Jun 13 09:25:28 2007
@@ -0,0 +1,557 @@
+/*
+ * -*- mode: Fundamental; tab-width: 4; -*-
+ * ex:ts=4
+ *
+ * Daemon control program, with Java Startup options.
+ *
+ *	Original by Ernst de Haan <znerd at freebsd.org>
+ *	www/jakarta-tomcat4/files/daemonctl.c
+ *
+ * $FreeBSD: ports/java/jboss4/files/daemonctl.c,v 1.3 2004/12/22 20:44:23 hq Exp $
+ */
+
+#include <assert.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
+#include <unistd.h>
+#include <sys/errno.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/uio.h>
+
+#define	TRUE	1
+#define	FALSE	0
+
+/* The interval in seconds between the checks to make sure the process
+   died after a kill */
+#define STOP_TIME_INTERVAL		1
+
+#define ERR_ILLEGAL_ARGUMENT				1
+#define ERR_PID_FILE_NOT_FOUND				2
+#define ERR_KILL_FAILED						5
+#define ERR_ALREADY_RUNNING					6
+#define ERR_NOT_RUNNING						7
+#define ERR_CHDIR_TO_APP_HOME				8
+#define ERR_ACCESS_JAR_FILE					17
+#define ERR_STDOUT_LOGFILE_OPEN				9
+#define ERR_STDERR_LOGFILE_OPEN				10
+#define ERR_FORK_FAILED						11
+#define ERR_STAT_JAVA_HOME					12
+#define ERR_JAVA_HOME_NOT_DIR				13
+#define ERR_STAT_JAVA_CMD					14
+#define ERR_JAVA_CMD_NOT_FILE				15
+#define ERR_JAVA_CMD_NOT_EXECUTABLE			16
+
+/*
+	Function declarations.
+ */
+static void printUsage (void);
+static int readPID (void);
+static void writePID (int pid);
+static void clearPID (void);
+static void start (int javaOpt, char * javaArgs [], int jbossOpt, char * jbossArgs []);
+static void stop (void);
+static void restart (int javaOpt, char * javaArgs [], int jbossOpt, char * jbossArgs []);
+static void logOutput (char *);
+
+/*
+	Globals
+ */
+static int isQuiet = FALSE;
+static char * optQuiet = "-q",			/* quiet option */
+			* optConfig = "-config";	/* jboss configuration option */
+
+/**
+ * Main function. This function is called when this program is executed.
+ *
+ * @param argc
+ *    the number of arguments plus one, so always greater than 0.
+ *
+ * @param argv
+ *    the arguments in an array of character pointers, where the last argument
+ *    element is followed by a NULL element.
+ */
+int
+main (
+ int argc,
+ char *argv [])
+{
+	/* Declare variables, like all other good ANSI C programs do :) */
+	int i, javaOpt, jbossOpt;
+	char *argument, **javaArgs, **jbossArgs;
+
+	/* Parse the arguments */
+	if (argc < 2)
+	{
+		printUsage ();
+		return 0;
+	}
+
+	/* XXX: Fix for setting up the environment for the java wrapper script */
+	setuid (geteuid ());
+	setgid (getegid ());
+
+	/*
+		Build up java and jboss option blocks.
+	 */
+	javaOpt = jbossOpt = 0;
+	for (i = 1; i < argc; i++)
+	{
+		if (strcmp (argv [i], optQuiet) == 0)
+		{
+			isQuiet = TRUE;
+
+		} else if (strcmp (argv [i], optConfig) == 0)
+		{
+			jbossOpt += 2;
+			if (++i >= argc)
+			{
+				printUsage ();
+				return ERR_ILLEGAL_ARGUMENT;
+			}
+
+		} else if (*argv [i] == '-')
+		{
+			javaOpt++;
+		}
+	}
+	if (javaOpt == 0)
+		javaArgs = NULL;
+	else
+	{
+		int j = 0;
+		javaArgs = malloc (sizeof (char *) * javaOpt);
+		for (i = 0; i < argc; i++)
+		{
+			if (strcmp (argv [i], optQuiet) &&
+				strcmp (argv [i], optConfig) &&
+				*argv [i] == '-')
+			{
+				javaArgs [j++] = argv [i];
+			}
+		}
+	}
+	if (jbossOpt == 0)
+		jbossArgs = NULL;
+	else
+	{
+		int j = 0;
+		jbossArgs = malloc (sizeof (char *) * jbossOpt);
+		for (i = 0; i < argc; i++)
+		{
+			if (strcmp (argv [i], optConfig) == 0)
+			{
+				jbossArgs [j++] = "-c";
+				jbossArgs [j++] = argv [++i];
+			}
+		}
+	}
+
+	/*
+		Decide on just what to call.
+	 */
+	argument = argv [argc - 1];
+	if (strcmp ("start", argument) == 0)
+	{
+		start (javaOpt, javaArgs, jbossOpt, jbossArgs);
+
+	} else if (strcmp ("stop", argument) == 0)
+	{
+		stop ();
+
+	} else if (strcmp ("restart", argument) == 0)
+	{
+		restart (javaOpt, javaArgs, jbossOpt, jbossArgs);
+
+	} else {
+		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Illegal argument \"%s\".\n", argument);
+		printUsage ();
+		exit (ERR_ILLEGAL_ARGUMENT);
+	}
+
+	return EXIT_SUCCESS;
+}
+
+/**
+ * Prints usage information to stdout.
+ */
+static void
+printUsage (void)
+{
+	printf ("Usage: %%CONTROL_SCRIPT_NAME%% [java-options] [-config jbossconfig] {start|stop|restart}\n");
+}
+
+/**
+ * Reads a PID from the PID file.
+ *
+ * @return
+ *    the PID, or -1 if the file was empty.
+ */
+static int
+readPID (void)
+{
+	FILE * file;
+	int pid;
+
+	logOutput (">> Reading PID file (%%PID_FILE%%)...");
+	file = fopen ("%%PID_FILE%%", "r");
+	if (!file)
+	{
+		logOutput (" [ FAILED ]\n");
+		perror ("%%CONTROL_SCRIPT_NAME%%: Unable to open %%PID_FILE%% for reading: ");
+		exit (ERR_PID_FILE_NOT_FOUND);
+	}
+	if (fscanf (file, "%d", &pid) < 1)
+		pid = -1;
+	fclose (file);
+
+	logOutput (" [ DONE ]\n");
+	return pid;
+}
+
+/**
+ * Writes a process ID to the specified file. The file is identified by a file
+ * handle.
+ *
+ * @param pid
+ *    the PID to store, always greater than 0.
+ */
+static void
+writePID (
+ int pid)
+{
+	FILE * file;
+
+	logOutput (">> Writing PID file...");
+	file = fopen ("%%PID_FILE%%", "w");
+	if (!file)
+	{
+		logOutput (" [ FAILED ]\n");
+		perror ("%%CONTROL_SCRIPT_NAME%%: Unable to open %%PID_FILE%% for writing: ");
+		exit (ERR_PID_FILE_NOT_FOUND);
+	}
+	fprintf (file, "%d\n", pid);
+	fclose (file);
+
+	logOutput (" [ DONE ]\n");
+}
+
+/**
+	Truncate the PID file.
+ */
+static void
+clearPID (void)
+{
+	if (truncate ("%%PID_FILE%%", 0) != 0)
+	{
+		perror ("%%CONTROL_SCRIPT_NAME%%: Unable to clear %%PID_FILE%%: ");
+		exit (ERR_PID_FILE_NOT_FOUND);
+	}
+}
+
+/**
+ * Checks if the specified process is running.
+ *
+ * @param pid
+ *    the process id, greater than 0.
+ *
+ * @return
+ *    0 if the specified process is not running, a different value otherwise.
+ */
+static int
+existsProcess (
+ int pid)
+{
+	int result;
+
+	/* Check preconditions */
+	assert (pid > 0);
+
+	/* See if the process exists */
+   	result = kill (pid, 0);
+
+	/* If the result is 0, then the process exists */
+	return result == 0;
+}
+
+/**
+ * Kills the process identified by the specified ID.
+ *
+ * @param pid
+ *    the process id, greater than 0.
+ */
+static void
+killProcess (
+ int pid)
+{
+	int result;
+	unsigned int waited;
+	unsigned int forced;
+	unsigned int interval = STOP_TIME_INTERVAL;
+	unsigned int timeout  = %%STOP_TIMEOUT%%;
+
+	/* Check preconditions */
+	assert (pid > 0);
+
+	if (!isQuiet)
+		printf (">> Terminating process %d...", pid);
+	result = kill (pid, SIGTERM);
+	if (result < 0) {
+		logOutput (" [ FAILED ]\n");
+		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to kill process %d: ", pid);
+		perror (NULL);
+		exit (ERR_KILL_FAILED);
+	}
+
+	/* Wait until the process is actually killed */
+    result = existsProcess (pid);
+	for (waited=0; result == 1 && waited < timeout; waited += interval)
+	{
+		logOutput (".");
+		fflush (stdout);
+		sleep (interval);
+    	result = existsProcess (pid);
+	}
+
+	/* If the process still exists, then have no mercy and kill it */
+	forced = 0;
+	if (result == 1)
+	{
+		/* Force the process to die */
+		result = kill (pid, SIGKILL);
+		if (result == 0) {
+			forced = 1;
+			logOutput (" [ KILLED ]\n");
+			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Process %d did not terminate within %%STOP_TIMEOUT%% sec. Killed.\n", pid);
+		} else if (result != ESRCH) {
+			logOutput (" [ FAILED ]\n");
+			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to kill process %d: ", pid);
+			perror (NULL);
+			exit (ERR_KILL_FAILED);
+		}
+	}
+
+	if (forced == 0) {
+		logOutput (" [ DONE ]\n");
+	}
+}
+
+/**
+ * Starts the daemon.
+ */
+static void
+start (
+ int javaOpt,
+ char * javaArgs [],
+ int jbossOpt,
+ char * jbossArgs [])
+{
+	int i, argc;
+	char ** argv;
+	int pid;
+	int result;
+	int stdoutLogFile;
+	int stderrLogFile;
+	struct stat sb;
+
+	pid = readPID ();
+
+	logOutput (">> Starting %%APP_TITLE%% %%PORTVERSION%%...");
+	if (pid != -1)
+	{
+		/* Check if the process actually exists */
+		result = existsProcess (pid);
+		if (result == 1)
+		{
+			logOutput (" [ FAILED ]\n");
+			fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: %%APP_TITLE%% %%PORTVERSION%% is already running, PID is %d.\n", pid);
+			exit (ERR_ALREADY_RUNNING);
+		}
+	}
+
+	/* Check if the JDK home directory is actually a directory */
+	result = stat ("%%JAVA_HOME%%", &sb);
+	if (result != 0) {
+		logOutput (" [ FAILED ]\n");
+		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to stat %%JAVA_HOME%%: ");
+		perror (NULL);
+		exit (ERR_STAT_JAVA_HOME);
+	}
+	if (!S_ISDIR (sb.st_mode)) {
+		logOutput (" [ FAILED ]\n");
+		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Java home directory %%JAVA_HOME%% is not a directory.\n");
+		exit (ERR_JAVA_HOME_NOT_DIR);
+	}
+
+	/* Check if the Java command is actually an executable regular file */
+	result = stat ("%%JAVA%%", &sb);
+	if (result != 0) {
+		logOutput (" [ FAILED ]\n");
+		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to stat %%JAVA%%: ");
+		perror (NULL);
+		exit (ERR_STAT_JAVA_CMD);
+	}
+	if (!S_ISREG (sb.st_mode)) {
+		logOutput (" [ FAILED ]\n");
+		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Java command %%JAVA%% is not a regular file.\n");
+		exit (ERR_JAVA_CMD_NOT_FILE);
+	}
+	result = access ("%%JAVA%%", X_OK);
+	if (result != 0) {
+		logOutput (" [ FAILED ]\n");
+		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Java command %%JAVA%% is not executable: ");
+		perror (NULL);
+		exit (ERR_JAVA_CMD_NOT_EXECUTABLE);
+	}
+
+	/* Change directory */
+	result = chdir ("%%APP_HOME%%");
+	if (result < 0) {
+		logOutput (" [ FAILED ]\n");
+		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to access directory %%APP_HOME%%: ");
+		perror (NULL);
+		exit (ERR_CHDIR_TO_APP_HOME);
+	}
+
+	/* See if the JAR file exists */
+	result = access ("%%APP_HOME%%/%%JAR_FILE%%", R_OK);
+	if (result < 0) {
+		logOutput (" [ FAILED ]\n");
+		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to access JAR file %%APP_HOME%%/%%JAR_FILE%%: ");
+		perror (NULL);
+		exit (ERR_ACCESS_JAR_FILE);
+	}
+
+	/* Open the stdout log file */
+	stdoutLogFile = open ("%%STDOUT_LOG%%", O_WRONLY);
+	if (stdoutLogFile < 0) {
+		logOutput (" [ FAILED ]\n");
+		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to open %%STDOUT_LOG%% for writing: ");
+		perror (NULL);
+		exit (ERR_STDOUT_LOGFILE_OPEN);
+	}
+	lseek (stdoutLogFile, (off_t) 0, SEEK_END);
+
+	/* Open the stderr log file */
+	stderrLogFile = open ("%%STDERR_LOG%%", O_WRONLY);
+	if (stderrLogFile < 0) {
+		logOutput (" [ FAILED ]\n");
+		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to open %%STDERR_LOG%% for writing: ");
+		perror (NULL);
+		exit (ERR_STDERR_LOGFILE_OPEN);
+	}
+	lseek (stderrLogFile, (off_t) 0, SEEK_END);
+
+	/* Split this process in two */
+	switch (pid = fork ())
+	{
+	case -1:
+		logOutput (" [ FAILED ]\n");
+		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to fork: ");
+		perror (NULL);
+		exit (ERR_FORK_FAILED);
+		break;
+
+	case 0:
+		/* Redirect stdout to log file */
+		dup2 (stdoutLogFile, STDOUT_FILENO);
+
+		/* Redirect stderr to log file */
+		dup2 (stderrLogFile, STDERR_FILENO);
+
+		/* TODO: Support redirection of both stdout and stderr to the same
+				 file using pipe (2) */
+
+		/*
+			Build the argument vector, with the java/jboss options if any.
+		 */
+		argv = malloc (sizeof (char *) * (javaOpt + jbossOpt + 5));
+		argc = 0;
+		argv [argc++] = "%%JAVA%%";
+		for (i = 0; i < javaOpt; i++)
+			argv [argc++] = javaArgs [i];
+		argv [argc++] = "-cp";
+		argv [argc++] = "%%JAVA_CP%%";
+		argv [argc++] = "%%JAVA_MAIN%%";
+		for (i = 0; i < jbossOpt; i++)
+			argv [argc++] = jbossArgs [i];
+		argv [argc++] = NULL;
+
+		/* Execute the command */
+		execv (argv [0], argv);
+		perror (NULL);
+		break;
+
+	default:
+		logOutput (" [ DONE ]\n");
+		writePID (pid);
+	}
+}
+
+/**
+ * Stops the daemon.
+ */
+static void
+stop (void)
+{
+	int pid;
+
+	pid = readPID ();
+
+	logOutput (">> Checking if %%APP_TITLE%% %%PORTVERSION%% is running...");
+
+	/* If there is a PID, see if the process still exists */
+	if (pid != -1)
+	{
+		int result = kill (pid, 0);
+		if (result != 0 && errno == ESRCH)
+		{
+			clearPID ();
+			pid = -1;
+		}
+	}
+
+	/* If there is no running process, produce an error */
+	if (pid == -1)
+	{
+		logOutput (" [ FAILED ]\n");
+		fprintf (stderr, "%%CONTROL_SCRIPT_NAME%%: %%APP_TITLE%% %%PORTVERSION%% is currently not running.\n");
+		exit (ERR_NOT_RUNNING);
+	}
+	logOutput (" [ DONE ]\n");
+
+	/* Terminate the process */
+	killProcess (pid);
+	clearPID ();
+}
+
+
+/**
+ * Restarts the process. If it not currently running, then it will fail.
+ */
+static void
+restart (
+ int javaOpt,
+ char * javaArgs [],
+ int jbossOpt,
+ char * jbossArgs [])
+{
+	stop ();
+	start (javaOpt, javaArgs, jbossOpt, jbossArgs);
+}
+
+/**
+	Output log to stdout.
+ */
+static void
+logOutput (
+ char * string)
+{
+	if (!isQuiet)
+		printf (string);
+}
diff -ruN /usr/ports/java/jboss4/files/jboss4.sh.in ./files/jboss4.sh.in
--- /usr/ports/java/jboss4/files/jboss4.sh.in	Thu Jan  1 12:00:00 1970
+++ ./files/jboss4.sh.in	Tue Jun 19 14:26:30 2007
@@ -0,0 +1,62 @@
+#!/bin/sh
+#
+# %%APP_TITLE%% startup script.
+#
+# $FreeBSD: ports/java/jboss4/files/startup.sh,v 1.4 2006/06/13 17:43:14 glewis Exp $
+#
+
+# PROVIDE: %%APP_SHORTNAME%%
+# REQUIRE: NETWORKING SERVERS
+# KEYWORD: shutdown
+
+# Add the following lines to /etc/rc.conf to enable %%APP_SHORTNAME%%:
+# %%APP_SHORTNAME%%_enable (bool):		Set to "NO" by default.
+#				Set it to "YES" to enable %%APP_SHORTNAME%%
+# %%APP_SHORTNAME%%_flags (str):		Set to "-server" by default.
+#				Extra JVM flags.
+# %%APP_SHORTNAME%%_config (str):		Set to "" by default
+#				JBoss server config, eg {all|default|minimal|standard}
+#
+. %%RC_SUBR%%
+
+name="%%APP_SHORTNAME%%"
+rcvar=`set_rcvar`
+
+start_cmd="%%APP_SHORTNAME%%_start"
+restart_cmd="%%APP_SHORTNAME%%_restart"
+pidfile="%%PID_FILE%%"
+procname="%%JAVA%%"
+
+[ -z "$%%APP_SHORTNAME%%_enable" ]	&& %%APP_SHORTNAME%%_enable="NO"
+[ -z "$%%APP_SHORTNAME%%_flags" ]	&& %%APP_SHORTNAME%%_flags="-server"
+[ -z "$%%APP_SHORTNAME%%_config" ]	&& %%APP_SHORTNAME%%_config=""
+
+%%APP_SHORTNAME%%_start ()
+{
+	checkyesno %%APP_SHORTNAME%%_enable &&
+	{
+		if [ ! -f ${pidfile} ]
+		then
+			touch ${pidfile}
+			chown %%USER%%:%%GROUP%% ${pidfile}
+		fi
+
+		echo "Starting %%APP_SHORTNAME%%."
+		%%CONTROL_SCRIPT%% -q ${%%APP_SHORTNAME%%_flags} ${%%APP_SHORTNAME%%_configflag} ${%%APP_SHORTNAME%%_config} start
+	}
+}
+
+%%APP_SHORTNAME%%_restart ()
+{
+	checkyesno %%APP_SHORTNAME%%_enable &&
+	{
+		echo "Restarting %%APP_SHORTNAME%%."
+		%%CONTROL_SCRIPT%% -q ${%%APP_SHORTNAME%%_flags} ${%%APP_SHORTNAME%%_configflag} ${%%APP_SHORTNAME%%_config} restart
+	}
+}
+
+load_rc_config $name
+
+[ -n "${%%APP_SHORTNAME%%_config}" ] && %%APP_SHORTNAME%%_configflag="-config"
+
+run_rc_command "$1"
diff -ruN /usr/ports/java/jboss4/files/patch-ant-build ./files/patch-ant-build
--- /usr/ports/java/jboss4/files/patch-ant-build	Thu Jan  1 12:00:00 1970
+++ ./files/patch-ant-build	Tue Jun 19 14:12:01 2007
@@ -0,0 +1,45 @@
+$FreeBSD: ports/java/jboss4/files/patch-serial-autoinc,v 1.2 2005/05/18 19:36:43 hq Exp $
+
+These patches disables the ant version checks.
+
+diff -ruN /tmp/jboss-4.2.0.GA-src/tools/etc/buildmagic/build-common.xml ./tools/etc/buildmagic/build-common.xml
+--- /tmp/jboss-4.2.0.GA-src/tools/etc/buildmagic/build-common.xml	Sat May 12 06:24:27 2007
++++ ./tools/etc/buildmagic/build-common.xml	Tue Jun 19 13:56:11 2007
+@@ -9,10 +9,12 @@
+    -->
+ 
+   <condition property="buildmagic.ant.compatible">
++	<!--
+     <or>
+       <contains string="${ant.version}" 
+ 	        substring="Ant version ${buildmagic.ant16.baseversion}"/>
+     </or>
++	  -->
+   </condition>
+ 
+   <fail unless="buildmagic.ant.compatible">
+diff -ruN /tmp/jboss-4.2.0.GA-src/tools/etc/buildmagic/buildmagic.ent ./tools/etc/buildmagic/buildmagic.ent
+--- /tmp/jboss-4.2.0.GA-src/tools/etc/buildmagic/buildmagic.ent	Sat May 12 06:24:27 2007
++++ ./tools/etc/buildmagic/buildmagic.ent	Tue Jun 19 14:03:55 2007
+@@ -11,19 +11,8 @@
+   <property name="buildmagic.ant15.baseversion" value="1.5"/>
+   <property name="buildmagic.ant16.baseversion" value="1.6"/>
+   
+-  <!--
+-     | Add new conditions for other supported Ant versions when they
+-     | become avaialble.
+-   -->
+-
+-  <condition property="buildmagic.ant.compatible">
+-    <or>
+-      <contains string="${ant.version}"
+-        substring="Ant version ${buildmagic.ant15.baseversion}"/>
+-      <contains string="${ant.version}"
+-        substring="Ant version ${buildmagic.ant16.baseversion}"/>
+-    </or>
+-  </condition>
++  <!-- disable ant checks -->
++  <property name="buildmagic.ant.compatible" value="forced"/>
+ 
+   <fail unless="buildmagic.ant.compatible">
+ 
diff -ruN /usr/ports/java/jboss4/files/pkg-deinstall.in ./files/pkg-deinstall.in
--- /usr/ports/java/jboss4/files/pkg-deinstall.in	Thu Jan  1 12:00:00 1970
+++ ./files/pkg-deinstall.in	Wed Jun 13 09:25:28 2007
@@ -0,0 +1,35 @@
+#!/bin/sh
+#
+# This script does the following.
+#
+# * Checks if the JBoss PID file exists. If it does, it kills the
+#   JBoss process and removes the PID file.
+#
+# $FreeBSD: ports/java/jboss4/pkg-deinstall,v 1.2 2003/07/14 10:03:13 des Exp $
+#
+
+# Make sure we're in the right stage of the process
+if [ "$2" = "DEINSTALL" ]; then
+
+	# Kill JBoss if it is still running
+	PID_FILE=/var/run/jboss.pid
+	if [ -s ${PID_FILE} ]; then
+		PID=`cat ${PID_FILE}`
+		echo -n ">> Killing JBoss Server process (${PID})..."
+		/bin/kill ${PID} > /dev/null 2> /dev/null
+		if [ $? -eq 0 ]; then
+			echo " [ DONE ]"
+		else
+			echo " [ FAILED ]"
+		fi
+		echo -n ">> Removing PID file (${PID_FILE})..."
+		rm ${PID_FILE} > /dev/null 2> /dev/null
+		if [ $? -eq 0 ]; then
+			echo " [ DONE ]"
+		else
+			echo " [ FAILED ]"
+		fi
+	fi
+fi
+
+exit 0
diff -ruN /usr/ports/java/jboss4/files/pkg-install.in ./files/pkg-install.in
--- /usr/ports/java/jboss4/files/pkg-install.in	Thu Jan  1 12:00:00 1970
+++ ./files/pkg-install.in	Wed Jun 13 09:25:28 2007
@@ -0,0 +1,46 @@
+#!/bin/sh
+#
+# Checks if the 'www' user and group exist. If they don't, then
+# an attempt is made to create both.
+#
+# $FreeBSD: ports/java/jboss4/pkg-install,v 1.1 2002/04/26 21:54:15 znerd Exp $
+#
+
+# Make sure we're called during the 'make install' process
+if [ "$2" != "PRE-INSTALL" ]; then
+    exit 0
+fi
+
+# Set some constants
+USER=www
+GROUP=${USER}
+UID=80
+GID=${UID}
+
+# See if the group already exists
+if ! pw groupshow "${GROUP}" 2>/dev/null 1>&2; then
+
+	# If not, try to create it
+	if pw groupadd ${GROUP} -g ${GID}; then
+		echo "Added group \"${GROUP}\"."
+	else
+		echo "Adding group \"${GROUP}\" failed..."
+		exit 1
+	fi
+fi
+
+# See if the user already exists
+if ! pw usershow "${USER}" 2>/dev/null 1>&2; then
+
+	# If not, try to create it
+	if pw useradd ${USER} -u ${UID} -g ${GROUP} -h - \
+		-s "/sbin/nologin" -d "/nonexistent" \
+		-c "World Wide Web Owner"; \
+	then
+		echo "Added user \"${USER}\"."
+	else
+		echo "Adding user \"${USER}\" failed..."
+		exit 1
+	fi
+fi
+exit 0
diff -ruN /usr/ports/java/jboss4/files/pkg-message ./files/pkg-message
--- /usr/ports/java/jboss4/files/pkg-message	Thu Dec 23 09:44:23 2004
+++ ./files/pkg-message	Thu Jan  1 12:00:00 1970
@@ -1,7 +0,0 @@
-%%PKGNAME%% has been installed in %%APP_HOME%%.
-
-If a user should be able to use %%CONTROL_SCRIPT_NAME%%, put it in the group '%%GROUP%%'.
-
-Use 'man %%CONTROL_SCRIPT_NAME%%' for information about starting and stopping %%APP_TITLE%%.
-
-To run the %%APP_TITLE%% server from startup, add %%APP_SHORTNAME%%_enable="YES" in your /etc/rc.conf. Extra options can be found in the startup script.
diff -ruN /usr/ports/java/jboss4/files/pkg-message.in ./files/pkg-message.in
--- /usr/ports/java/jboss4/files/pkg-message.in	Thu Jan  1 12:00:00 1970
+++ ./files/pkg-message.in	Wed Jun 13 09:25:28 2007
@@ -0,0 +1,7 @@
+%%PKGNAME%% has been installed in %%APP_HOME%%.
+
+If a user should be able to use %%CONTROL_SCRIPT_NAME%%, put it in the group '%%GROUP%%'.
+
+Use 'man %%CONTROL_SCRIPT_NAME%%' for information about starting and stopping %%APP_TITLE%%.
+
+To run the %%APP_TITLE%% server from startup, add %%APP_SHORTNAME%%_enable="YES" in your /etc/rc.conf. Extra options can be found in the startup script.
diff -ruN /usr/ports/java/jboss4/files/startup.sh ./files/startup.sh
--- /usr/ports/java/jboss4/files/startup.sh	Wed Jun 14 18:47:19 2006
+++ ./files/startup.sh	Thu Jan  1 12:00:00 1970
@@ -1,61 +0,0 @@
-#!/bin/sh
-#
-# %%APP_TITLE%% startup script.
-#
-# $FreeBSD: ports/java/jboss4/files/startup.sh,v 1.4 2006/06/13 17:43:14 glewis Exp $
-#
-
-# PROVIDE: %%APP_SHORTNAME%%
-# REQUIRE: NETWORKING SERVERS
-
-# Add the following lines to /etc/rc.conf to enable %%APP_SHORTNAME%%:
-# %%APP_SHORTNAME%%_enable (bool):		Set to "NO" by default.
-#				Set it to "YES" to enable %%APP_SHORTNAME%%
-# %%APP_SHORTNAME%%_flags (str):		Set to "-server" by default.
-#				Extra JVM flags.
-# %%APP_SHORTNAME%%_config (str):		Set to "" by default
-#				JBoss server config, eg {all|default|minimal|standard}
-#
-. %%RC_SUBR%%
-
-name="%%APP_SHORTNAME%%"
-rcvar=`set_rcvar`
-
-start_cmd="%%APP_SHORTNAME%%_start"
-restart_cmd="%%APP_SHORTNAME%%_restart"
-pidfile="%%PID_FILE%%"
-procname="%%JAVA%%"
-
-[ -z "$%%APP_SHORTNAME%%_enable" ]	&& %%APP_SHORTNAME%%_enable="NO"
-[ -z "$%%APP_SHORTNAME%%_flags" ]	&& %%APP_SHORTNAME%%_flags="-server"
-[ -z "$%%APP_SHORTNAME%%_config" ]	&& %%APP_SHORTNAME%%_config=""
-
-%%APP_SHORTNAME%%_start ()
-{
-	checkyesno %%APP_SHORTNAME%%_enable &&
-	{
-		if [ ! -f ${pidfile} ]
-		then
-			touch ${pidfile}
-			chown %%USER%%:%%GROUP%% ${pidfile}
-		fi
-
-		echo "Starting %%APP_SHORTNAME%%."
-		%%CONTROL_SCRIPT%% -q ${%%APP_SHORTNAME%%_flags} ${%%APP_SHORTNAME%%_configflag} ${%%APP_SHORTNAME%%_config} start
-	}
-}
-
-%%APP_SHORTNAME%%_restart ()
-{
-	checkyesno %%APP_SHORTNAME%%_enable &&
-	{
-		echo "Restarting %%APP_SHORTNAME%%."
-		%%CONTROL_SCRIPT%% -q ${%%APP_SHORTNAME%%_flags} ${%%APP_SHORTNAME%%_configflag} ${%%APP_SHORTNAME%%_config} restart
-	}
-}
-
-load_rc_config $name
-
-[ -n "${%%APP_SHORTNAME%%_config}" ] && %%APP_SHORTNAME%%_configflag="-config"
-
-run_rc_command "$1"
diff -ruN /usr/ports/java/jboss4/pkg-deinstall ./pkg-deinstall
--- /usr/ports/java/jboss4/pkg-deinstall	Mon Jul 14 22:03:13 2003
+++ ./pkg-deinstall	Thu Jan  1 12:00:00 1970
@@ -1,35 +0,0 @@
-#!/bin/sh
-#
-# This script does the following.
-#
-# * Checks if the JBoss PID file exists. If it does, it kills the
-#   JBoss process and removes the PID file.
-#
-# $FreeBSD: ports/java/jboss4/pkg-deinstall,v 1.2 2003/07/14 10:03:13 des Exp $
-#
-
-# Make sure we're in the right stage of the process
-if [ "$2" = "DEINSTALL" ]; then
-
-	# Kill JBoss if it is still running
-	PID_FILE=/var/run/jboss.pid
-	if [ -s ${PID_FILE} ]; then
-		PID=`cat ${PID_FILE}`
-		echo -n ">> Killing JBoss Server process (${PID})..."
-		/bin/kill ${PID} > /dev/null 2> /dev/null
-		if [ $? -eq 0 ]; then
-			echo " [ DONE ]"
-		else
-			echo " [ FAILED ]"
-		fi
-		echo -n ">> Removing PID file (${PID_FILE})..."
-		rm ${PID_FILE} > /dev/null 2> /dev/null
-		if [ $? -eq 0 ]; then
-			echo " [ DONE ]"
-		else
-			echo " [ FAILED ]"
-		fi
-	fi
-fi
-
-exit 0
diff -ruN /usr/ports/java/jboss4/pkg-install ./pkg-install
--- /usr/ports/java/jboss4/pkg-install	Sat Apr 27 09:54:15 2002
+++ ./pkg-install	Thu Jan  1 12:00:00 1970
@@ -1,46 +0,0 @@
-#!/bin/sh
-#
-# Checks if the 'www' user and group exist. If they don't, then
-# an attempt is made to create both.
-#
-# $FreeBSD: ports/java/jboss4/pkg-install,v 1.1 2002/04/26 21:54:15 znerd Exp $
-#
-
-# Make sure we're called during the 'make install' process
-if [ "$2" != "PRE-INSTALL" ]; then
-    exit 0
-fi
-
-# Set some constants
-USER=www
-GROUP=${USER}
-UID=80
-GID=${UID}
-
-# See if the group already exists
-if ! pw groupshow "${GROUP}" 2>/dev/null 1>&2; then
-
-	# If not, try to create it
-	if pw groupadd ${GROUP} -g ${GID}; then
-		echo "Added group \"${GROUP}\"."
-	else
-		echo "Adding group \"${GROUP}\" failed..."
-		exit 1
-	fi
-fi
-
-# See if the user already exists
-if ! pw usershow "${USER}" 2>/dev/null 1>&2; then
-
-	# If not, try to create it
-	if pw useradd ${USER} -u ${UID} -g ${GROUP} -h - \
-		-s "/sbin/nologin" -d "/nonexistent" \
-		-c "World Wide Web Owner"; \
-	then
-		echo "Added user \"${USER}\"."
-	else
-		echo "Adding user \"${USER}\" failed..."
-		exit 1
-	fi
-fi
-exit 0
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list