Fix scripts when launching from bin

When running a script that depends on elasticsearch-env, the
elasticsearch-env script seeks backwards from the directory containing
the script to find Elasticsearch home. This is done by seeking backwards
in the path to find bin, and then going one directory above
that. Unfortunately, if the script is started relatively from the bin
directory, then bin will appear in the path since it is a relative
path. This commit fixes this by making the starting path absolute before
attempting to seek backwards.
This commit is contained in:
Jason Tedor 2017-07-28 10:21:34 +09:00
parent 3a20922046
commit 6c650874c9
1 changed files with 4 additions and 3 deletions

View File

@ -21,14 +21,15 @@ done
# 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 make ES_HOME absolute
ES_HOME=`cd "$ES_HOME"; pwd`
# now set the classpath
ES_CLASSPATH="$ES_HOME/lib/*"