[66] | 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 | if "%OS%" == "Windows_NT" setlocal |
---|
| 18 | rem --------------------------------------------------------------------------- |
---|
| 19 | rem NT Service Install/Uninstall script |
---|
| 20 | rem |
---|
| 21 | rem Options |
---|
| 22 | rem install Install the service using Tomcat6 as service name. |
---|
| 23 | rem Service is installed using default settings. |
---|
| 24 | rem remove Remove the service from the System. |
---|
| 25 | rem |
---|
| 26 | rem name (optional) If the second argument is present it is considered |
---|
| 27 | rem to be new service name |
---|
| 28 | rem |
---|
| 29 | rem $Id: service.bat 600659 2007-12-03 20:15:09Z jim $ |
---|
| 30 | rem --------------------------------------------------------------------------- |
---|
| 31 | |
---|
| 32 | rem Guess CATALINA_HOME if not defined |
---|
| 33 | set CURRENT_DIR=%cd% |
---|
| 34 | if not "%CATALINA_HOME%" == "" goto gotHome |
---|
| 35 | set CATALINA_HOME=%cd% |
---|
| 36 | if exist "%CATALINA_HOME%\bin\tomcat6.exe" goto okHome |
---|
| 37 | rem CD to the upper dir |
---|
| 38 | cd .. |
---|
| 39 | set CATALINA_HOME=%cd% |
---|
| 40 | :gotHome |
---|
| 41 | if exist "%CATALINA_HOME%\bin\tomcat6.exe" goto okHome |
---|
| 42 | echo The tomcat.exe was not found... |
---|
| 43 | echo The CATALINA_HOME environment variable is not defined correctly. |
---|
| 44 | echo This environment variable is needed to run this program |
---|
| 45 | goto end |
---|
| 46 | rem Make sure prerequisite environment variables are set |
---|
| 47 | if not "%JAVA_HOME%" == "" goto okHome |
---|
| 48 | echo The JAVA_HOME environment variable is not defined |
---|
| 49 | echo This environment variable is needed to run this program |
---|
| 50 | goto end |
---|
| 51 | :okHome |
---|
| 52 | if not "%CATALINA_BASE%" == "" goto gotBase |
---|
| 53 | set CATALINA_BASE=%CATALINA_HOME% |
---|
| 54 | :gotBase |
---|
| 55 | |
---|
| 56 | set EXECUTABLE=%CATALINA_HOME%\bin\tomcat6.exe |
---|
| 57 | |
---|
| 58 | rem Set default Service name |
---|
| 59 | set SERVICE_NAME=Tomcat6 |
---|
| 60 | set PR_DISPLAYNAME=Apache Tomcat |
---|
| 61 | |
---|
| 62 | if "%1" == "" goto displayUsage |
---|
| 63 | if "%2" == "" goto setServiceName |
---|
| 64 | set SERVICE_NAME=%2 |
---|
| 65 | set PR_DISPLAYNAME=Apache Tomcat %2 |
---|
| 66 | :setServiceName |
---|
| 67 | if %1 == install goto doInstall |
---|
| 68 | if %1 == remove goto doRemove |
---|
| 69 | if %1 == uninstall goto doRemove |
---|
| 70 | echo Unknown parameter "%1" |
---|
| 71 | :displayUsage |
---|
| 72 | echo. |
---|
| 73 | echo Usage: service.bat install/remove [service_name] |
---|
| 74 | goto end |
---|
| 75 | |
---|
| 76 | :doRemove |
---|
| 77 | rem Remove the service |
---|
| 78 | "%EXECUTABLE%" //DS//%SERVICE_NAME% |
---|
| 79 | echo The service '%SERVICE_NAME%' has been removed |
---|
| 80 | goto end |
---|
| 81 | |
---|
| 82 | :doInstall |
---|
| 83 | rem Install the service |
---|
| 84 | echo Installing the service '%SERVICE_NAME%' ... |
---|
| 85 | echo Using CATALINA_HOME: %CATALINA_HOME% |
---|
| 86 | echo Using CATALINA_BASE: %CATALINA_BASE% |
---|
| 87 | echo Using JAVA_HOME: %JAVA_HOME% |
---|
| 88 | |
---|
| 89 | rem Use the environment variables as an example |
---|
| 90 | rem Each command line option is prefixed with PR_ |
---|
| 91 | |
---|
| 92 | set PR_DESCRIPTION=Apache Tomcat Server - http://tomcat.apache.org/ |
---|
| 93 | set PR_INSTALL=%EXECUTABLE% |
---|
| 94 | set PR_LOGPATH=%CATALINA_BASE%\logs |
---|
| 95 | set PR_CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar |
---|
| 96 | rem Set the server jvm from JAVA_HOME |
---|
| 97 | set PR_JVM=%JAVA_HOME%\jre\bin\server\jvm.dll |
---|
| 98 | if exist "%PR_JVM%" goto foundJvm |
---|
| 99 | rem Set the client jvm from JAVA_HOME |
---|
| 100 | set PR_JVM=%JAVA_HOME%\jre\bin\client\jvm.dll |
---|
| 101 | if exist "%PR_JVM%" goto foundJvm |
---|
| 102 | set PR_JVM=auto |
---|
| 103 | :foundJvm |
---|
| 104 | echo Using JVM: %PR_JVM% |
---|
| 105 | "%EXECUTABLE%" //IS//%SERVICE_NAME% --StartClass org.apache.catalina.startup.Bootstrap --StopClass org.apache.catalina.startup.Bootstrap --StartParams start --StopParams stop |
---|
| 106 | if not errorlevel 1 goto installed |
---|
| 107 | echo Failed installing '%SERVICE_NAME%' service |
---|
| 108 | goto end |
---|
| 109 | :installed |
---|
| 110 | rem Clear the environment variables. They are not needed any more. |
---|
| 111 | set PR_DISPLAYNAME= |
---|
| 112 | set PR_DESCRIPTION= |
---|
| 113 | set PR_INSTALL= |
---|
| 114 | set PR_LOGPATH= |
---|
| 115 | set PR_CLASSPATH= |
---|
| 116 | set PR_JVM= |
---|
| 117 | rem Set extra parameters |
---|
| 118 | "%EXECUTABLE%" //US//%SERVICE_NAME% --JvmOptions "-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed" --StartMode jvm --StopMode jvm |
---|
| 119 | rem More extra parameters |
---|
| 120 | set PR_LOGPATH=%CATALINA_BASE%\logs |
---|
| 121 | set PR_STDOUTPUT=auto |
---|
| 122 | set PR_STDERROR=auto |
---|
| 123 | "%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties" --JvmMs 128 --JvmMx 256 |
---|
| 124 | echo The service '%SERVICE_NAME%' has been installed. |
---|
| 125 | |
---|
| 126 | :end |
---|
| 127 | cd %CURRENT_DIR% |
---|