[45135] trunk/dports/java

ricci at macports.org ricci at macports.org
Thu Jan 8 14:31:40 PST 2009


Revision: 45135
          http://trac.macports.org/changeset/45135
Author:   ricci at macports.org
Date:     2009-01-08 14:31:40 -0800 (Thu, 08 Jan 2009)
Log Message:
-----------
First cut at a tomcat6 port.  This was copied from tomcat5 and hacked up
to "work" for installing tomcat6.  It could probably use some attention from
someone who has a better understanding of the right way to install tomcat6

Added Paths:
-----------
    trunk/dports/java/tomcat6/
    trunk/dports/java/tomcat6/Portfile
    trunk/dports/java/tomcat6/files/
    trunk/dports/java/tomcat6/files/conf_setup.sh
    trunk/dports/java/tomcat6/files/patch-bin-catalina.sh
    trunk/dports/java/tomcat6/files/patch-build.properties.default
    trunk/dports/java/tomcat6/files/patch-build.xml.diff
    trunk/dports/java/tomcat6/files/patch-catalina.sh
    trunk/dports/java/tomcat6/files/setenv.local
    trunk/dports/java/tomcat6/files/setenv.sh
    trunk/dports/java/tomcat6/files/tomcat6.sh
    trunk/dports/java/tomcat6/files/tomcatctl

Added: trunk/dports/java/tomcat6/Portfile
===================================================================
--- trunk/dports/java/tomcat6/Portfile	                        (rev 0)
+++ trunk/dports/java/tomcat6/Portfile	2009-01-08 22:31:40 UTC (rev 45135)
@@ -0,0 +1,258 @@
+# $Id$
+
+PortSystem 1.0
+
+name				tomcat6
+version				6.0.18
+
+categories			java www
+maintainers			ricci openmaintainer
+platforms			darwin
+
+description			Tomcat 6 HTTP Server and Java Servlet Container.
+long_description	Tomcat is the servlet container that is used in the official \
+					Reference Implementation for the Java Servlet and JavaServer \
+					Pages technologies.
+homepage			http://tomcat.apache.org/
+
+distname			apache-tomcat-${version}-src
+master_sites		apache:tomcat/tomcat-6/v${version}/src/
+
+checksums           md5     9bdbb1c1d79302c80057a70b18fe6721 \
+                    sha1    9182b0d6b2d0cb2d60f04be6211f3b3516bc518e \
+                    rmd160  ef85db0d65a4f3bdd3ca821420d06535050b6a93
+
+					
+patchfiles			patch-bin-catalina.sh	\
+					patch-build.xml.diff
+
+depends_build		bin:ant:apache-ant
+depends_lib			bin:java:kaffe \
+					bin:jsvc:commons-daemon \
+					port:jakarta-taglibs-standard-11 \
+					port:commons-beanutils \
+					port:commons-collections \
+					port:commons-launcher \
+					port:commons-daemon \
+					port:commons-digester \
+					port:commons-el \
+					port:commons-logging \
+					port:commons-modeler \
+					port:commons-httpclient \
+					port:commons-pool \
+					port:commons-dbcp \
+					port:commons-fileupload \
+					port:commons-io \
+					port:jakarta-regexp \
+					port:xercesj \
+					port:jakarta-log4j \
+					port:mx4j \
+					port:junit \
+					port:jaxen \
+					port:saxpath
+				
+## worksrcdir			${distname}
+
+set javaLibs		${prefix}/share/java
+set home			share/java/tomcat6
+set tomcatuser		www
+set tomcatgroup		www
+
+use_configure		no
+
+build.cmd			ant
+build.target		download 
+set antArgs		 [join "
+					-Dbase.path=${worksrcpath}/Repository
+					-Dnsis.exe=${worksrcpath}/.bogus
+					-Dcommons-beanutils.jar=${javaLibs}/commons-beanutils.jar
+					-Dcommons-collections.jar=${javaLibs}/commons-collections.jar
+					-Dcommons-launcher.jar=${javaLibs}/commons-launcher.jar
+					-Dcommons-daemon.jar=${javaLibs}/commons-daemon.jar
+					-Dcommons-digester.jar=${javaLibs}/commons-digester.jar
+					-Dcommons-el.jar=${javaLibs}/commons-el.jar
+					-Dcommons-logging.jar=${javaLibs}/commons-logging.jar
+					-Dcommons-logging-api.jar=${javaLibs}/commons-logging-api.jar
+					-Dcommons-modeler.jar=${javaLibs}/commons-modeler.jar
+					-Dcommons-httpclient.jar=${javaLibs}/commons-httpclient.jar
+					-Dcommons-pool.jar=${javaLibs}/commons-pool.jar
+					-Dcommons-dbcp.jar=${javaLibs}/commons-dbcp.jar
+					-Dcommons-fileupload.jar=${javaLibs}/commons-fileupload.jar
+					-Dregexp.jar=${javaLibs}/jakarta-regexp.jar
+					-DxercesImpl.jar=${javaLibs}/xercesImpl.jar
+					-Dxml-apis.jar=${javaLibs}/xml-apis.jar
+					-Dlog4j.jar=${javaLibs}/jakarta-log4j.jar
+					-Djmx.lib=${javaLibs}
+					-Djunit.jar=${javaLibs}/junit.jar
+					-Djaxen.jar=${javaLibs}/jaxen.jar
+					-Dsaxpath.jar=${javaLibs}/saxpath.jar
+					-Djasper.home=${worksrcpath}/../jasper
+					"]
+#					-Dstruts.lib=${javaLibs}/struts/lib
+
+build.args			$antArgs
+
+## # Remove compatibility for pre-JRE 1.5 systems
+## variant nocompat {
+## 	build.target-delete compat
+## }
+
+pre-build {
+	#
+	# Tomcat in this version requires ant 1.6.5.
+	# If the current version of ant is not at least 1.6.5 then
+	# tell the user and fail.
+	#
+	if { [string length [auto_execok ant]] } {
+		set verOutput [exec ant -version]
+		regexp {version (\d+(\.\d+)*)} $verOutput -> antVersion
+		if { [rpm-vercomp $antVersion "1.6.5"] < 0 } {
+			return -code error "This version of tomcat requires ant version 1.6.5 or better. Please install a newer ant before proceeding."
+		}
+	}
+
+	# Make a bogus file to prevent nsis.exe from downloading
+#	system "touch ${worksrcpath}/.bogus"
+}
+
+destroot {
+	set target ${destroot}${prefix}/${home}
+	xinstall -m 755 -d ${target}
+
+	# Ensure we've got needed directories
+	ui_msg "# setting up needed dirs"
+	xinstall -m 755 -d \
+		${destroot}${prefix}/share/java \
+		${destroot}${prefix}/share/doc \
+		${destroot}${prefix}/etc/rc.d
+		
+	# Create the tomcat user
+	addgroup ${tomcatgroup}
+	set gid [existsgroup ${tomcatgroup}]
+	adduser ${tomcatuser} gid=${gid} realname=Web Server
+	
+	# Install Tomcat
+	ui_msg "# installing tomcat..."
+## 	file copy ${worksrcpath}/bin/ ${destroot}/${prefix}/bin
+## 	file copy ${worksrcpath}/bin ${target}
+##  	system "cd ${worksrcpath} &&  ant $antArgs deploy"
+ 	system "cd ${worksrcpath} &&  ant $antArgs deploy"
+	## build space:
+ 	file copy ${worksrcpath}/output/build/bin ${target}
+ 	file copy ${worksrcpath}/output/build/conf ${target}
+ 	file copy ${worksrcpath}/output/build/lib ${target}
+ 	file copy ${worksrcpath}/output/build/temp ${target}
+ 	file copy ${worksrcpath}/output/build/webapps ${target}
+	## and classes:
+ 	file copy ${worksrcpath}/output/classes ${target}/shared/
+	
+## 	# Add compat files as needed
+## 	if { ! [variant_isset nocompat] } {
+## 		system "tar -cf - -C ${worksrcpath}/compat . | tar xpf - -C ${target}"
+## 	}
+	
+	# Add the jstl libs to tomcat6/shared/lib so that they're available to all
+	ui_msg "# adding the jstl libs "
+	xinstall -m 755 -d ${target}/shared/lib
+	xinstall -m 644 \
+		${prefix}/share/java/jstl.jar \
+		${prefix}/share/java/standard.jar \
+		${target}/shared/lib
+		
+	# Remove unwanted files
+	foreach f [glob -directory ${target}/bin *.bat] { file delete $f }
+	
+	# Maintain empty directories
+	ui_msg "# maint. empty dirs... "
+	xinstall -m 755 -d ${target}/work
+	xinstall -m 755 -d ${target}/logs
+	destroot.keepdirs-append \
+		${target}/logs \
+		${target}/temp \
+		${target}/work \
+		${target}/shared/classes \
+		${target}/common/classes
+		
+	# Install our scripts
+	ui_msg "# adding our scripts "
+	xinstall -m 755 \
+		${filespath}/tomcatctl \
+		${filespath}/conf_setup.sh \
+		${filespath}/setenv.sh \
+		${target}/bin
+	ui_msg "# adding our scripts 2"
+	xinstall -m 755 \
+		${filespath}/setenv.local \
+		${target}/conf
+	
+	# Don't install startup script, as we're now generating a startupitem
+	#xinstall -m 755 ${filespath}/tomcat6.sh \
+	#	${destroot}${prefix}/etc/rc.d
+	#reinplace s|TOMCATPREFIX=$|TOMCATPREFIX=${prefix}/${home}| ${destroot}${prefix}/etc/rc.d/tomcat6.sh
+		
+	# Add a symlink from bin directory to tomcatctl
+	system "cd ${destroot}${prefix}/bin && ln -s ../${home}/bin/tomcatctl"
+	
+	# Configure the scripts
+	reinplace s|PREFIX=$|PREFIX=${prefix}| ${target}/bin/tomcatctl
+	reinplace s|TOMCAT_USER=$|TOMCAT_USER=${tomcatuser}| ${target}/bin/tomcatctl
+	
+	# Rename certain files as .sample to avoid replacing them on update
+	# These will be "repaired" by conf_setup.sh on first run
+	foreach f 	"
+				catalina.policy
+				catalina.properties
+				server.xml
+				tomcat-users.xml
+				web.xml
+				setenv.local
+				" {
+		file rename ${target}/conf/${f} ${target}/conf/${f}.sample
+	}
+
+	# Fix ownership of some directories tomcat really needs to write to
+	system "chown -R ${tomcatuser}:${tomcatgroup} \
+		${target}/conf \
+		${target}/logs \
+		${target}/temp \
+		${target}/webapps \
+		${target}/work"
+	
+	# Install the docs
+	file copy ${worksrcpath}/webapps/docs \
+		${destroot}${prefix}/share/doc/${name}
+}
+
+
+post-install {
+	ui_msg "#"
+	ui_msg "# Configuration files in ${prefix}/${home}/conf have been"
+	ui_msg "# installed with a .sample extension so that they won't be replaced by a"
+	ui_msg "# port update. Each will be copied to its proper location during the"
+	ui_msg "# first startup of tomcat by catalina.sh or tomcatctl if you don't"
+	ui_msg "# do this yourself first. If this _is_ an update, you might do a diff to"
+	ui_msg "# verify that you're not missing anything in the newer .sample versions"
+	ui_msg "# of these files."
+	ui_msg "#"
+	ui_msg "# The script ${prefix}/${home}/bin/tomcatctl has been installed to"
+	ui_msg "# facilitate start and stop of tomcat using the jsvc utility, which allows you to"
+	ui_msg "# start tomcat as a true daemon process. Once tomcat has acquired its TCP socket,"
+	ui_msg "# jsvc will drop its root privileges and run as user ${tomcatuser}."
+	ui_msg "#"
+	ui_msg "# Under Apple Java, control over the Java version used to launch ${name} is"
+	ui_msg "# through the shell variable JAVA_JVM_VERSION. This variable should be set"
+	ui_msg "# to a java version such as 1.4, 1.5, or CurrentJDK (for the default version)."
+	ui_msg "# You may set JAVA_JVM_VERSION in ${prefix}/${home}/bin/setenv.sh."
+	ui_msg "#"
+}
+
+
+startupitem.create		yes
+startupitem.executable	"${prefix}/bin/tomcatctl" start
+startupitem.pidfile		clean "${prefix}/share/java/tomcat6/logs/${name}.pid"
+
+
+livecheck.check regex
+livecheck.url   ${homepage}/download-60.cgi
+livecheck.regex "apache-tomcat-(\\d+\\.\\d+(\\.\\d+)?)-src.tar.gz"
+


Property changes on: trunk/dports/java/tomcat6/Portfile
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: trunk/dports/java/tomcat6/files/conf_setup.sh
===================================================================
--- trunk/dports/java/tomcat6/files/conf_setup.sh	                        (rev 0)
+++ trunk/dports/java/tomcat6/files/conf_setup.sh	2009-01-08 22:31:40 UTC (rev 45135)
@@ -0,0 +1,47 @@
+#!/bin/sh
+#
+# conf_setup.sh
+#
+# This file performs a self-repair sanity check on the tomcat configuration files.
+# Any critical files that are missing will be replaced by sample files. This is 
+# particularly useful in first-run situations.
+#
+# Note that no effort is made to ensure the validity of file contents.
+#
+
+PRG=`basename $0`
+
+# Look for $CATALINA_BASE
+if [ -z "$CATALINA_BASE" -o ! -d "$CATALINA_BASE" ]; then
+	echo "$PRG: CATALINA_BASE must be set in my environment"
+	exit 1
+fi
+
+# Look for $CATALINA_BASE/conf
+CONF="${CATALINA_BASE}/conf"
+if [ ! -d "${CONF}" ]; then
+	echo "$PRG: ${CONF} directory not found!"
+	exit 1
+fi
+
+CONF_FILES=" \
+	conf/catalina.policy \
+	conf/catalina.properties \
+	conf/server.xml \
+	conf/tomcat-users.xml \
+	conf/web.xml \
+	conf/setenv.local \
+	"
+
+# Try to repair any needed files in conf
+for FILE in $CONF_FILES; do
+	SAMPLE="${FILE}.sample"
+	if [ ! -f "${CATALINA_BASE}/${FILE}" ]; then
+		if [ ! -f "${CATALINA_BASE}/${SAMPLE}" ]; then
+			echo "$PRG: file ${FILE} is missing, but no corresponding ${SAMPLE} file was found to repair it!"
+		else
+			echo "$PRG: file ${FILE} is missing; copying ${SAMPLE} to its place."
+			cp -p "${CATALINA_BASE}/${SAMPLE}" "${CATALINA_BASE}/${FILE}"
+		fi
+	fi
+done


Property changes on: trunk/dports/java/tomcat6/files/conf_setup.sh
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/dports/java/tomcat6/files/patch-bin-catalina.sh
===================================================================
--- trunk/dports/java/tomcat6/files/patch-bin-catalina.sh	                        (rev 0)
+++ trunk/dports/java/tomcat6/files/patch-bin-catalina.sh	2009-01-08 22:31:40 UTC (rev 45135)
@@ -0,0 +1,14 @@
+--- bin/catalina.sh.orig	2009-01-02 11:57:54.000000000 -0800
++++ bin/catalina.sh	2009-01-02 11:58:16.000000000 -0800
+@@ -185,6 +185,11 @@
+   LOGGING_CONFIG="-Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties"
+ fi
+ 
++# Run conf_setup.sh to check and repair the conf directory
++if [ -x "$CATALINA_HOME/bin/conf_setup.sh" ]; then
++       CATALINA_BASE="$CATALINA_BASE" "$CATALINA_HOME/bin/conf_setup.sh"
++fi
++
+ # ----- Execute The Requested Command -----------------------------------------
+ 
+ # Bugzilla 37848: only output this if we have a TTY

Added: trunk/dports/java/tomcat6/files/patch-build.properties.default
===================================================================
--- trunk/dports/java/tomcat6/files/patch-build.properties.default	                        (rev 0)
+++ trunk/dports/java/tomcat6/files/patch-build.properties.default	2009-01-08 22:31:40 UTC (rev 45135)
@@ -0,0 +1,11 @@
+--- ../build/build.properties.default.orig	2006-09-12 11:12:23.000000000 -0400
++++ ../build/build.properties.default	2006-11-06 20:48:16.000000000 -0500
+@@ -138,7 +138,7 @@
+ jdt.home=${base.path}/eclipse/plugins
+ jdt.lib=${jdt.home}
+ jdt.jar=${jdt.lib}/org.eclipse.jdt.core_3.1.2.jar
+-jdt.loc=http://sunsite.informatik.rwth-aachen.de/eclipse/downloads/drops/R-3.1.2-200601181600/eclipse-JDT-3.1.2.zip
++jdt.loc=http://archive.eclipse.org/eclipse/downloads/drops/R-3.1.2-200601181600/eclipse-JDT-3.1.2.zip
+ 
+ 
+ # ----- Tomcat native library -----

Added: trunk/dports/java/tomcat6/files/patch-build.xml.diff
===================================================================
--- trunk/dports/java/tomcat6/files/patch-build.xml.diff	                        (rev 0)
+++ trunk/dports/java/tomcat6/files/patch-build.xml.diff	2009-01-08 22:31:40 UTC (rev 45135)
@@ -0,0 +1,11 @@
+--- build.xml.orig	2008-07-21 17:01:29.000000000 -0700
++++ build.xml	2009-01-02 17:00:38.000000000 -0800
+@@ -471,7 +471,7 @@
+             file="${tomcat-native.tar.gz}" />
+ 
+     <copy todir="${tomcat.build}/bin" file="${commons-daemon.jar}" />
+-    <copy todir="${tomcat.build}/bin" file="${commons-daemon.jsvc.tar.gz}" />
++  <!---  <copy todir="${tomcat.build}/bin" file="${commons-daemon.jsvc.tar.gz}" /> -->
+ 
+   	<!-- Copy scripts -->
+     <copy todir="${tomcat.build}/bin">

Added: trunk/dports/java/tomcat6/files/patch-catalina.sh
===================================================================
--- trunk/dports/java/tomcat6/files/patch-catalina.sh	                        (rev 0)
+++ trunk/dports/java/tomcat6/files/patch-catalina.sh	2009-01-08 22:31:40 UTC (rev 45135)
@@ -0,0 +1,14 @@
+--- ../container/catalina/src/bin/catalina.sh.orig	2005-09-23 06:45:08.000000000 -0700
++++ ../container/catalina/src/bin/catalina.sh	2005-10-25 12:54:10.000000000 -0700
+@@ -146,6 +146,11 @@
+   JAVA_OPTS="$JAVA_OPTS "-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" "-Djava.util.logging.config.file="$CATALINA_BASE/conf/logging.properties"
+ fi
+ 
++# Run conf_setup.sh to check and repair the conf directory
++if [ -x "$CATALINA_HOME/bin/conf_setup.sh" ]; then
++	CATALINA_BASE="$CATALINA_BASE" "$CATALINA_HOME/bin/conf_setup.sh"
++fi
++
+ # ----- Execute The Requested Command -----------------------------------------
+ 
+ echo "Using CATALINA_BASE:   $CATALINA_BASE"

Added: trunk/dports/java/tomcat6/files/setenv.local
===================================================================
--- trunk/dports/java/tomcat6/files/setenv.local	                        (rev 0)
+++ trunk/dports/java/tomcat6/files/setenv.local	2009-01-08 22:31:40 UTC (rev 45135)
@@ -0,0 +1,12 @@
+#!/bin/sh
+#
+# setenv.local
+#
+# This script, if present, is executed by tomcatctl through setenv.sh
+# in order to set up any environment prior to executation of tomcat.
+#
+
+# For Apple Java, JAVA_JVM_VERSION may be used to specify a particular
+# java version to run. It should be something like 1.4, 1.5, or CurrentJDK.
+#export JAVA_JVM_VERSION=1.5
+

Added: trunk/dports/java/tomcat6/files/setenv.sh
===================================================================
--- trunk/dports/java/tomcat6/files/setenv.sh	                        (rev 0)
+++ trunk/dports/java/tomcat6/files/setenv.sh	2009-01-08 22:31:40 UTC (rev 45135)
@@ -0,0 +1,47 @@
+#!/bin/sh
+#
+# setenv.sh
+#
+# You may edit this script to set defaults for such variables as JAVA_HOME.
+#
+# For Apple Java, the $JAVA_HOME is not well respected by the JNI launching code
+# in jsvc. On Apple Java systems, you are better off setting JAVA_JVM_VERSION
+# to the proper java name, such as 1.4, 1.5, or CurrentJDK, and let JAVA_HOME
+# be calculated from that.
+#
+
+# First source the conf/setenv.local file to allow user to configure environment
+# in an even more minimal fashion.
+if [ -r "$CATALINA_HOME/conf/setenv.local" ]; then
+    . "$CATALINA_HOME/conf/setenv.local"
+fi
+
+# Attempt to set JAVA_HOME if it's not already set
+if [ -z "$JAVA_HOME" ]; then
+	
+	# Set JAVA_JVM_VERSION and JAVA_HOME for Darwin
+	if [ `uname -s` = "Darwin" ]; then
+	
+		# To specify that a particular Java version be run, set it here
+		#export JAVA_JVM_VERSION=1.5
+	
+		# Look for a java version specified by JAVA_JVM_VERSION, falling back to current version
+		# Set JAVA_HOME to reflect the version
+		for jversion in $JAVA_JVM_VERSION CurrentJDK ; do
+			jhome="/System/Library/Frameworks/JavaVM.framework/Versions/${jversion}/Home"
+			if [ -z "$JAVA_HOME" -a -d "${jhome}" ]; then
+				# Get the actual version that any symlink points to, since
+				# jni doesn't like JAVA_JVM_VERSION set to CurrentJDK
+				saved=`pwd`
+				cd "/System/Library/Frameworks/JavaVM.framework/Versions/${jversion}"
+				actualvers=$(basename $(pwd -P))
+				cd $saved
+				
+				export JAVA_JVM_VERSION=${actualvers}
+				export JAVA_HOME=${jhome}
+			fi
+		done
+		
+	fi
+	
+fi


Property changes on: trunk/dports/java/tomcat6/files/setenv.sh
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/dports/java/tomcat6/files/tomcat6.sh
===================================================================
--- trunk/dports/java/tomcat6/files/tomcat6.sh	                        (rev 0)
+++ trunk/dports/java/tomcat6/files/tomcat6.sh	2009-01-08 22:31:40 UTC (rev 45135)
@@ -0,0 +1,17 @@
+#!/bin/sh
+TOMCATPREFIX=
+TOMCATCTL=${TOMCATPREFIX}/bin/tomcatctl
+
+case "$1" in
+start)
+	[ -x ${TOMCATCTL} ] && ${TOMCATCTL} start > /dev/null && echo -n ' tomcat5'
+	;;
+stop)
+	[ -x ${TOMCATCTL} ] && ${TOMCATCTL} stop > /dev/null && echo -n ' tomcat5'
+	;;
+*)
+	echo "Usage: `basename $0` {start|stop}" >&2
+	;;
+esac
+
+exit 0

Added: trunk/dports/java/tomcat6/files/tomcatctl
===================================================================
--- trunk/dports/java/tomcat6/files/tomcatctl	                        (rev 0)
+++ trunk/dports/java/tomcat6/files/tomcatctl	2009-01-08 22:31:40 UTC (rev 45135)
@@ -0,0 +1,235 @@
+#!/bin/sh
+#
+#	tomcatctl
+#
+#	Tomcat control script to control tomcat running under jsvc.
+#
+#	USAGE: tomcatctl [--jdpa] start|stop|restart|status|info
+#
+
+# To be customized by installer...
+PREFIX=
+TOMCAT_USER=
+
+WC=wc
+JSVC="$PREFIX/bin/jsvc"
+#JSVC_ENV=
+#JSVC_DEBUG="-debug -verbose"
+
+
+# Calculate CATALINA_HOME based on our location
+if [ -z "$CATALINA_HOME" ]; then
+    # Handle symlinks
+    PRG="$0"    
+    while [ -L "$PRG" ]; do
+        ls=`ls -ld "$PRG"`
+        link=`expr "$ls" : '.*-> \(.*\)$'`
+        if expr "$link" : '/.*' > /dev/null; then
+            PRG="$link"
+        else
+            PRG="`dirname $PRG`/$link"
+        fi
+    done
+    
+    pushd "`dirname \"$PRG\"`/.." > /dev/null
+    CATALINA_HOME="`pwd -P`"
+    popd > /dev/null
+fi
+
+# Source the setenv.sh file to allow user to configure environment
+# including JAVA_HOME
+if [ -r "$CATALINA_HOME/bin/setenv.sh" ]; then
+    . "$CATALINA_HOME/bin/setenv.sh"
+fi
+
+# Source the setclasspath.sh file to allow setup of the CLASSPATH variable
+BASEDIR="$CATALINA_HOME"
+. "$CATALINA_HOME/bin/setclasspath.sh"
+
+# Set variable default values
+[ -z "$CATALINA_BASE" ]     	&& CATALINA_BASE="${CATALINA_HOME}"
+[ -z "$CATALINA_TMPDIR" ]   	&& CATALINA_TMPDIR="${CATALINA_BASE}/temp"
+
+[ -z "$TOMCAT_PIDNAME" ]    	&& TOMCAT_PIDNAME="tomcat5.pid"
+[ -z "$TOMCAT_PIDFILE" ]    	&& TOMCAT_PIDFILE="${CATALINA_BASE}/logs/${TOMCAT_PIDNAME}"
+[ -z "$TOMCAT_USER" ]       	&& TOMCAT_USER=tomcat
+
+[ -z "$JAVA_ENDORSED_DIRS" ]	&& JAVA_ENDORSED_DIRS=${CATALINA_BASE}/common/endorsed
+
+[ -z "$JPDA_TRANSPORT" ]    	&& JPDA_TRANSPORT=dt_socket
+[ -z "$JPDA_ADDRESS" ]      	&& JPDA_ADDRESS=8000
+
+CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jar:"$CATALINA_HOME"/bin/commons-logging-api.jar
+
+if [ -r "${CATALINA_HOME}/bin/tomcat-juli.jar" ]; then
+  JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
+fi
+
+usage()
+{
+    cat <<EOT
+USAGE: `basename $0` [--jpda] start|stop|restart|status|info
+EOT
+}
+
+
+check()
+{
+    PID=
+    RUNNING=
+    STATUS=
+    
+    if [ -f "$TOMCAT_PIDFILE" ]; then
+        PID=`cat $TOMCAT_PIDFILE`
+        if [ -n "$PID" -a `ps $PID | $WC -l` -gt 1 ]; then
+            STATUS="running (pid $PID)"
+            RUNNING=$PID
+        else
+            STATUS="not running (stale pid $PID?)"
+            RUNNING=
+        fi
+    else
+        STATUS="not running"
+        RUNNING=
+    fi
+}
+
+
+start()
+{
+	# Run conf_setup.sh to check and repair the conf directory
+	if [ -x "$CATALINA_HOME/bin/conf_setup.sh" ]; then
+		CATALINA_BASE="$CATALINA_BASE" "$CATALINA_HOME/bin/conf_setup.sh"
+	fi
+
+    printf "Starting Tomcat..."
+    check
+    
+    if [ -n "$RUNNING" ]; then
+        printf "already $STATUS\n"
+    else
+        # Remove any existing pid file
+        rm -f "$TOMCAT_PIDFILE"
+        
+        # Start Tomcat using jsvc
+        $JSVC_ENV $JSVC $JSVC_DEBUG $JAVA_OPTS $JPDA_OPTS \
+            -home "$JAVA_HOME" \
+            -user "$TOMCAT_USER" \
+            -classpath "${CLASSPATH}" \
+            -pidfile "$TOMCAT_PIDFILE" \
+            -outfile "$CATALINA_BASE/logs/catalina.out" \
+            -errfile "$CATALINA_BASE/logs/catalina.err" \
+            -Dcatalina.home="$CATALINA_HOME" \
+            -Dcatalina.base="$CATALINA_BASE" \
+            -Djava.io.tmpdir="$CATALINA_TMPDIR" \
+            -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \
+            org.apache.catalina.startup.Bootstrap "$@" start
+            
+        # Wait for it to really start
+        for ((CNT=0; CNT < 15; ++CNT)); do
+            [ -f "$TOMCAT_PIDFILE" ] && break
+            printf "."
+            sleep 1
+        done
+        
+        # Let 'em know what happened
+        check
+        if [ -n "$RUNNING" ]; then
+            printf " started. (pid $PID)\n"
+        else
+            printf " giving up.\n"
+        fi
+    fi
+}
+
+
+stop()
+{
+    printf "Stopping Tomcat..."
+    check
+    
+    if [ -z "$RUNNING" ]; then
+        printf "already $STATUS\n"
+    else
+        printf "(pid $PID)"
+        
+        # Stop Tomcat
+        kill $PID
+        
+        # Wait for it to really stop
+        for ((CNT=0; CNT < 15; ++CNT)); do
+            [ -f "$TOMCAT_PIDFILE" ] || break
+            printf "."
+            sleep 1
+        done
+        
+        # Let 'em know what happened
+        check
+        if [ -z "$RUNNING" ]; then
+            printf " stopped.\n"
+        else
+            printf " giving up.\n"
+        fi
+    fi
+}
+
+
+# Ensure at least one parameter
+if [ $# -lt 1 ]; then
+   usage
+   exit 1
+fi
+
+# Parameter Handling
+while [ $# -gt 0 ]; do
+	case "$1" in
+	--jpda)
+		[ -z "$JPDA_OPTS" ] && JPDA_OPTS="-Xdebug -Xrunjdwp:transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=n"
+		;;
+		
+	start)
+		start
+		;;
+		
+	stop)
+		stop
+		;;
+		
+	restart)
+		stop
+		start
+		;;
+		
+	status)
+		check
+		printf "Tomcat is $STATUS\n"
+		;;
+		
+	info)
+		check
+		cat <<EOT
+	
+Tomcat is $STATUS
+
+CATALINA_HOME       $CATALINA_HOME
+CATALINA_BASE       $CATALINA_BASE
+CATALINA_TMPDIR     $CATALINA_TMPDIR
+JAVA_HOME           $JAVA_HOME
+CLASSPATH           $CLASSPATH
+TOMCAT_PIDFILE      $TOMCAT_PIDFILE
+JAVA_OPTS           $JAVA_OPTS
+JPDA_OPTS           $JPDA_OPTS
+EOT
+		;;
+		
+	*)
+		printf "$0: unrecognized option '$1'\n"
+		usage
+		exit 1
+		;;
+	esac
+	
+	shift
+done
+
+


Property changes on: trunk/dports/java/tomcat6/files/tomcatctl
___________________________________________________________________
Added: svn:executable
   + *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090108/b4894697/attachment-0001.html>


More information about the macports-changes mailing list