Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame^] | 1 | #!/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. |
| 35 | cygwin=false |
| 36 | case "`uname`" in |
| 37 | CYGWIN*) cygwin=true;; |
| 38 | esac |
| 39 | |
| 40 | # resolve links - $0 may be a softlink |
| 41 | PRG="$0" |
| 42 | |
| 43 | while [ -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 |
| 51 | done |
| 52 | |
| 53 | # Get standard environment variables |
| 54 | PRGDIR=`dirname "$PRG"` |
| 55 | CATALINA_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. |
| 59 | CLASSPATH= |
| 60 | |
| 61 | if [ -r "$CATALINA_HOME"/bin/setenv.sh ]; then |
| 62 | . "$CATALINA_HOME"/bin/setenv.sh |
| 63 | fi |
| 64 | |
| 65 | # For Cygwin, ensure paths are in UNIX format before anything is touched |
| 66 | if $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"` |
| 70 | fi |
| 71 | |
| 72 | # Get standard Java environment variables |
| 73 | if [ -r "$CATALINA_HOME"/bin/setclasspath.sh ]; then |
| 74 | BASEDIR="$CATALINA_HOME" |
| 75 | . "$CATALINA_HOME"/bin/setclasspath.sh |
| 76 | else |
| 77 | echo "Cannot find $CATALINA_HOME/bin/setclasspath.sh" |
| 78 | echo "This file is needed to run this program" |
| 79 | exit 1 |
| 80 | fi |
| 81 | |
| 82 | # Add on extra jar files to CLASSPATH |
| 83 | CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jar:"$BASEDIR"/lib/servlet-api.jar |
| 84 | |
| 85 | # For Cygwin, switch paths to Windows format before running java |
| 86 | if $cygwin; then |
| 87 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` |
| 88 | CATALINA_HOME=`cygpath --path --windows "$CATALINA_HOME"` |
| 89 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` |
| 90 | fi |
| 91 | |
| 92 | # ----- Execute The Requested Command ----------------------------------------- |
| 93 | |
| 94 | exec "$_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 "$@" |