blob: 71c1de4ee4334c6c64807b33e40b442df47e1b58 [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#
23# CATALINA_HOME May point at your Catalina "build" directory.
24#
25# TOOL_OPTS (Optional) Java runtime options used when the "start",
26# "stop", or "run" command is executed.
27#
28# JAVA_HOME Must point at your Java Development Kit installation.
29#
30# JAVA_OPTS (Optional) Java runtime options used when the "start",
31# "stop", or "run" command is executed.
32# -----------------------------------------------------------------------------
33
34# OS specific support. $var _must_ be set to either true or false.
35cygwin=false
36case "`uname`" in
37CYGWIN*) cygwin=true;;
38esac
39
40# resolve links - $0 may be a softlink
41PRG="$0"
42
43while [ -h "$PRG" ]; do
44 ls=`ls -ld "$PRG"`
45 link=`expr "$ls" : '.*-> \(.*\)$'`
46 if expr "$link" : '/.*' > /dev/null; then
47 PRG="$link"
48 else
49 PRG=`dirname "$PRG"`/"$link"
50 fi
51done
52
53# Get standard environment variables
54PRGDIR=`dirname "$PRG"`
55CATALINA_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`
56
57# Ensure that any user defined CLASSPATH variables are not used on startup,
58# but allow them to be specified in setenv.sh, in rare case when it is needed.
59CLASSPATH=
60
61if [ -r "$CATALINA_HOME"/bin/setenv.sh ]; then
62 . "$CATALINA_HOME"/bin/setenv.sh
63fi
64
65# For Cygwin, ensure paths are in UNIX format before anything is touched
66if $cygwin; then
67 [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
68 [ -n "$CATALINA_HOME" ] && CATALINA_HOME=`cygpath --unix "$CATALINA_HOME"`
69 [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
70fi
71
72# Get standard Java environment variables
73if [ -r "$CATALINA_HOME"/bin/setclasspath.sh ]; then
74 BASEDIR="$CATALINA_HOME"
75 . "$CATALINA_HOME"/bin/setclasspath.sh
76else
77 echo "Cannot find $CATALINA_HOME/bin/setclasspath.sh"
78 echo "This file is needed to run this program"
79 exit 1
80fi
81
82# Add on extra jar files to CLASSPATH
83CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jar:"$BASEDIR"/lib/servlet-api.jar
84
85# For Cygwin, switch paths to Windows format before running java
86if $cygwin; then
87 JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
88 CATALINA_HOME=`cygpath --path --windows "$CATALINA_HOME"`
89 CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
90fi
91
92# ----- Execute The Requested Command -----------------------------------------
93
94exec "$_RUNJAVA" $JAVA_OPTS $TOOL_OPTS \
95 -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
96 -Dcatalina.home="$CATALINA_HOME" \
97 org.apache.catalina.startup.Tool "$@"