From cb95c96b289e9d3cd72f434dd7797b1ee19dbe9d Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Mon, 3 Apr 2023 23:20:49 +0200 Subject: [PATCH] feat: allow overwrite opensearch home Signed-off-by: Soner Sayakci --- distribution/src/bin/opensearch-env | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/distribution/src/bin/opensearch-env b/distribution/src/bin/opensearch-env index 6fe703a73b2de..f94824576b122 100644 --- a/distribution/src/bin/opensearch-env +++ b/distribution/src/bin/opensearch-env @@ -28,18 +28,20 @@ while [ -h "$SCRIPT" ] ; do fi done -# determine OpenSearch 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) -OPENSEARCH_HOME=`dirname "$SCRIPT"` - -# now make OPENSEARCH_HOME absolute -OPENSEARCH_HOME=`cd "$OPENSEARCH_HOME"; pwd` - -while [ "`basename "$OPENSEARCH_HOME"`" != "bin" ]; do +if [[ -z "$OPENSEARCH_HOME" ]]; then + # determine OpenSearch 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) + OPENSEARCH_HOME=`dirname "$SCRIPT"` + + # now make OPENSEARCH_HOME absolute + OPENSEARCH_HOME=`cd "$OPENSEARCH_HOME"; pwd` + + while [ "`basename "$OPENSEARCH_HOME"`" != "bin" ]; do + OPENSEARCH_HOME=`dirname "$OPENSEARCH_HOME"` + done OPENSEARCH_HOME=`dirname "$OPENSEARCH_HOME"` -done -OPENSEARCH_HOME=`dirname "$OPENSEARCH_HOME"` +fi # now set the classpath OPENSEARCH_CLASSPATH="$OPENSEARCH_HOME/lib/*"