Cheng Tang | 697ce24 | 2014-04-27 16:18:17 +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. |
| 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 Tang | 697ce24 | 2014-04-27 16:18:17 +0800 | [diff] [blame] | 41 | # ----------------------------------------------------------------------------- |
| 42 | |
| 43 | # OS specific support. $var _must_ be set to either true or false. |
| 44 | cygwin=false |
| 45 | darwin=false |
| 46 | os400=false |
| 47 | case "`uname`" in |
| 48 | CYGWIN*) cygwin=true;; |
| 49 | Darwin*) darwin=true;; |
| 50 | OS400*) os400=true;; |
| 51 | esac |
| 52 | |
| 53 | # resolve links - $0 may be a softlink |
| 54 | PRG="$0" |
| 55 | |
| 56 | while [ -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 |
| 64 | done |
| 65 | |
| 66 | # Get standard environment variables |
| 67 | PRGDIR=`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. |
| 74 | CLASSPATH= |
| 75 | |
| 76 | if [ -r "$CATALINA_HOME/bin/setenv.sh" ]; then |
| 77 | . "$CATALINA_HOME/bin/setenv.sh" |
| 78 | fi |
| 79 | |
| 80 | # For Cygwin, ensure paths are in UNIX format before anything is touched |
| 81 | if $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"` |
| 86 | fi |
| 87 | |
| 88 | # For OS400 |
| 89 | if $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 |
| 98 | fi |
| 99 | |
| 100 | # Get standard Java environment variables |
| 101 | if $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 |
| 107 | else |
| 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 |
| 115 | fi |
| 116 | |
| 117 | # Add on extra jar files to CLASSPATH |
| 118 | if [ ! -z "$CLASSPATH" ] ; then |
| 119 | CLASSPATH="$CLASSPATH": |
| 120 | fi |
| 121 | CLASSPATH="$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 |
| 124 | if $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"` |
| 130 | fi |
| 131 | |
| 132 | JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" |
| 133 | |
| 134 | # ----- Execute The Requested Command ----------------------------------------- |
| 135 | |
| 136 | exec "$_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 "$@" |