-
Notifications
You must be signed in to change notification settings - Fork 25k
/
elasticsearch-env.bat
51 lines (41 loc) · 1.45 KB
/
elasticsearch-env.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
set SCRIPT=%0
rem determine Elasticsearch home; to do this, we strip from the path until we
rem find bin, and then strip bin (there is an assumption here that there is no
rem nested directory under bin also named bin)
for %%I in (%SCRIPT%) do set ES_HOME=%%~dpI
:es_home_loop
for %%I in ("%ES_HOME:~1,-1%") do set DIRNAME=%%~nxI
if not "%DIRNAME%" == "bin" (
for %%I in ("%ES_HOME%..") do set ES_HOME=%%~dpfI
goto es_home_loop
)
for %%I in ("%ES_HOME%..") do set ES_HOME=%%~dpfI
rem now set the classpath
set ES_CLASSPATH=!ES_HOME!\lib\*
rem now set the path to java
if defined JAVA_HOME (
set JAVA="%JAVA_HOME%\bin\java.exe"
) else (
for %%I in (java.exe) do set JAVA="%%~$PATH:I"
)
if not exist %JAVA% (
echo could not find java; set JAVA_HOME or ensure java is in PATH 1>&2
exit /b 1
)
rem do not let JAVA_TOOL_OPTIONS slip in (as the JVM does by default)
if defined JAVA_TOOL_OPTIONS (
echo warning: ignoring JAVA_TOOL_OPTIONS=%JAVA_TOOL_OPTIONS%
set JAVA_TOOL_OPTIONS=
)
rem JAVA_OPTS is not a built-in JVM mechanism but some people think it is so we
rem warn them that we are not observing the value of %JAVA_OPTS%
if defined JAVA_OPTS (
(echo|set /p=warning: ignoring JAVA_OPTS=%JAVA_OPTS%; )
echo pass JVM parameters via ES_JAVA_OPTS
)
rem check the Java version
%JAVA% -cp "%ES_CLASSPATH%" "org.elasticsearch.tools.JavaVersionChecker" || exit /b 1
set HOSTNAME=%COMPUTERNAME%
if not defined ES_PATH_CONF (
set ES_PATH_CONF=!ES_HOME!\config
)