[pkg-java] r2791 - branches/tomcat5.5/feature/debian/debian

Marcus Better marcusb-guest at alioth.debian.org
Thu Nov 23 13:58:48 CET 2006


Author: marcusb-guest
Date: 2006-11-23 13:58:47 +0100 (Thu, 23 Nov 2006)
New Revision: 2791

Modified:
   branches/tomcat5.5/feature/debian/debian/tomcat5.5.init
Log:
Don't forget to set java.io.tmpdir.


Modified: branches/tomcat5.5/feature/debian/debian/tomcat5.5.init
===================================================================
--- branches/tomcat5.5/feature/debian/debian/tomcat5.5.init	2006-11-23 09:06:54 UTC (rev 2790)
+++ branches/tomcat5.5/feature/debian/debian/tomcat5.5.init	2006-11-23 12:58:47 UTC (rev 2791)
@@ -23,8 +23,8 @@
 PATH=/bin:/usr/bin:/sbin:/usr/sbin
 NAME=tomcat5.5
 DESC="Tomcat servlet engine"
+DAEMON=/usr/bin/jsvc
 CATALINA_HOME=/usr/share/$NAME
-DAEMON=$CATALINA_HOME/bin/catalina.sh
 DEFAULT=/etc/default/$NAME
 
 . /lib/lsb/init-functions
@@ -72,42 +72,53 @@
 done
 export JAVA_HOME
 
-# Set java.awt.headless=true if CATALINA_OPTS is not set so the
+# Set java.awt.headless=true if JAVA_OPTS is not set so the
 # Xalan XSL transformer can work without X11 display on JDK 1.4+
 # It also looks like the default heap size of 64M is not enough for most cases
 # se the maximum heap size is set to 128M
-if [ -z "$CATALINA_OPTS" ]; then
-	CATALINA_OPTS="-Djava.awt.headless=true -Xmx128M"
+if [ -z "$JAVA_OPTS" ]; then
+	JAVA_OPTS="-Djava.awt.headless=true -Xmx128M"
 fi
 
+JAVA_OPTS="$JAVA_OPTS -Djava.endorsed.dirs=$CATALINA_HOME/common/endorsed -Dcatalina.base=$CATALINA_BASE -Dcatalina.home=$CATALINA_HOME -Djava.io.tmpdir=$CATALINA_BASE/temp"
+
 # Set the JSP compiler if set in the tomcat5.5.default file
 if [ -n "$JSP_COMPILER" ]; then
-	CATALINA_OPTS="$CATALINA_OPTS -Dbuild.compiler=$JSP_COMPILER"
+	JAVA_OPTS="$JAVA_OPTS -Dbuild.compiler=$JSP_COMPILER"
 fi
 
-# Define other required variables
-CATALINA_PID="$CATALINA_BASE/temp/$NAME.pid"
-STARTUP_OPTS=""
 if [ "$TOMCAT5_SECURITY" = "yes" ]; then
-	STARTUP_OPTS="-security"
+	JAVA_OPTS="$JAVA_OPTS -Djava.security.manager -Djava.security.policy=$CATALINA_BASE/conf/catalina.policy"
 fi
 
+# juli LogManager disabled if running under libgcj (see bug #395167)
+gcj=no
+"$JAVA_HOME/bin/java" -version 2>&1 | grep -q "^gij (GNU libgcj)" && gcj=yes
+if [ "$gcj" != "yes" ]; then
+  JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties"
+fi
+
+# Define other required variables
+CATALINA_PID="/var/run/$NAME.pid"
+LOGFILE="$CATALINA_BASE/logs/catalina.out"
+BOOTSTRAP_CLASS=org.apache.catalina.startup.Bootstrap
+JSVC_CLASSPATH="/usr/share/java/commons-daemon.jar:$CATALINA_HOME/bin/bootstrap.jar"
+
 # Look for Java Secure Sockets Extension (JSSE) JARs
 if [ -z "${JSSE_HOME}" -a -r "${JAVA_HOME}/jre/lib/jsse.jar" ]; then
     JSSE_HOME="${JAVA_HOME}/jre/"
 fi
+export JSSE_HOME
 
-export CATALINA_HOME CATALINA_BASE CATALINA_OPTS CATALINA_PID JSSE_HOME
-
 case "$1" in
   start)
 	if [ -z "$JAVA_HOME" ]; then
-		log_failure_msg "Not starting Tomcat: no Java Development Kit found."
+		log_failure_msg "no JDK found - please set JAVA_HOME"
 		exit 1
 	fi
 
 	if [ ! -d "$CATALINA_BASE/conf" ]; then
-		log_failure_msg "Not starting Tomcat: invalid CATALINA_BASE specified."
+		log_failure_msg "invalid CATALINA_BASE specified"
 		exit 1
 	fi
 
@@ -128,30 +139,16 @@
 			>> "$CATALINA_BASE/conf/catalina.policy"
 
 		# Clean up and set permissions on required files
-		rm -rf "$CATALINA_BASE"/temp/* \
-			"$CATALINA_BASE/logs/catalina.out"
-		mkfifo -m700 "$CATALINA_BASE/logs/catalina.out"
+		rm -rf "$CATALINA_BASE"/temp/*
 		chown --dereference "$TOMCAT5_USER" "$CATALINA_BASE/conf" \
 			"$CATALINA_BASE/conf/tomcat-users.xml" \
 			"$CATALINA_BASE/logs" "$CATALINA_BASE/temp" \
 			"$CATALINA_BASE/webapps" "$CATALINA_BASE/work" \
 			"$CATALINA_BASE/logs/catalina.out" || true
 
-		# Look for rotatelogs/rotatelogs2
-		if [ -x /usr/sbin/rotatelogs ]; then
-			ROTATELOGS=/usr/sbin/rotatelogs
-		else
-			ROTATELOGS=/usr/sbin/rotatelogs2
-		fi
-
-		# -p preserves the environment (for $JAVA_HOME etc.)
-		# -s is required because tomcat5.5's login shell is /bin/false
-		su -p -s /bin/sh $TOMCAT5_USER \
-				-c "$ROTATELOGS \"$CATALINA_BASE/logs/catalina_%F.log\" 86400" \
-				< "$CATALINA_BASE/logs/catalina.out" &
-		su -p -s /bin/sh $TOMCAT5_USER \
-			-c "\"$DAEMON\" start $STARTUP_OPTS" \
-			>> "$CATALINA_BASE/logs/catalina.out" 2>&1
+		$DAEMON -user "$TOMCAT5_USER" -cp "$JSVC_CLASSPATH" \
+		    -outfile "$LOGFILE"  -errfile '&1' \
+		    -pidfile "$CATALINA_PID" $JAVA_OPTS "$BOOTSTRAP_CLASS"
 	else
 	        log_progress_msg "(already running)"
 	fi
@@ -164,24 +161,8 @@
 		>/dev/null; then
 		log_progress_msg "(not running)"
 	else
-		su -p -s /bin/sh $TOMCAT5_USER -c "\"$DAEMON\" stop" \
-			>/dev/null 2>&1 || true
-		# Fallback to kill the JVM process in case stopping didn't work
-		sleep 1
-		while ! start-stop-daemon --test --start \
-			--pidfile "$CATALINA_PID" --user "$TOMCAT5_USER" \
-			--startas "$JAVA_HOME/bin/java" >/dev/null; do
-			sleep 1
-			log_progress_msg "."
-			TOMCAT5_SHUTDOWN=`expr $TOMCAT5_SHUTDOWN - 1` || true
-			if [ $TOMCAT5_SHUTDOWN -le 0 ]; then
-				log_progress_msg "(killing)"
-				start-stop-daemon --stop --signal 9 --oknodo \
-					--quiet --pidfile "$CATALINA_PID" \
-					--user "$TOMCAT5_USER"
-			fi
-		done
-		rm -f "$CATALINA_PID" "$CATALINA_BASE/logs/catalina.out"
+		$DAEMON -cp "$JSVC_CLASSPATH" -pidfile "$CATALINA_PID" \
+		     -stop -wait "$TOMCAT5_SHUTDOWN" "$BOOTSTRAP_CLASS"
 	fi
 	log_end_msg 0
 	;;




More information about the pkg-java-commits mailing list