perfsonar-dev - perfsonar: r3679 - branches/rpm/specs
Subject: perfsonar development work
List archive
- From:
- To:
- Subject: perfsonar: r3679 - branches/rpm/specs
- Date: Tue, 15 Apr 2008 11:16:01 -0400
Author: gijs
Date: 2008-04-15 11:16:00 -0400 (Tue, 15 Apr 2008)
New Revision: 3679
Modified:
branches/rpm/specs/perfsonar-tomcat.sh
Log:
modified to perfection
Modified: branches/rpm/specs/perfsonar-tomcat.sh
===================================================================
--- branches/rpm/specs/perfsonar-tomcat.sh 2008-04-15 14:53:10 UTC (rev
3678)
+++ branches/rpm/specs/perfsonar-tomcat.sh 2008-04-15 15:16:00 UTC (rev
3679)
@@ -1,42 +1,114 @@
#!/bin/sh
+#
+# /etc/init.d/perfsonar-tomcat -- startup script for the PerfSONAR Tomcat
servlet engine
+#
+# written by Gijs Molenaar
<>
+#
-DAEMON=/opt/perfsonar/tomcat/bin/jsvc
+set -e
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
NAME=perfsonar-tomcat
-USER=perfsonar
+DESC="Perfsonar Tomcat servlet engine"
CATALINA_HOME=/opt/perfsonar/tomcat
-JSVC_CLASSPATH=$CATALINA_HOME/bin/commons-daemon.jar:$CATALINA_HOME/bin/bootstrap.jar
-CATALINA_PID=/var/run/$NAME.pid
+DAEMON=$CATALINA_HOME/bin/jsvc
+TOMCAT_USER=perfsonar
+TOMCAT_SECURITY=no
+
+if [ `id -u` -ne 0 ]; then
+ echo "You need root privileges to run this script"
+ exit 1
+fi
+
+#. /lib/lsb/init-functions
+#. /etc/init.d/functions
+
+
+# The first existing directory is used for JAVA_HOME
+JDK_DIRS="/usr/java /usr/lib/jvm/java-6-sun /usr/lib/jvm/java-1.5.0-sun
/usr/lib/j2sdk1.5-sun /usr/lib/jvm/java /usr/lib/jvm/java-gcj"
+
+# Look for the right JVM to use
+for jdir in $JDK_DIRS; do
+ if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
+ JAVA_HOME_TMP="$jdir"
+ # checks for a real JDK like environment, needed to check if
+ # really the java-gcj-compat-dev package is installed
+ if [ -r "$jdir/bin/jdb" ]; then
+ JAVA_HOME="$JAVA_HOME_TMP"
+ fi
+ fi
+done
+export JAVA_HOME
+
+
+# Check if we use gij
+gij=no
+"$JAVA_HOME/bin/java" -version 2>&1 | grep -q "^gij (GNU libgcj)" && gij=yes
+
+# gij doesn't support a security manager yet (see bug #399595)
+if [ "$gij" = "yes" ]; then
+ echo -e "The java-gcj-compat-dev environment currently doesn't\nsupport
a security manager." | logger -p daemon.warning -t $NAME
+fi
+
+# 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 "$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_HOME -Dcatalina.home=$CATALINA_HOME
-Djava.io.tmpdir=$CATALINA_HOME/temp"
+
+if [ "$TOMCAT_SECURITY" = "yes" ]; then
+ JAVA_OPTS="$JAVA_OPTS -Djava.security.manager
-Djava.security.policy=$CATALINA_HOME/conf/catalina.policy"
+fi
+
+# juli LogManager disabled if running under gij (see bug #395167)
+if [ "$gij" != "yes" ]; then
+ JAVA_OPTS="$JAVA_OPTS
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=$CATALINA_HOME/conf/logging.properties"
+fi
+
+# Define other required variables
+CATALINA_PID="/var/run/$NAME.pid"
BOOTSTRAP_CLASS=org.apache.catalina.startup.Bootstrap
-JAVA_HOME=/usr/lib/jvm/jre
+JSVC_CLASSPATH="/usr/share/java/commons-daemon.jar:$CATALINA_HOME/bin/bootstrap.jar"
-#JAVA_OPTS="-Djava.awt.headless=true -Xmx128M -Dcatalina.base=$CATALINA_BASE
-Dcatalina.home=$CATALINA_HOME -Djava.io.tmpdir=$CATALINA_BASE/temp
-Djava.security.manager
-Djava.security.policy=$CATALINA_BASE/conf/catalina.policy"
-case $1 in
- start)
- echo "starting tomcat..."
- c="$DAEMON -home $JAVA_HOME -user $USER -cp $JSVC_CLASSPATH -outfile
$CATALINA_HOME/logs/jsvc.log -errfile $CATALINA_HOME/logs/jsvc.err \
- -pidfile $CATALINA_PID $JAVA_OPTS $BOOTSTRAP_CLASS"
- #echo $c
- $c
+case "$1" in
+ start)
+ if [ -z "$JAVA_HOME" ]; then
+ echo "no JDK found - please set JAVA_HOME"
+ exit 1
+ fi
- exit 0
- ;;
- stop)
- echo "stopping tomcat..."
- $DAEMON -cp $JSVC_CLASSPATH -pidfile $CATALINA_PID -stop
$BOOTSTRAP_CLASS
- exit 0
- ;;
- restart)
- $0 stop
- sleep 1
- $0 start
- exit 0
- ;;
-
- *)
- echo "Usage: $0 {start|stop|restart}"
- exit 1
- ;;
+ if [ ! -d "$CATALINA_HOME/conf" ]; then
+ echo "invalid CATALINA_HOME specified"
+ exit 1
+ fi
+
+ echo "Starting $DESC" "$NAME"
+ $DAEMON -user "$TOMCAT_USER" -cp "$JSVC_CLASSPATH" \
+ -outfile $CATALINA_HOME/logs/jsvc.log -errfile
$CATALINA_HOME/logs/jsvc.err \
+ -pidfile "$CATALINA_PID" $JAVA_OPTS "$BOOTSTRAP_CLASS"
+ ;;
+
+ stop)
+ echo "Stopping $DESC" "$NAME"
+ $DAEMON -cp "$JSVC_CLASSPATH" -pidfile "$CATALINA_PID" \
+ -stop "$BOOTSTRAP_CLASS"
+ ;;
+
+ restart|force-reload)
+ $0 stop
+ sleep 1
+ $0 start
+ ;;
+
+ *)
+ echo "Usage: $0 {start|stop|restart}"
+ exit 1
+ ;;
esac
exit 0
- perfsonar: r3679 - branches/rpm/specs, svnlog, 04/15/2008
Archive powered by MHonArc 2.6.16.