1@echo off 2rem Licensed to the Apache Software Foundation (ASF) under one or more 3rem contributor license agreements. See the NOTICE file distributed with 4rem this work for additional information regarding copyright ownership. 5rem The ASF licenses this file to You under the Apache License, Version 2.0 6rem (the "License"); you may not use this file except in compliance with 7rem the License. You may obtain a copy of the License at 8rem 9rem http://www.apache.org/licenses/LICENSE-2.0 10rem 11rem Unless required by applicable law or agreed to in writing, software 12rem distributed under the License is distributed on an "AS IS" BASIS, 13rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14rem See the License for the specific language governing permissions and 15rem limitations under the License. 16 17rem This script creates the directory structure required for running Tomcat 18rem in a separate directory by pointing %CATALINA_BASE% to it. It copies the 19rem conf directory from %CATALINA_HOME%, and creates empty directories for 20rem bin, lib, logs, temp, webapps, and work. 21rem 22rem If the file %CATALINA_HOME%/bin/setenv.sh exists then it is copied to 23rem the target directory as well. 24rem 25rem Usage: makebase <path-to-target-directory> [-w | --webapps] 26 27setlocal 28 29rem Guess CATALINA_HOME if not defined 30set "CURRENT_DIR=%cd%" 31if not "%CATALINA_HOME%" == "" goto gotHome 32set "CATALINA_HOME=%CURRENT_DIR%" 33if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome 34cd .. 35set "CATALINA_HOME=%cd%" 36cd "%CURRENT_DIR%" 37:gotHome 38 39if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome 40echo The CATALINA_HOME environment variable is not defined correctly 41echo This environment variable is needed to run this program 42goto EOF 43:okHome 44 45rem first arg is the target directory 46set BASE_TGT=%1 47 48if %BASE_TGT%.==. ( 49 rem target directory not provided; exit 50 echo Usage: makebase ^<path-to-target-directory^> 51 goto :EOF 52) 53 54set COPY_WEBAPPS=false 55 56rem parse args 57for %%a in (%*) do ( 58 if "%%~a"=="--webapps" ( 59 set COPY_WEBAPPS=true 60 ) 61 if "%%~a"=="-w" ( 62 set COPY_WEBAPPS=true 63 ) 64) 65 66if exist %BASE_TGT% ( 67 rem target directory exists 68 echo Target directory exists 69 70 rem exit if target directory is not empty 71 for /F %%i in ('dir /b %BASE_TGT%\*.*') do ( 72 echo Target directory is not empty 73 goto :EOF 74 ) 75) else ( 76 rem create the target directory 77 mkdir %BASE_TGT% 78) 79 80rem create empty directories 81for %%d in (bin, conf, lib, logs, temp, webapps, work) do ( 82 mkdir %BASE_TGT%\%%d 83) 84 85if "%COPY_WEBAPPS%" == "true" ( 86 echo Copying webapps 87 robocopy %CATALINA_HOME%\webapps %BASE_TGT%\webapps /E > nul 88 rem copy conf directory recursively 89 robocopy %CATALINA_HOME%\conf %BASE_TGT%\conf /E > nul 90) else ( 91 rem copy conf directory without subdirectories and suppress warning 92 robocopy %CATALINA_HOME%\conf %BASE_TGT%\conf > nul 93 rem create empty ROOT directory 94 mkdir %BASE_TGT%\webapps\ROOT 95) 96 97rem copy setenv.bat if exists 98robocopy %CATALINA_HOME%\bin %BASE_TGT%\bin setenv.bat > nul 99 100echo Created CATALINA_BASE directory at %BASE_TGT% 101 102echo. 103echo You can launch the new instance by running: 104echo set CATALINA_HOME=%CATALINA_HOME% 105echo set CATALINA_BASE=%BASE_TGT% 106echo %%CATALINA_HOME%%/bin/catalina.bat run 107 108echo. 109echo Attention: The ports in conf\server.xml might be bound by a 110echo different instance. Please review your config files 111echo and update them where necessary. 112echo. 113 114:EOF 115