home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-tomcat-addon-1.4.9-installer.exe / service.bat < prev    next >
Encoding:
DOS Batch File  |  2004-08-28  |  3.6 KB  |  100 lines

  1. @echo off
  2. if "%OS%" == "Windows_NT" setlocal
  3. rem ---------------------------------------------------------------------------
  4. rem NT Service Install/Uninstall script
  5. rem
  6. rem Options
  7. rem install                Install the service using Tomcat5 as service name.
  8. rem                        Service is installed using default settings.
  9. rem remove                 Remove the service from the System.
  10. rem
  11. rem name        (optional) If the second argument is present it is considered
  12. rem                        to be new service name                                           
  13. rem
  14. rem $Id: service.bat,v 1.5.2.1 2004/08/23 22:54:32 mturk Exp $
  15. rem ---------------------------------------------------------------------------
  16.  
  17. rem Guess CATALINA_HOME if not defined
  18. set CURRENT_DIR=%cd%
  19. if not "%CATALINA_HOME%" == "" goto gotHome
  20. set CATALINA_HOME=%cd%
  21. if exist "%CATALINA_HOME%\bin\tomcat5.exe" goto okHome
  22. rem CD to the upper dir
  23. cd ..
  24. set CATALINA_HOME=%cd%
  25. :gotHome
  26. if exist "%CATALINA_HOME%\bin\tomcat5.exe" goto okHome
  27. echo The tomcat.exe was not found...
  28. echo The CATALINA_HOME environment variable is not defined correctly.
  29. echo This environment variable is needed to run this program
  30. goto end
  31. rem Make sure prerequisite environment variables are set
  32. if not "%JAVA_HOME%" == "" goto okHome
  33. echo The JAVA_HOME environment variable is not defined
  34. echo This environment variable is needed to run this program
  35. goto end 
  36. :okHome
  37. if not "%CATALINA_BASE%" == "" goto gotBase
  38. set CATALINA_BASE=%CATALINA_HOME%
  39. :gotBase
  40.  
  41. set EXECUTABLE=%CATALINA_HOME%\bin\tomcat5.exe
  42.  
  43. rem Set default Service name
  44. set SERVICE_NAME=Tomcat5
  45. set PR_DISPLAYNAME=Apache Tomcat
  46.  
  47. if "%1" == "" goto displayUsage
  48. if "%2" == "" goto setServiceName
  49. set SERVICE_NAME=%2
  50. set PR_DISPLAYNAME=Apache Tomcat %2
  51. :setServiceName
  52. if %1 == install goto doInstall
  53. if %1 == remove goto doRemove
  54. echo Unknown parameter "%1"
  55. :displayUsage
  56. echo 
  57. echo Usage: service.bat install/remove [service_name]
  58. goto end
  59.  
  60. :doRemove
  61. rem Remove the service
  62. "%EXECUTABLE%" //DS//%SERVICE_NAME%
  63. echo The service '%SERVICE_NAME%' has been removed
  64. goto end
  65.  
  66. :doInstall
  67. rem Install the service
  68. echo Installing the service '%SERVICE_NAME%' ...
  69. echo Using CATALINA_HOME:    %CATALINA_HOME%
  70. echo Using JAVA_HOME:        %JAVA_HOME%
  71.  
  72. rem Use the environment variables as an exaple
  73. rem Each command line option is prefixed with PR_
  74.  
  75. set PR_DESCRIPTION=Apache Tomcat Server - http://jakarta.apache.org/tomcat
  76. set PR_INSTALL=%EXECUTABLE%
  77. set PR_LOGPATH=%CATALINA_HOME%\logs
  78. set PR_CLASSPATH=%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\bin\bootstrap.jar
  79. rem Set the server jvm frrom JAVA_HOME
  80. set PR_JVM=%JAVA_HOME%\jre\bin\server\jvm.dll
  81. rem You can use the 'set PR_JVM=auto' for default JVM
  82. "%EXECUTABLE%" //IS//%SERVICE_NAME% --StartClass org.apache.catalina.startup.Bootstrap --StopClass org.apache.catalina.startup.Bootstrap --StartParams start --StopParams stop
  83. rem Clear the environment variables. They are not needed any more.
  84. set PR_DISPLAYNAME=
  85. set PR_DESCRIPTION=
  86. set PR_INSTALL=
  87. set PR_LOGPATH=
  88. set PR_CLASSPATH=
  89. set PR_JVM=
  90. rem Set extra parameters
  91. "%EXECUTABLE%" //US//%SERVICE_NAME% --JvmOptions "-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%\common\endorsed" --StartMode jvm --StopMode jvm
  92. rem More extra parameters
  93. set PR_STDOUTPUT=%CATALINA_HOME%\logs\stdout.log
  94. set PR_STDERROR=%CATALINA_HOME%\logs\stderr.log
  95. "%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp" --JvmMs 128 --JvmMx 256
  96. echo The service '%SERVICE_NAME%' has been installed.
  97.  
  98. :end
  99. cd %CURRENT_DIR%
  100.