/
elasticsearch-env
75 lines (60 loc) · 1.87 KB
/
elasticsearch-env
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
CDPATH=""
SCRIPT="$0"
# SCRIPT might be an arbitrarily deep series of symbolic links; loop until we
# have the concrete path
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
# Drop everything prior to ->
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
# determine Elasticsearch home; to do this, we strip from the path until we find
# bin, and then strip bin (there is an assumption here that there is no nested
# directory under bin also named bin)
ES_HOME=`dirname "$SCRIPT"`
# now make ES_HOME absolute
ES_HOME=`cd "$ES_HOME"; pwd`
while [ "`basename "$ES_HOME"`" != "bin" ]; do
ES_HOME=`dirname "$ES_HOME"`
done
ES_HOME=`dirname "$ES_HOME"`
# now set the classpath
ES_CLASSPATH="$ES_HOME/lib/*"
# now set the path to java
if [ -x "$JAVA_HOME/bin/java" ]; then
JAVA="$JAVA_HOME/bin/java"
else
JAVA=`which java`
fi
if [ ! -x "$JAVA" ]; then
echo "could not find java; set JAVA_HOME or ensure java is in PATH"
exit 1
fi
# do not let JAVA_TOOL_OPTIONS slip in (as the JVM does by default)
if [ "x$JAVA_TOOL_OPTIONS" != "x" ]; then
echo "warning: ignoring JAVA_TOOL_OPTIONS=$JAVA_TOOL_OPTIONS"
unset JAVA_TOOL_OPTIONS
fi
# JAVA_OPTS is not a built-in JVM mechanism but some people think it is so we
# warn them that we are not observing the value of $JAVA_OPTS
if [ "x$JAVA_OPTS" != "x" ]; then
echo -n "warning: ignoring JAVA_OPTS=$JAVA_OPTS; "
echo "pass JVM parameters via ES_JAVA_OPTS"
fi
# check the Java version
"$JAVA" -cp "$ES_CLASSPATH" org.elasticsearch.tools.JavaVersionChecker
if [ $? -ne 0 ]; then
echo -n "the minimum required Java version is 8; "
echo "your Java version from $JAVA does not meet this requirement"
exit 1
fi
${source.path.env}
if [ -z "$CONF_DIR" ]; then
echo "CONF_DIR must be set to the configuration path"
exit 1
fi