text
stringlengths
0
834k
goto okHome
)
if exist ""%CATALINA_HOME%\bin\%SERVICE_NAME%.exe"" (
set ""EXECUTABLE=%CATALINA_HOME%\bin\%SERVICE_NAME%.exe""
goto okHome
)
if ""%DEFAULT_SERVICE_NAME%""== ""%SERVICE_NAME%"" (
echo The file %DEFAULT_SERVICE_NAME%.exe was not found...
) else (
echo Neither the %DEFAULT_SERVICE_NAME%.exe file nor the %SERVICE_NAME%.exe file was found...
)
echo Either the CATALINA_HOME environment variable is not defined correctly or
echo the incorrect service name has been used.
echo Both the CATALINA_HOME environment variable and the correct service name
echo are required to run this program.
exit /b 1
:okHome
cd ""%CURRENT_DIR%""
rem Make sure prerequisite environment variables are set
if not ""%JAVA_HOME%"" == """" goto gotJdkHome
if not ""%JRE_HOME%"" == """" goto gotJreHome
echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
echo Service will try to guess them from the registry.
goto okJavaHome
:gotJreHome
if not exist ""%JRE_HOME%\bin\java.exe"" goto noJavaHome
goto okJavaHome
:gotJdkHome
if not exist ""%JAVA_HOME%\bin\javac.exe"" goto noJavaHome
rem Java 9 has a different directory structure
if exist ""%JAVA_HOME%\jre\bin\java.exe"" goto preJava9Layout
if not exist ""%JAVA_HOME%\bin\java.exe"" goto noJavaHome
if not ""%JRE_HOME%"" == """" goto okJavaHome
set ""JRE_HOME=%JAVA_HOME%""
goto okJavaHome
:preJava9Layout
if not ""%JRE_HOME%"" == """" goto okJavaHome
set ""JRE_HOME=%JAVA_HOME%\jre""
goto okJavaHome
:noJavaHome
echo The JAVA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
echo NB: JAVA_HOME should point to a JDK not a JRE
exit /b 1
:okJavaHome
if not ""%CATALINA_BASE%"" == """" goto gotBase
set ""CATALINA_BASE=%CATALINA_HOME%""
:gotBase
rem Java 9 no longer supports the java.endorsed.dirs
rem system property. Only try to use it if
rem JAVA_ENDORSED_DIRS was explicitly set
rem or CATALINA_HOME/endorsed exists.
set ENDORSED_PROP=ignore.endorsed.dirs
if ""%JAVA_ENDORSED_DIRS%"" == """" goto noEndorsedVar
set ENDORSED_PROP=java.endorsed.dirs
goto doneEndorsed
:noEndorsedVar
if not exist ""%CATALINA_HOME%\endorsed"" goto doneEndorsed
set ENDORSED_PROP=java.endorsed.dirs
:doneEndorsed
rem Process the requested command
if /i %SERVICE_CMD% == install goto doInstall
if /i %SERVICE_CMD% == remove goto doRemove
if /i %SERVICE_CMD% == uninstall goto doRemove
echo Unknown parameter ""%SERVICE_CMD%""
:displayUsage
echo.
echo Usage: service.bat install/remove [service_name [--rename]] [--user username]
exit /b 1
:doRemove
rem Remove the service
echo Removing the service '%SERVICE_NAME%' ...
echo Using CATALINA_BASE: ""%CATALINA_BASE%""
""%EXECUTABLE%"" //DS//%SERVICE_NAME% ^
--LogPath ""%CATALINA_BASE%\logs""
if not errorlevel 1 goto removed
echo Failed removing '%SERVICE_NAME%' service
exit /b 1
:removed
echo The service '%SERVICE_NAME%' has been removed
if exist ""%CATALINA_HOME%\bin\%SERVICE_NAME%.exe"" (
rename ""%SERVICE_NAME%.exe"" ""%DEFAULT_SERVICE_NAME%.exe""
rename ""%SERVICE_NAME%w.exe"" ""%DEFAULT_SERVICE_NAME%w.exe""
)
exit /b 0
:doInstall
rem Install the service
echo Installing the service '%SERVICE_NAME%' ...
echo Using CATALINA_HOME: ""%CATALINA_HOME%""
echo Using CATALINA_BASE: ""%CATALINA_BASE%""
echo Using JAVA_HOME: ""%JAVA_HOME%""
echo Using JRE_HOME: ""%JRE_HOME%""
rem Try to use the server jvm