blob: 54ea0fcebc141f522988503a4e8929e4ea85332f [file] [log] [blame]
Cheng Tang697ce242014-04-27 16:18:17 +08001#!/bin/sh
2
3# Licensed to the Apache Software Foundation (ASF) under one or more
4# contributor license agreements. See the NOTICE file distributed with
5# this work for additional information regarding copyright ownership.
6# The ASF licenses this file to You under the Apache License, Version 2.0
7# (the "License"); you may not use this file except in compliance with
8# the License. You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17
18# -----------------------------------------------------------------------------
19# Wrapper script for command line tools
20#
21# Environment Variable Prerequisites
22#
23# CATALINA_HOME May point at your Catalina "build" directory.
24#
25# TOOL_OPTS (Optional) Java runtime options.
26#
27# JAVA_HOME Must point at your Java Development Kit installation.
28# Using JRE_HOME instead works as well.
29#
30# JRE_HOME Must point at your Java Runtime installation.
31# Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME
32# are both set, JRE_HOME is used.
33#
34# JAVA_OPTS (Optional) Java runtime options.
35#
36# JAVA_ENDORSED_DIRS (Optional) Lists of of colon separated directories
37# containing some jars in order to allow replacement of APIs
38# created outside of the JCP (i.e. DOM and SAX from W3C).
39# It can also be used to update the XML parser implementation.
刘洪青8d26a3c2018-02-28 18:16:21 +080040# Note that Java 9 no longer supports this feature.
Cheng Tang697ce242014-04-27 16:18:17 +080041# Defaults to $CATALINA_HOME/endorsed.
Cheng Tang697ce242014-04-27 16:18:17 +080042# -----------------------------------------------------------------------------
43
44# OS specific support. $var _must_ be set to either true or false.
45cygwin=false
46darwin=false
47os400=false
48case "`uname`" in
49CYGWIN*) cygwin=true;;
50Darwin*) darwin=true;;
51OS400*) os400=true;;
52esac
53
54# resolve links - $0 may be a softlink
55PRG="$0"
56
57while [ -h "$PRG" ]; do
58 ls=`ls -ld "$PRG"`
59 link=`expr "$ls" : '.*-> \(.*\)$'`
60 if expr "$link" : '/.*' > /dev/null; then
61 PRG="$link"
62 else
63 PRG=`dirname "$PRG"`/"$link"
64 fi
65done
66
67# Get standard environment variables
68PRGDIR=`dirname "$PRG"`
69
70# Only set CATALINA_HOME if not already set
71[ -z "$CATALINA_HOME" ] && CATALINA_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`
72
73# Ensure that any user defined CLASSPATH variables are not used on startup,
74# but allow them to be specified in setenv.sh, in rare case when it is needed.
75CLASSPATH=
76
77if [ -r "$CATALINA_HOME/bin/setenv.sh" ]; then
78 . "$CATALINA_HOME/bin/setenv.sh"
79fi
80
81# For Cygwin, ensure paths are in UNIX format before anything is touched
82if $cygwin; then
83 [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
84 [ -n "$JRE_HOME" ] && JRE_HOME=`cygpath --unix "$JRE_HOME"`
85 [ -n "$CATALINA_HOME" ] && CATALINA_HOME=`cygpath --unix "$CATALINA_HOME"`
86 [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
87fi
88
89# For OS400
90if $os400; then
91 # Set job priority to standard for interactive (interactive - 6) by using
92 # the interactive priority - 6, the helper threads that respond to requests
93 # will be running at the same priority as interactive jobs.
94 COMMAND='chgjob job('$JOBNAME') runpty(6)'
95 system $COMMAND
96
97 # Enable multi threading
98 export QIBM_MULTI_THREADED=Y
99fi
100
101# Get standard Java environment variables
102if $os400; then
103 # -r will Only work on the os400 if the files are:
104 # 1. owned by the user
105 # 2. owned by the PRIMARY group of the user
106 # this will not work if the user belongs in secondary groups
107 . "$CATALINA_HOME"/bin/setclasspath.sh
108else
109 if [ -r "$CATALINA_HOME"/bin/setclasspath.sh ]; then
110 . "$CATALINA_HOME"/bin/setclasspath.sh
111 else
112 echo "Cannot find $CATALINA_HOME/bin/setclasspath.sh"
113 echo "This file is needed to run this program"
114 exit 1
115 fi
116fi
117
118# Add on extra jar files to CLASSPATH
119if [ ! -z "$CLASSPATH" ] ; then
120 CLASSPATH="$CLASSPATH":
121fi
122CLASSPATH="$CLASSPATH""$CATALINA_HOME"/bin/bootstrap.jar:"$CATALINA_HOME"/bin/tomcat-juli.jar:"$CATALINA_HOME"/lib/servlet-api.jar
123
124# For Cygwin, switch paths to Windows format before running java
125if $cygwin; then
126 JAVA_HOME=`cygpath --absolute --windows "$JAVA_HOME"`
127 JRE_HOME=`cygpath --absolute --windows "$JRE_HOME"`
128 CATALINA_HOME=`cygpath --absolute --windows "$CATALINA_HOME"`
129 CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
130 JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
131fi
132
刘洪青8d26a3c2018-02-28 18:16:21 +0800133# Java 9 no longer supports the java.endorsed.dirs
134# system property. Only try to use it if
135# JAVA_ENDORSED_DIRS was explicitly set
136# or CATALINA_HOME/endorsed exists.
137ENDORSED_PROP=ignore.endorsed.dirs
138if [ -n "$JAVA_ENDORSED_DIRS" ]; then
139 ENDORSED_PROP=java.endorsed.dirs
140fi
141if [ -d "$CATALINA_HOME/endorsed" ]; then
142 ENDORSED_PROP=java.endorsed.dirs
143fi
144
Cheng Tang697ce242014-04-27 16:18:17 +0800145JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
146
147# ----- Execute The Requested Command -----------------------------------------
148
149exec "$_RUNJAVA" $JAVA_OPTS $TOOL_OPTS \
刘洪青8d26a3c2018-02-28 18:16:21 +0800150 -D$ENDORSED_PROP="$JAVA_ENDORSED_DIRS" \
151 -classpath "$CLASSPATH" \
Cheng Tang697ce242014-04-27 16:18:17 +0800152 -Dcatalina.home="$CATALINA_HOME" \
153 org.apache.catalina.startup.Tool "$@"