You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

elasticsearch-env.bat 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. set SCRIPT=%0
  2. rem determine Elasticsearch home; to do this, we strip from the path until we
  3. rem find bin, and then strip bin (there is an assumption here that there is no
  4. rem nested directory under bin also named bin)
  5. for %%I in (%SCRIPT%) do set ES_HOME=%%~dpI
  6. :es_home_loop
  7. for %%I in ("%ES_HOME:~1,-1%") do set DIRNAME=%%~nxI
  8. if not "%DIRNAME%" == "bin" (
  9. for %%I in ("%ES_HOME%..") do set ES_HOME=%%~dpfI
  10. goto es_home_loop
  11. )
  12. for %%I in ("%ES_HOME%..") do set ES_HOME=%%~dpfI
  13. rem now set the classpath
  14. set ES_CLASSPATH=!ES_HOME!\lib\*
  15. rem now set the path to java
  16. if defined JAVA_HOME (
  17. set JAVA="%JAVA_HOME%\bin\java.exe"
  18. ) else (
  19. echo warning: Falling back to java on path. This behavior is deprecated. Specify JAVA_HOME
  20. for %%I in (java.exe) do set JAVA="%%~$PATH:I"
  21. )
  22. if not exist %JAVA% (
  23. echo could not find java; set JAVA_HOME 1>&2
  24. exit /b 1
  25. )
  26. rem do not let JAVA_TOOL_OPTIONS slip in (as the JVM does by default)
  27. if defined JAVA_TOOL_OPTIONS (
  28. echo warning: ignoring JAVA_TOOL_OPTIONS=%JAVA_TOOL_OPTIONS%
  29. set JAVA_TOOL_OPTIONS=
  30. )
  31. rem JAVA_OPTS is not a built-in JVM mechanism but some people think it is so we
  32. rem warn them that we are not observing the value of %JAVA_OPTS%
  33. if defined JAVA_OPTS (
  34. (echo|set /p=warning: ignoring JAVA_OPTS=%JAVA_OPTS%; )
  35. echo pass JVM parameters via ES_JAVA_OPTS
  36. )
  37. rem check the Java version
  38. %JAVA% -cp "%ES_CLASSPATH%" "org.elasticsearch.tools.java_version_checker.JavaVersionChecker" || exit /b 1
  39. set HOSTNAME=%COMPUTERNAME%
  40. if not defined ES_PATH_CONF (
  41. set ES_PATH_CONF=!ES_HOME!\config
  42. )
  43. rem now make ES_PATH_CONF absolute
  44. for %%I in ("%ES_PATH_CONF%..") do set ES_PATH_CONF=%%~dpfI
  45. set ES_DISTRIBUTION_FLAVOR=default
  46. set ES_DISTRIBUTION_TYPE=tar
  47. if not defined ES_TMPDIR (
  48. for /f "tokens=* usebackq" %%a in (`CALL %JAVA% -cp "!ES_CLASSPATH!" "org.elasticsearch.tools.launchers.TempDirectory"`) do set ES_TMPDIR=%%a
  49. )