1 |
#!/bin/bash |
2 |
|
3 |
if [ -r /usr/share/java-utils/java-functions ]; then |
4 |
. /usr/share/java-utils/java-functions |
5 |
else |
6 |
echo "Can't read Java functions library, aborting" |
7 |
exit 1 |
8 |
fi |
9 |
|
10 |
# Get the tomcat config (use this for environment specific settings) |
11 |
#if [ -z "${TOMCAT_CFG}" ]; then |
12 |
# TOMCAT_CFG="/etc/tomcat/tomcat.conf" |
13 |
#fi |
14 |
|
15 |
#if [ -r "$TOMCAT_CFG" ]; then |
16 |
# . $TOMCAT_CFG |
17 |
#fi |
18 |
|
19 |
set_javacmd |
20 |
|
21 |
# CLASSPATH munging |
22 |
if [ -n "$JSSE_HOME" ]; then |
23 |
CLASSPATH="${CLASSPATH}:$(build-classpath jcert jnet jsse 2>/dev/null)" |
24 |
fi |
25 |
CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/bootstrap.jar" |
26 |
CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/tomcat-juli.jar" |
27 |
CLASSPATH="${CLASSPATH}:$(build-classpath commons-daemon 2>/dev/null)" |
28 |
|
29 |
# if jsvc installed and USE_JSVC=true |
30 |
# then use jsvc instead of calling java directly |
31 |
if [ -x /usr/bin/jsvc ]; then |
32 |
JAVACMD="/usr/bin/jsvc -nodetach -user ${TOMCAT_USER} -outfile ${CATALINA_BASE}/logs/catalina.out -errfile ${CATALINA_BASE}/logs/catalina.out" |
33 |
if [ "$1" = "stop" ]; then |
34 |
JAVACMD="${JAVACMD} -stop" |
35 |
fi |
36 |
fi |
37 |
|
38 |
if [ "$1" = "start" ]; then |
39 |
${JAVACMD} $JAVA_OPTS $CATALINA_OPTS \ |
40 |
-classpath "$CLASSPATH" \ |
41 |
-Dcatalina.base="$CATALINA_BASE" \ |
42 |
-Dcatalina.home="$CATALINA_HOME" \ |
43 |
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \ |
44 |
-Djava.io.tmpdir="$CATALINA_TMPDIR" \ |
45 |
-Djava.util.logging.config.file="${CATALINA_BASE}/conf/logging.properties" \ |
46 |
-Djava.util.logging.manager="org.apache.juli.ClassLoaderLogManager" \ |
47 |
org.apache.catalina.startup.Bootstrap start \ |
48 |
>> ${CATALINA_BASE}/logs/catalina.out 2>&1 & |
49 |
if [ ! -z "$CATALINA_PID" ]; then |
50 |
echo $! > $CATALINA_PID |
51 |
fi |
52 |
elif [ "$1" = "start-security" ]; then |
53 |
${JAVACMD} $JAVA_OPTS $CATALINA_OPTS \ |
54 |
-classpath "$CLASSPATH" \ |
55 |
-Dcatalina.base="$CATALINA_BASE" \ |
56 |
-Dcatalina.home="$CATALINA_HOME" \ |
57 |
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \ |
58 |
-Djava.io.tmpdir="$CATALINA_TMPDIR" \ |
59 |
-Djava.security.manager \ |
60 |
-Djava.security.policy=="${CATALINA_BASE}/conf/catalina.policy" \ |
61 |
-Djava.util.logging.config.file="${CATALINA_BASE}/conf/logging.properties" \ |
62 |
-Djava.util.logging.manager="org.apache.juli.ClassLoaderLogManager" \ |
63 |
org.apache.catalina.startup.Bootstrap start \ |
64 |
>> ${CATALINA_BASE}/logs/catalina.out 2>&1 & |
65 |
if [ ! -z "$CATALINA_PID" ]; then |
66 |
echo $! > $CATALINA_PID |
67 |
fi |
68 |
elif [ "$1" = "stop" ]; then |
69 |
${JAVACMD} $JAVA_OPTS \ |
70 |
-classpath "$CLASSPATH" \ |
71 |
-Dcatalina.base="$CATALINA_BASE" \ |
72 |
-Dcatalina.home="$CATALINA_HOME" \ |
73 |
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \ |
74 |
-Djava.io.tmpdir="$CATALINA_TMPDIR" \ |
75 |
org.apache.catalina.startup.Bootstrap stop \ |
76 |
>> ${CATALINA_BASE}/logs/catalina.out 2>&1 |
77 |
elif [ "$1" = "version" ]; then |
78 |
${JAVACMD} -classpath ${CATALINA_HOME}/lib/catalina.jar \ |
79 |
org.apache.catalina.util.ServerInfo |
80 |
else |
81 |
echo "Usage: $0 {start|start-security|stop|version}" |
82 |
exit 1 |
83 |
fi |