shell.bat 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. @echo off
  2. rem
  3. rem
  4. rem Licensed to the Apache Software Foundation (ASF) under one or more
  5. rem contributor license agreements. See the NOTICE file distributed with
  6. rem this work for additional information regarding copyright ownership.
  7. rem The ASF licenses this file to You under the Apache License, Version 2.0
  8. rem (the "License"); you may not use this file except in compliance with
  9. rem the License. You may obtain a copy of the License at
  10. rem
  11. rem http://www.apache.org/licenses/LICENSE-2.0
  12. rem
  13. rem Unless required by applicable law or agreed to in writing, software
  14. rem distributed under the License is distributed on an "AS IS" BASIS,
  15. rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. rem See the License for the specific language governing permissions and
  17. rem limitations under the License.
  18. rem
  19. if not "%ECHO%" == "" echo %ECHO%
  20. setlocal
  21. set DIRNAME=%~dp0%
  22. set PROGNAME=%~nx0%
  23. set ARGS=%*
  24. rem Sourcing environment settings for karaf similar to tomcats setenv
  25. SET KARAF_SCRIPT="shell.bat"
  26. if exist "%DIRNAME%setenv.bat" (
  27. call "%DIRNAME%setenv.bat"
  28. )
  29. rem Check console window title. Set to Karaf by default
  30. if not "%KARAF_TITLE%" == "" (
  31. title %KARAF_TITLE%
  32. ) else (
  33. title Karaf
  34. )
  35. rem Check/Set up some easily accessible MIN/MAX params for JVM mem usage
  36. if "%JAVA_MIN_MEM%" == "" (
  37. set JAVA_MIN_MEM=128M
  38. )
  39. if "%JAVA_MAX_MEM%" == "" (
  40. set JAVA_MAX_MEM=512M
  41. )
  42. goto BEGIN
  43. :warn
  44. echo %PROGNAME%: %*
  45. goto :EOF
  46. :BEGIN
  47. rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  48. if not "%KARAF_HOME%" == "" (
  49. call :warn Ignoring predefined value for KARAF_HOME
  50. )
  51. set KARAF_HOME=%DIRNAME%..
  52. if not exist "%KARAF_HOME%" (
  53. call :warn KARAF_HOME is not valid: "%KARAF_HOME%"
  54. goto END
  55. )
  56. if not "%KARAF_BASE%" == "" (
  57. if not exist "%KARAF_BASE%" (
  58. call :warn KARAF_BASE is not valid: "%KARAF_BASE%"
  59. goto END
  60. )
  61. )
  62. if "%KARAF_BASE%" == "" (
  63. set "KARAF_BASE=%KARAF_HOME%"
  64. )
  65. if not "%KARAF_DATA%" == "" (
  66. if not exist "%KARAF_DATA%" (
  67. call :warn KARAF_DATA is not valid: "%KARAF_DATA%"
  68. goto END
  69. )
  70. )
  71. if "%KARAF_DATA%" == "" (
  72. set "KARAF_DATA=%KARAF_BASE%\data"
  73. )
  74. if not "%KARAF_ETC%" == "" (
  75. if not exist "%KARAF_ETC%" (
  76. call :warn KARAF_ETC is not valid: "%KARAF_ETC%"
  77. goto END
  78. )
  79. )
  80. if "%KARAF_ETC%" == "" (
  81. set "KARAF_ETC=%KARAF_BASE%\etc"
  82. )
  83. set DEFAULT_JAVA_OPTS=
  84. set DEFAULT_JAVA_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
  85. rem Support for loading native libraries
  86. set PATH=%PATH%;%KARAF_BASE%\lib;%KARAF_HOME%\lib
  87. rem Setup the Java Virtual Machine
  88. if not "%JAVA%" == "" goto :Check_JAVA_END
  89. set JAVA=java
  90. if "%JAVA_HOME%" == "" call :warn JAVA_HOME not set; results may vary
  91. if not "%JAVA_HOME%" == "" set JAVA=%JAVA_HOME%\bin\java
  92. if not exist "%JAVA_HOME%" (
  93. call :warn JAVA_HOME is not valid: "%JAVA_HOME%"
  94. goto END
  95. )
  96. :Check_JAVA_END
  97. if "%JAVA_OPTS%" == "" set JAVA_OPTS=%DEFAULT_JAVA_OPTS%
  98. if "%EXTRA_JAVA_OPTS%" == "" goto :KARAF_EXTRA_JAVA_OPTS_END
  99. set JAVA_OPTS=%JAVA_OPTS% %EXTRA_JAVA_OPTS%
  100. :KARAF_EXTRA_JAVA_OPTS_END
  101. if "%KARAF_DEBUG%" == "" goto :KARAF_DEBUG_END
  102. rem Use the defaults if JAVA_DEBUG_OPTS was not set
  103. if "%JAVA_DEBUG_OPTS%" == "" set JAVA_DEBUG_OPTS=%DEFAULT_JAVA_DEBUG_OPTS%
  104. set JAVA_OPTS="%JAVA_DEBUG_OPTS% %JAVA_OPTS%"
  105. call :warn Enabling Java debug options: %JAVA_DEBUG_OPTS%
  106. :KARAF_DEBUG_END
  107. set CLASSPATH=%KARAF_HOME%\system\org\apache\karaf\shell\org.apache.karaf.shell.core\4.0.9\org.apache.karaf.shell.core-4.0.9.jar
  108. set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\system\org\ops4j\pax\logging\pax-logging-api\1.8.5\pax-logging-api-1.8.5.jar
  109. set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\system\jline\jline\2.14.1\jline-2.14.1.jar
  110. :EXECUTE
  111. if "%SHIFT%" == "true" SET ARGS=%2 %3 %4 %5 %6 %7 %8
  112. if not "%SHIFT%" == "true" SET ARGS=%1 %2 %3 %4 %5 %6 %7 %8
  113. rem Execute the Java Virtual Machine
  114. "%JAVA%" %JAVA_OPTS% %OPTS% -classpath "%CLASSPATH%" -Dkaraf.instances="%KARAF_HOME%\instances" -Dkaraf.home="%KARAF_HOME%" -Dkaraf.base="%KARAF_BASE%" -Dkaraf.etc="%KARAF_ETC%" -Dkaraf.data="%KARAF_DATA%" -Djava.io.tmpdir="%KARAF_DATA%\tmp" -Djava.util.logging.config.file="%KARAF_BASE%\etc\java.util.logging.properties" %KARAF_OPTS% org.apache.karaf.shell.impl.console.standalone.Main --classpath="%KARAF_HOME%\system" %ARGS%
  115. rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  116. :END
  117. endlocal