blob: 8979209b9b286f649455cb73985bc95f2b766aa5 [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.
40# Defaults to $CATALINA_HOME/endorsed.
41#
42# $Id: tool-wrapper.sh 1138835 2011-06-23 11:27:57Z rjung $
43# -----------------------------------------------------------------------------
44
45# OS specific support. $var _must_ be set to either true or false.
46cygwin=false
47darwin=false
48os400=false
49case "`uname`" in
50CYGWIN*) cygwin=true;;
51Darwin*) darwin=true;;
52OS400*) os400=true;;
53esac
54
55# resolve links - $0 may be a softlink
56PRG="$0"
57
58while [ -h "$PRG" ]; do
59 ls=`ls -ld "$PRG"`
60 link=`expr "$ls" : '.*-> \(.*\)$'`
61 if expr "$link" : '/.*' > /dev/null; then
62 PRG="$link"
63 else
64 PRG=`dirname "$PRG"`/"$link"
65 fi
66done
67
68# Get standard environment variables
69PRGDIR=`dirname "$PRG"`
70
71# Only set CATALINA_HOME if not already set
72[ -z "$CATALINA_HOME" ] && CATALINA_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`
73
74# Ensure that any user defined CLASSPATH variables are not used on startup,
75# but allow them to be specified in setenv.sh, in rare case when it is needed.
76CLASSPATH=
77
78if [ -r "$CATALINA_HOME/bin/setenv.sh" ]; then
79 . "$CATALINA_HOME/bin/setenv.sh"
80fi
81
82# For Cygwin, ensure paths are in UNIX format before anything is touched
83if $cygwin; then
84 [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
85 [ -n "$JRE_HOME" ] && JRE_HOME=`cygpath --unix "$JRE_HOME"`
86 [ -n "$CATALINA_HOME" ] && CATALINA_HOME=`cygpath --unix "$CATALINA_HOME"`
87 [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
88fi
89
90# For OS400
91if $os400; then
92 # Set job priority to standard for interactive (interactive - 6) by using
93 # the interactive priority - 6, the helper threads that respond to requests
94 # will be running at the same priority as interactive jobs.
95 COMMAND='chgjob job('$JOBNAME') runpty(6)'
96 system $COMMAND
97
98 # Enable multi threading
99 export QIBM_MULTI_THREADED=Y
100fi
101
102# Get standard Java environment variables
103if $os400; then
104 # -r will Only work on the os400 if the files are:
105 # 1. owned by the user
106 # 2. owned by the PRIMARY group of the user
107 # this will not work if the user belongs in secondary groups
108 . "$CATALINA_HOME"/bin/setclasspath.sh
109else
110 if [ -r "$CATALINA_HOME"/bin/setclasspath.sh ]; then
111 . "$CATALINA_HOME"/bin/setclasspath.sh
112 else
113 echo "Cannot find $CATALINA_HOME/bin/setclasspath.sh"
114 echo "This file is needed to run this program"
115 exit 1
116 fi
117fi
118
119# Add on extra jar files to CLASSPATH
120if [ ! -z "$CLASSPATH" ] ; then
121 CLASSPATH="$CLASSPATH":
122fi
123CLASSPATH="$CLASSPATH""$CATALINA_HOME"/bin/bootstrap.jar:"$CATALINA_HOME"/bin/tomcat-juli.jar:"$CATALINA_HOME"/lib/servlet-api.jar
124
125# For Cygwin, switch paths to Windows format before running java
126if $cygwin; then
127 JAVA_HOME=`cygpath --absolute --windows "$JAVA_HOME"`
128 JRE_HOME=`cygpath --absolute --windows "$JRE_HOME"`
129 CATALINA_HOME=`cygpath --absolute --windows "$CATALINA_HOME"`
130 CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
131 JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
132fi
133
134JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
135
136# ----- Execute The Requested Command -----------------------------------------
137
138exec "$_RUNJAVA" $JAVA_OPTS $TOOL_OPTS \
139 -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
140 -Dcatalina.home="$CATALINA_HOME" \
141 org.apache.catalina.startup.Tool "$@"