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