blob: 54ea0fcebc141f522988503a4e8929e4ea85332f [file] [log] [blame]
Hongqing Liufd5ee812014-05-10 16:32:51 +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#
刘洪青6266f992017-05-15 21:21:03 +080023# CATALINA_HOME May point at your Catalina "build" directory.
Hongqing Liufd5ee812014-05-10 16:32:51 +080024#
刘洪青6266f992017-05-15 21:21:03 +080025# TOOL_OPTS (Optional) Java runtime options.
Hongqing Liufd5ee812014-05-10 16:32:51 +080026#
刘洪青6266f992017-05-15 21:21:03 +080027# JAVA_HOME Must point at your Java Development Kit installation.
28# Using JRE_HOME instead works as well.
Hongqing Liufd5ee812014-05-10 16:32:51 +080029#
刘洪青6266f992017-05-15 21:21:03 +080030# 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.
刘洪青a78cd382018-03-01 14:48:24 +080040# Note that Java 9 no longer supports this feature.
刘洪青6266f992017-05-15 21:21:03 +080041# Defaults to $CATALINA_HOME/endorsed.
Hongqing Liufd5ee812014-05-10 16:32:51 +080042# -----------------------------------------------------------------------------
43
44# OS specific support. $var _must_ be set to either true or false.
45cygwin=false
刘洪青6266f992017-05-15 21:21:03 +080046darwin=false
47os400=false
Hongqing Liufd5ee812014-05-10 16:32:51 +080048case "`uname`" in
49CYGWIN*) cygwin=true;;
刘洪青6266f992017-05-15 21:21:03 +080050Darwin*) darwin=true;;
51OS400*) os400=true;;
Hongqing Liufd5ee812014-05-10 16:32:51 +080052esac
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"`
刘洪青6266f992017-05-15 21:21:03 +080069
70# Only set CATALINA_HOME if not already set
71[ -z "$CATALINA_HOME" ] && CATALINA_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`
Hongqing Liufd5ee812014-05-10 16:32:51 +080072
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
刘洪青6266f992017-05-15 21:21:03 +080077if [ -r "$CATALINA_HOME/bin/setenv.sh" ]; then
78 . "$CATALINA_HOME/bin/setenv.sh"
Hongqing Liufd5ee812014-05-10 16:32:51 +080079fi
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"`
刘洪青6266f992017-05-15 21:21:03 +080084 [ -n "$JRE_HOME" ] && JRE_HOME=`cygpath --unix "$JRE_HOME"`
Hongqing Liufd5ee812014-05-10 16:32:51 +080085 [ -n "$CATALINA_HOME" ] && CATALINA_HOME=`cygpath --unix "$CATALINA_HOME"`
86 [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
87fi
88
刘洪青6266f992017-05-15 21:21:03 +080089# 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
Hongqing Liufd5ee812014-05-10 16:32:51 +0800101# Get standard Java environment variables
刘洪青6266f992017-05-15 21:21:03 +0800102if $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
Hongqing Liufd5ee812014-05-10 16:32:51 +0800107 . "$CATALINA_HOME"/bin/setclasspath.sh
108else
刘洪青6266f992017-05-15 21:21:03 +0800109 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
Hongqing Liufd5ee812014-05-10 16:32:51 +0800116fi
117
118# Add on extra jar files to CLASSPATH
刘洪青6266f992017-05-15 21:21:03 +0800119if [ ! -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
Hongqing Liufd5ee812014-05-10 16:32:51 +0800123
124# For Cygwin, switch paths to Windows format before running java
125if $cygwin; then
刘洪青6266f992017-05-15 21:21:03 +0800126 JAVA_HOME=`cygpath --absolute --windows "$JAVA_HOME"`
127 JRE_HOME=`cygpath --absolute --windows "$JRE_HOME"`
128 CATALINA_HOME=`cygpath --absolute --windows "$CATALINA_HOME"`
Hongqing Liufd5ee812014-05-10 16:32:51 +0800129 CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
刘洪青6266f992017-05-15 21:21:03 +0800130 JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
Hongqing Liufd5ee812014-05-10 16:32:51 +0800131fi
132
刘洪青a78cd382018-03-01 14:48:24 +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
刘洪青6266f992017-05-15 21:21:03 +0800145JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
146
Hongqing Liufd5ee812014-05-10 16:32:51 +0800147# ----- Execute The Requested Command -----------------------------------------
148
149exec "$_RUNJAVA" $JAVA_OPTS $TOOL_OPTS \
刘洪青a78cd382018-03-01 14:48:24 +0800150 -D$ENDORSED_PROP="$JAVA_ENDORSED_DIRS" \
151 -classpath "$CLASSPATH" \
Hongqing Liufd5ee812014-05-10 16:32:51 +0800152 -Dcatalina.home="$CATALINA_HOME" \
153 org.apache.catalina.startup.Tool "$@"