2012-06-16 07:18:01 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# This script provides systemd activation of the tomcat service
|
|
|
|
# To create clones of this service:
|
2012-07-17 16:23:06 +02:00
|
|
|
# 1) Create /etc/tomcat/${SERVICE_NAME}.conf from /etc/tomcat/tomcat.conf
|
|
|
|
# to override tomcat defaults and add the EnvironmentFile=
|
|
|
|
# 2) Change the location of PIDFile=
|
2012-06-16 07:18:01 +02:00
|
|
|
|
2012-07-17 16:23:06 +02:00
|
|
|
#### from /usr/sbin/dtomcat
|
|
|
|
if [[ -r /usr/share/java-utils/java-functions ]]; then
|
|
|
|
. /usr/share/java-utils/java-functions
|
2012-06-16 07:18:01 +02:00
|
|
|
else
|
2012-07-17 16:23:06 +02:00
|
|
|
echo "Can't read Java functions library, aborting" >&2
|
|
|
|
exit 1
|
2012-06-16 07:18:01 +02:00
|
|
|
fi
|
|
|
|
|
2012-07-17 16:23:06 +02:00
|
|
|
set_javacmd
|
|
|
|
|
|
|
|
# CLASSPATH munging
|
|
|
|
if [[ -n "$JSSE_HOME" ]]; then
|
|
|
|
CLASSPATH="${CLASSPATH}:$(build-classpath jcert jnet jsse 2>/dev/null)"
|
2012-06-16 07:18:01 +02:00
|
|
|
fi
|
2012-07-17 16:23:06 +02:00
|
|
|
CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/bootstrap.jar"
|
|
|
|
CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/tomcat-juli.jar"
|
|
|
|
CLASSPATH="${CLASSPATH}:$(build-classpath commons-daemon 2>/dev/null)"
|
2012-06-16 07:18:01 +02:00
|
|
|
|
|
|
|
# See how we were called.
|
|
|
|
function start() {
|
|
|
|
|
2012-07-17 16:23:06 +02:00
|
|
|
local ret
|
|
|
|
|
|
|
|
# running as root is not recommended in any case!
|
|
|
|
if [[ $(id -u) == 0 ]]; then
|
|
|
|
echo "ERROR: starting tomcat under uid 0 is not supported" >&2
|
|
|
|
echo " use appropriate User/Group settings in service file" >&2
|
|
|
|
echo " see man systemd.exec for details" >&2
|
|
|
|
exit 2
|
2012-06-16 07:18:01 +02:00
|
|
|
fi
|
|
|
|
|
2012-07-17 16:23:06 +02:00
|
|
|
if [[ "$SECURITY_MANAGER" = "true" ]]; then
|
|
|
|
DSECURITY_MANAGER="-Djava.security.manager"
|
2012-06-16 07:18:01 +02:00
|
|
|
else
|
2012-07-17 16:23:06 +02:00
|
|
|
unset DSECURITY_MANAGER
|
2012-06-16 07:18:01 +02:00
|
|
|
fi
|
2012-07-17 16:23:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
${JAVACMD} $JAVA_OPTS $CATALINA_OPTS \
|
|
|
|
-classpath "$CLASSPATH" \
|
|
|
|
-Dcatalina.base="$CATALINA_BASE" \
|
|
|
|
-Dcatalina.home="$CATALINA_HOME" \
|
|
|
|
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \
|
|
|
|
-Djava.io.tmpdir="$CATALINA_TMPDIR" ${DSECURITY_MANAGER} \
|
|
|
|
-Djava.util.logging.config.file="${CATALINA_BASE}/conf/logging.properties" \
|
|
|
|
-Djava.util.logging.manager="org.apache.juli.ClassLoaderLogManager" \
|
|
|
|
org.apache.catalina.startup.Bootstrap start
|
|
|
|
ret=${?}
|
|
|
|
|
|
|
|
return $ret
|
2012-06-16 07:18:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function stop() {
|
2012-07-17 16:23:06 +02:00
|
|
|
|
|
|
|
local ret
|
|
|
|
|
|
|
|
${JAVACMD} $JAVA_OPTS \
|
|
|
|
-classpath "$CLASSPATH" \
|
|
|
|
-Dcatalina.base="$CATALINA_BASE" \
|
|
|
|
-Dcatalina.home="$CATALINA_HOME" \
|
|
|
|
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \
|
|
|
|
-Djava.io.tmpdir="$CATALINA_TMPDIR" \
|
|
|
|
org.apache.catalina.startup.Bootstrap stop
|
|
|
|
ret=${?}
|
|
|
|
|
|
|
|
if [[ ret == 143 ]]; then
|
|
|
|
ret=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
return $ret
|
|
|
|
}
|
|
|
|
|
|
|
|
function version() {
|
|
|
|
|
|
|
|
exec ${JAVACMD} -classpath ${CATALINA_HOME}/lib/catalina.jar \
|
|
|
|
org.apache.catalina.util.ServerInfo
|
|
|
|
|
2012-06-16 07:18:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# See how we were called.
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
;;
|
2012-07-17 16:23:06 +02:00
|
|
|
version)
|
|
|
|
version
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: $0 {start|stop|restart|version}" >&2
|
|
|
|
exit 1
|
2012-06-16 07:18:01 +02:00
|
|
|
esac
|
|
|
|
|