Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 771 | blopes | 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 | # This script creates the directory structure required for running Tomcat |
||
| 19 | # in a separate directory by pointing $CATALINA_BASE to it. It copies the |
||
| 20 | # conf directory from $CATALINA_HOME, and creates empty directories for |
||
| 21 | # bin, lib, logs, temp, webapps, and work. |
||
| 22 | # |
||
| 23 | # If the file $CATALINA_HOME/bin/setenv.sh exists then it is copied to |
||
| 24 | # the target directory as well. |
||
| 25 | # |
||
| 26 | # Usage: makebase <path-to-target-directory> [-w | --webapps] |
||
| 27 | |||
| 28 | # resolve links - $0 may be a softlink |
||
| 29 | PRG="$0" |
||
| 30 | |||
| 31 | while [ -h "$PRG" ]; do |
||
| 32 | ls=`ls -ld "$PRG"` |
||
| 33 | link=`expr "$ls" : '.*-> \(.*\)$'` |
||
| 34 | if expr "$link" : '/.*' > /dev/null; then |
||
| 35 | PRG="$link" |
||
| 36 | else |
||
| 37 | PRG=`dirname "$PRG"`/"$link" |
||
| 38 | fi |
||
| 39 | done |
||
| 40 | |||
| 41 | # Get standard environment variables |
||
| 42 | PRGDIR=`dirname "$PRG"` |
||
| 43 | |||
| 44 | # Only set CATALINA_HOME if not already set |
||
| 45 | [ -z "$CATALINA_HOME" ] && CATALINA_HOME=`cd "$PRGDIR/.." >/dev/null; pwd` |
||
| 46 | |||
| 47 | # first arg is the target directory |
||
| 48 | BASE_TGT=$1 |
||
| 49 | |||
| 50 | if [ -z "$BASE_TGT" ]; then |
||
| 51 | # target directory not provided; exit |
||
| 52 | echo "Usage: makebase <path-to-target-directory>" |
||
| 53 | exit 1 |
||
| 54 | fi |
||
| 55 | |||
| 56 | COPY_WEBAPPS=false |
||
| 57 | |||
| 58 | # parse args |
||
| 59 | while [ "$1" != "" ]; do |
||
| 60 | case $1 in |
||
| 61 | -w | --webapps) |
||
| 62 | COPY_WEBAPPS=true |
||
| 63 | ;; |
||
| 64 | esac |
||
| 65 | shift |
||
| 66 | done |
||
| 67 | |||
| 68 | if [ -d "$BASE_TGT" ]; then |
||
| 69 | # target directory exists |
||
| 70 | echo "Target directory exists" |
||
| 71 | |||
| 72 | # exit if target directory is not empty |
||
| 73 | [ "`ls -A "$BASE_TGT"`" ] && \ |
||
| 74 | echo "Target directory is not empty" && \ |
||
| 75 | exit 1 |
||
| 76 | else |
||
| 77 | # create the target directory |
||
| 78 | mkdir -p "$BASE_TGT" |
||
| 79 | fi |
||
| 80 | |||
| 81 | for dir in bin conf lib logs temp webapps work; |
||
| 82 | do |
||
| 83 | # create empty directories |
||
| 84 | mkdir "$BASE_TGT/$dir" |
||
| 85 | done |
||
| 86 | |||
| 87 | if [ "$COPY_WEBAPPS" = true ]; then |
||
| 88 | echo "Copying webapps" |
||
| 89 | cp -r "$CATALINA_HOME/webapps" "$BASE_TGT/" |
||
| 90 | # copy conf directory recursively |
||
| 91 | cp -r "$CATALINA_HOME/conf" "$BASE_TGT/" |
||
| 92 | else |
||
| 93 | # copy conf directory without subdirectories and suppress warning |
||
| 94 | cp "${CATALINA_HOME}/conf"/* "$BASE_TGT/conf" 2> /dev/null |
||
| 95 | # create empty ROOT directory |
||
| 96 | mkdir "$BASE_TGT/webapps/ROOT" |
||
| 97 | fi |
||
| 98 | |||
| 99 | # copy setenv.sh if exists |
||
| 100 | [ -f "$CATALINA_HOME/bin/setenv.sh" ] && \ |
||
| 101 | cp "$CATALINA_HOME/bin/setenv.sh" "$BASE_TGT/bin/" |
||
| 102 | |||
| 103 | echo "Created CATALINA_BASE directory at $BASE_TGT" |
||
| 104 | |||
| 105 | echo |
||
| 106 | echo "You can launch the new instance by running:" |
||
| 107 | echo " export CATALINA_HOME=$CATALINA_HOME" |
||
| 108 | echo " export CATALINA_BASE=$BASE_TGT" |
||
| 109 | echo " \$CATALINA_HOME/bin/catalina.sh run" |
||
| 110 | |||
| 111 | echo |
||
| 112 | echo "Attention: The ports in conf/server.xml might be bound by a " |
||
| 113 | echo " different instance. Please review your config files " |
||
| 114 | echo " and update them as necessary." |
||
| 115 | echo |