[66] | 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 | # Start/Stop Script for the CATALINA Server |
---|
| 20 | # |
---|
| 21 | # Environment Variable Prequisites |
---|
| 22 | # |
---|
| 23 | # CATALINA_HOME May point at your Catalina "build" directory. |
---|
| 24 | # |
---|
| 25 | # CATALINA_BASE (Optional) Base directory for resolving dynamic portions |
---|
| 26 | # of a Catalina installation. If not present, resolves to |
---|
| 27 | # the same directory that CATALINA_HOME points to. |
---|
| 28 | # |
---|
| 29 | # CATALINA_OPTS (Optional) Java runtime options used when the "start", |
---|
| 30 | # or "run" command is executed. |
---|
| 31 | # |
---|
| 32 | # CATALINA_TMPDIR (Optional) Directory path location of temporary directory |
---|
| 33 | # the JVM should use (java.io.tmpdir). Defaults to |
---|
| 34 | # $CATALINA_BASE/temp. |
---|
| 35 | # |
---|
| 36 | # JAVA_HOME Must point at your Java Development Kit installation. |
---|
| 37 | # Required to run the with the "debug" or "javac" argument. |
---|
| 38 | # |
---|
| 39 | # JRE_HOME Must point at your Java Development Kit installation. |
---|
| 40 | # Defaults to JAVA_HOME if empty. |
---|
| 41 | # |
---|
| 42 | # JAVA_OPTS (Optional) Java runtime options used when the "start", |
---|
| 43 | # "stop", or "run" command is executed. |
---|
| 44 | # |
---|
| 45 | # JPDA_TRANSPORT (Optional) JPDA transport used when the "jpda start" |
---|
| 46 | # command is executed. The default is "dt_socket". |
---|
| 47 | # |
---|
| 48 | # JPDA_ADDRESS (Optional) Java runtime options used when the "jpda start" |
---|
| 49 | # command is executed. The default is 8000. |
---|
| 50 | # |
---|
| 51 | # JPDA_SUSPEND (Optional) Java runtime options used when the "jpda start" |
---|
| 52 | # command is executed. Specifies whether JVM should suspend |
---|
| 53 | # execution immediately after startup. Default is "n". |
---|
| 54 | # |
---|
| 55 | # JPDA_OPTS (Optional) Java runtime options used when the "jpda start" |
---|
| 56 | # command is executed. If used, JPDA_TRANSPORT, JPDA_ADDRESS, |
---|
| 57 | # and JPDA_SUSPEND are ignored. Thus, all required jpda |
---|
| 58 | # options MUST be specified. The default is: |
---|
| 59 | # |
---|
| 60 | # -Xdebug -Xrunjdwp:transport=$JPDA_TRANSPORT, |
---|
| 61 | # address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND |
---|
| 62 | # |
---|
| 63 | # JSSE_HOME (Optional) May point at your Java Secure Sockets Extension |
---|
| 64 | # (JSSE) installation, whose JAR files will be added to the |
---|
| 65 | # system class path used to start Tomcat. |
---|
| 66 | # |
---|
| 67 | # CATALINA_PID (Optional) Path of the file which should contains the pid |
---|
| 68 | # of catalina startup java process, when start (fork) is used |
---|
| 69 | # |
---|
| 70 | # $Id: catalina.sh 656834 2008-05-15 21:04:04Z markt $ |
---|
| 71 | # ----------------------------------------------------------------------------- |
---|
| 72 | |
---|
| 73 | # OS specific support. $var _must_ be set to either true or false. |
---|
| 74 | cygwin=false |
---|
| 75 | os400=false |
---|
| 76 | darwin=false |
---|
| 77 | case "`uname`" in |
---|
| 78 | CYGWIN*) cygwin=true;; |
---|
| 79 | OS400*) os400=true;; |
---|
| 80 | Darwin*) darwin=true;; |
---|
| 81 | esac |
---|
| 82 | |
---|
| 83 | # resolve links - $0 may be a softlink |
---|
| 84 | PRG="$0" |
---|
| 85 | |
---|
| 86 | while [ -h "$PRG" ]; do |
---|
| 87 | ls=`ls -ld "$PRG"` |
---|
| 88 | link=`expr "$ls" : '.*-> \(.*\)$'` |
---|
| 89 | if expr "$link" : '/.*' > /dev/null; then |
---|
| 90 | PRG="$link" |
---|
| 91 | else |
---|
| 92 | PRG=`dirname "$PRG"`/"$link" |
---|
| 93 | fi |
---|
| 94 | done |
---|
| 95 | |
---|
| 96 | # Get standard environment variables |
---|
| 97 | PRGDIR=`dirname "$PRG"` |
---|
| 98 | |
---|
| 99 | # Only set CATALINA_HOME if not already set |
---|
| 100 | [ -z "$CATALINA_HOME" ] && CATALINA_HOME=`cd "$PRGDIR/.." ; pwd` |
---|
| 101 | |
---|
| 102 | if [ -r "$CATALINA_BASE"/bin/setenv.sh ]; then |
---|
| 103 | . "$CATALINA_BASE"/bin/setenv.sh |
---|
| 104 | elif [ -r "$CATALINA_HOME"/bin/setenv.sh ]; then |
---|
| 105 | . "$CATALINA_HOME"/bin/setenv.sh |
---|
| 106 | fi |
---|
| 107 | |
---|
| 108 | # For Cygwin, ensure paths are in UNIX format before anything is touched |
---|
| 109 | if $cygwin; then |
---|
| 110 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` |
---|
| 111 | [ -n "$JRE_HOME" ] && JRE_HOME=`cygpath --unix "$JRE_HOME"` |
---|
| 112 | [ -n "$CATALINA_HOME" ] && CATALINA_HOME=`cygpath --unix "$CATALINA_HOME"` |
---|
| 113 | [ -n "$CATALINA_BASE" ] && CATALINA_BASE=`cygpath --unix "$CATALINA_BASE"` |
---|
| 114 | [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"` |
---|
| 115 | [ -n "$JSSE_HOME" ] && JSSE_HOME=`cygpath --absolute --unix "$JSSE_HOME"` |
---|
| 116 | fi |
---|
| 117 | |
---|
| 118 | # For OS400 |
---|
| 119 | if $os400; then |
---|
| 120 | # Set job priority to standard for interactive (interactive - 6) by using |
---|
| 121 | # the interactive priority - 6, the helper threads that respond to requests |
---|
| 122 | # will be running at the same priority as interactive jobs. |
---|
| 123 | COMMAND='chgjob job('$JOBNAME') runpty(6)' |
---|
| 124 | system $COMMAND |
---|
| 125 | |
---|
| 126 | # Enable multi threading |
---|
| 127 | export QIBM_MULTI_THREADED=Y |
---|
| 128 | fi |
---|
| 129 | |
---|
| 130 | # Get standard Java environment variables |
---|
| 131 | if $os400; then |
---|
| 132 | # -r will Only work on the os400 if the files are: |
---|
| 133 | # 1. owned by the user |
---|
| 134 | # 2. owned by the PRIMARY group of the user |
---|
| 135 | # this will not work if the user belongs in secondary groups |
---|
| 136 | BASEDIR="$CATALINA_HOME" |
---|
| 137 | . "$CATALINA_HOME"/bin/setclasspath.sh |
---|
| 138 | else |
---|
| 139 | if [ -r "$CATALINA_HOME"/bin/setclasspath.sh ]; then |
---|
| 140 | BASEDIR="$CATALINA_HOME" |
---|
| 141 | . "$CATALINA_HOME"/bin/setclasspath.sh |
---|
| 142 | else |
---|
| 143 | echo "Cannot find $CATALINA_HOME/bin/setclasspath.sh" |
---|
| 144 | echo "This file is needed to run this program" |
---|
| 145 | exit 1 |
---|
| 146 | fi |
---|
| 147 | fi |
---|
| 148 | |
---|
| 149 | # Add on extra jar files to CLASSPATH |
---|
| 150 | if [ -n "$JSSE_HOME" ]; then |
---|
| 151 | CLASSPATH="$CLASSPATH":"$JSSE_HOME"/lib/jcert.jar:"$JSSE_HOME"/lib/jnet.jar:"$JSSE_HOME"/lib/jsse.jar |
---|
| 152 | fi |
---|
| 153 | CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jar |
---|
| 154 | |
---|
| 155 | if [ -z "$CATALINA_BASE" ] ; then |
---|
| 156 | CATALINA_BASE="$CATALINA_HOME" |
---|
| 157 | fi |
---|
| 158 | |
---|
| 159 | if [ -z "$CATALINA_TMPDIR" ] ; then |
---|
| 160 | # Define the java.io.tmpdir to use for Catalina |
---|
| 161 | CATALINA_TMPDIR="$CATALINA_BASE"/temp |
---|
| 162 | fi |
---|
| 163 | |
---|
| 164 | # Bugzilla 37848: When no TTY is available, don't output to console |
---|
| 165 | have_tty=0 |
---|
| 166 | if [ "`tty`" != "not a tty" ]; then |
---|
| 167 | have_tty=1 |
---|
| 168 | fi |
---|
| 169 | |
---|
| 170 | # For Cygwin, switch paths to Windows format before running java |
---|
| 171 | if $cygwin; then |
---|
| 172 | JAVA_HOME=`cygpath --absolute --windows "$JAVA_HOME"` |
---|
| 173 | JRE_HOME=`cygpath --absolute --windows "$JRE_HOME"` |
---|
| 174 | CATALINA_HOME=`cygpath --absolute --windows "$CATALINA_HOME"` |
---|
| 175 | CATALINA_BASE=`cygpath --absolute --windows "$CATALINA_BASE"` |
---|
| 176 | CATALINA_TMPDIR=`cygpath --absolute --windows "$CATALINA_TMPDIR"` |
---|
| 177 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` |
---|
| 178 | [ -n "$JSSE_HOME" ] && JSSE_HOME=`cygpath --absolute --windows "$JSSE_HOME"` |
---|
| 179 | JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"` |
---|
| 180 | fi |
---|
| 181 | |
---|
| 182 | # Set juli LogManager if it is present |
---|
| 183 | if [ -r "$CATALINA_BASE"/conf/logging.properties ]; then |
---|
| 184 | JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" |
---|
| 185 | LOGGING_CONFIG="-Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties" |
---|
| 186 | fi |
---|
| 187 | |
---|
| 188 | # ----- Execute The Requested Command ----------------------------------------- |
---|
| 189 | |
---|
| 190 | # Bugzilla 37848: only output this if we have a TTY |
---|
| 191 | if [ $have_tty -eq 1 ]; then |
---|
| 192 | echo "Using CATALINA_BASE: $CATALINA_BASE" |
---|
| 193 | echo "Using CATALINA_HOME: $CATALINA_HOME" |
---|
| 194 | echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR" |
---|
| 195 | if [ "$1" = "debug" -o "$1" = "javac" ] ; then |
---|
| 196 | echo "Using JAVA_HOME: $JAVA_HOME" |
---|
| 197 | else |
---|
| 198 | echo "Using JRE_HOME: $JRE_HOME" |
---|
| 199 | fi |
---|
| 200 | fi |
---|
| 201 | |
---|
| 202 | if [ "$1" = "jpda" ] ; then |
---|
| 203 | if [ -z "$JPDA_TRANSPORT" ]; then |
---|
| 204 | JPDA_TRANSPORT="dt_socket" |
---|
| 205 | fi |
---|
| 206 | if [ -z "$JPDA_ADDRESS" ]; then |
---|
| 207 | JPDA_ADDRESS="8000" |
---|
| 208 | fi |
---|
| 209 | if [ -z "$JPDA_SUSPEND" ]; then |
---|
| 210 | JPDA_SUSPEND="n" |
---|
| 211 | fi |
---|
| 212 | if [ -z "$JPDA_OPTS" ]; then |
---|
| 213 | JPDA_OPTS="-agentlib:jdwp=transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND" |
---|
| 214 | fi |
---|
| 215 | CATALINA_OPTS="$CATALINA_OPTS $JPDA_OPTS" |
---|
| 216 | shift |
---|
| 217 | fi |
---|
| 218 | |
---|
| 219 | if [ "$1" = "debug" ] ; then |
---|
| 220 | if $os400; then |
---|
| 221 | echo "Debug command not available on OS400" |
---|
| 222 | exit 1 |
---|
| 223 | else |
---|
| 224 | shift |
---|
| 225 | if [ "$1" = "-security" ] ; then |
---|
| 226 | echo "Using Security Manager" |
---|
| 227 | shift |
---|
| 228 | exec "$_RUNJDB" $JAVA_OPTS "$LOGGING_CONFIG" $CATALINA_OPTS \ |
---|
| 229 | -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ |
---|
| 230 | -sourcepath "$CATALINA_HOME"/../../java \ |
---|
| 231 | -Djava.security.manager \ |
---|
| 232 | -Djava.security.policy=="$CATALINA_BASE"/conf/catalina.policy \ |
---|
| 233 | -Dcatalina.base="$CATALINA_BASE" \ |
---|
| 234 | -Dcatalina.home="$CATALINA_HOME" \ |
---|
| 235 | -Djava.io.tmpdir="$CATALINA_TMPDIR" \ |
---|
| 236 | org.apache.catalina.startup.Bootstrap "$@" start |
---|
| 237 | else |
---|
| 238 | exec "$_RUNJDB" $JAVA_OPTS "$LOGGING_CONFIG" $CATALINA_OPTS \ |
---|
| 239 | -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ |
---|
| 240 | -sourcepath "$CATALINA_HOME"/../../java \ |
---|
| 241 | -Dcatalina.base="$CATALINA_BASE" \ |
---|
| 242 | -Dcatalina.home="$CATALINA_HOME" \ |
---|
| 243 | -Djava.io.tmpdir="$CATALINA_TMPDIR" \ |
---|
| 244 | org.apache.catalina.startup.Bootstrap "$@" start |
---|
| 245 | fi |
---|
| 246 | fi |
---|
| 247 | |
---|
| 248 | elif [ "$1" = "run" ]; then |
---|
| 249 | |
---|
| 250 | shift |
---|
| 251 | if [ "$1" = "-security" ] ; then |
---|
| 252 | echo "Using Security Manager" |
---|
| 253 | shift |
---|
| 254 | exec "$_RUNJAVA" $JAVA_OPTS "$LOGGING_CONFIG" $CATALINA_OPTS \ |
---|
| 255 | -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ |
---|
| 256 | -Djava.security.manager \ |
---|
| 257 | -Djava.security.policy=="$CATALINA_BASE"/conf/catalina.policy \ |
---|
| 258 | -Dcatalina.base="$CATALINA_BASE" \ |
---|
| 259 | -Dcatalina.home="$CATALINA_HOME" \ |
---|
| 260 | -Djava.io.tmpdir="$CATALINA_TMPDIR" \ |
---|
| 261 | org.apache.catalina.startup.Bootstrap "$@" start |
---|
| 262 | else |
---|
| 263 | exec "$_RUNJAVA" $JAVA_OPTS "$LOGGING_CONFIG" $CATALINA_OPTS \ |
---|
| 264 | -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ |
---|
| 265 | -Dcatalina.base="$CATALINA_BASE" \ |
---|
| 266 | -Dcatalina.home="$CATALINA_HOME" \ |
---|
| 267 | -Djava.io.tmpdir="$CATALINA_TMPDIR" \ |
---|
| 268 | org.apache.catalina.startup.Bootstrap "$@" start |
---|
| 269 | fi |
---|
| 270 | |
---|
| 271 | elif [ "$1" = "start" ] ; then |
---|
| 272 | |
---|
| 273 | shift |
---|
| 274 | touch "$CATALINA_BASE"/logs/catalina.out |
---|
| 275 | if [ "$1" = "-security" ] ; then |
---|
| 276 | echo "Using Security Manager" |
---|
| 277 | shift |
---|
| 278 | "$_RUNJAVA" $JAVA_OPTS "$LOGGING_CONFIG" $CATALINA_OPTS \ |
---|
| 279 | -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ |
---|
| 280 | -Djava.security.manager \ |
---|
| 281 | -Djava.security.policy=="$CATALINA_BASE"/conf/catalina.policy \ |
---|
| 282 | -Dcatalina.base="$CATALINA_BASE" \ |
---|
| 283 | -Dcatalina.home="$CATALINA_HOME" \ |
---|
| 284 | -Djava.io.tmpdir="$CATALINA_TMPDIR" \ |
---|
| 285 | org.apache.catalina.startup.Bootstrap "$@" start \ |
---|
| 286 | >> "$CATALINA_BASE"/logs/catalina.out 2>&1 & |
---|
| 287 | |
---|
| 288 | if [ ! -z "$CATALINA_PID" ]; then |
---|
| 289 | echo $! > $CATALINA_PID |
---|
| 290 | fi |
---|
| 291 | else |
---|
| 292 | "$_RUNJAVA" $JAVA_OPTS "$LOGGING_CONFIG" $CATALINA_OPTS \ |
---|
| 293 | -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ |
---|
| 294 | -Dcatalina.base="$CATALINA_BASE" \ |
---|
| 295 | -Dcatalina.home="$CATALINA_HOME" \ |
---|
| 296 | -Djava.io.tmpdir="$CATALINA_TMPDIR" \ |
---|
| 297 | org.apache.catalina.startup.Bootstrap "$@" start \ |
---|
| 298 | >> "$CATALINA_BASE"/logs/catalina.out 2>&1 & |
---|
| 299 | |
---|
| 300 | if [ ! -z "$CATALINA_PID" ]; then |
---|
| 301 | echo $! > $CATALINA_PID |
---|
| 302 | fi |
---|
| 303 | fi |
---|
| 304 | |
---|
| 305 | elif [ "$1" = "stop" ] ; then |
---|
| 306 | |
---|
| 307 | shift |
---|
| 308 | FORCE=0 |
---|
| 309 | if [ "$1" = "-force" ]; then |
---|
| 310 | shift |
---|
| 311 | FORCE=1 |
---|
| 312 | fi |
---|
| 313 | |
---|
| 314 | "$_RUNJAVA" $JAVA_OPTS \ |
---|
| 315 | -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ |
---|
| 316 | -Dcatalina.base="$CATALINA_BASE" \ |
---|
| 317 | -Dcatalina.home="$CATALINA_HOME" \ |
---|
| 318 | -Djava.io.tmpdir="$CATALINA_TMPDIR" \ |
---|
| 319 | org.apache.catalina.startup.Bootstrap "$@" stop |
---|
| 320 | |
---|
| 321 | if [ $FORCE -eq 1 ]; then |
---|
| 322 | if [ ! -z "$CATALINA_PID" ]; then |
---|
| 323 | echo "Killing: `cat $CATALINA_PID`" |
---|
| 324 | kill -9 `cat $CATALINA_PID` |
---|
| 325 | else |
---|
| 326 | echo "Kill failed: \$CATALINA_PID not set" |
---|
| 327 | fi |
---|
| 328 | fi |
---|
| 329 | |
---|
| 330 | elif [ "$1" = "version" ] ; then |
---|
| 331 | |
---|
| 332 | "$_RUNJAVA" \ |
---|
| 333 | -classpath "$CATALINA_HOME/lib/catalina.jar" \ |
---|
| 334 | org.apache.catalina.util.ServerInfo |
---|
| 335 | |
---|
| 336 | else |
---|
| 337 | |
---|
| 338 | echo "Usage: catalina.sh ( commands ... )" |
---|
| 339 | echo "commands:" |
---|
| 340 | if $os400; then |
---|
| 341 | echo " debug Start Catalina in a debugger (not available on OS400)" |
---|
| 342 | echo " debug -security Debug Catalina with a security manager (not available on OS400)" |
---|
| 343 | else |
---|
| 344 | echo " debug Start Catalina in a debugger" |
---|
| 345 | echo " debug -security Debug Catalina with a security manager" |
---|
| 346 | fi |
---|
| 347 | echo " jpda start Start Catalina under JPDA debugger" |
---|
| 348 | echo " run Start Catalina in the current window" |
---|
| 349 | echo " run -security Start in the current window with security manager" |
---|
| 350 | echo " start Start Catalina in a separate window" |
---|
| 351 | echo " start -security Start in a separate window with security manager" |
---|
| 352 | echo " stop Stop Catalina" |
---|
| 353 | echo " stop -force Stop Catalina (followed by kill -KILL)" |
---|
| 354 | echo " version What version of tomcat are you running?" |
---|
| 355 | exit 1 |
---|
| 356 | |
---|
| 357 | fi |
---|