Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

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