Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow overwrite opensearch home to 2.x #7049

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Changed
- Require MediaType in Strings.toString API ([#6009](https://github.com/opensearch-project/OpenSearch/pull/6009))
- [Refactor] XContent base classes from xcontent to core library ([#5902](https://github.com/opensearch-project/OpenSearch/pull/5902))
- Changed `opensearch-env` to respect already set `OPENSEARCH_HOME` environment variable ([#6956](https://github.com/opensearch-project/OpenSearch/pull/6956/))

### Deprecated
- Map, List, and Set in org.opensearch.common.collect ([#6609](https://github.com/opensearch-project/OpenSearch/pull/6609))
Expand Down
24 changes: 13 additions & 11 deletions distribution/src/bin/opensearch-env
Original file line number Diff line number Diff line change
Expand Up @@ -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/*"
Expand Down
14 changes: 8 additions & 6 deletions distribution/src/bin/opensearch-env.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ set SCRIPT=%0
rem determine OpenSearch 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 OPENSEARCH_HOME=%%~dpI
if not defined OPENSEARCH_HOME (
for %%I in (%SCRIPT%) do set OPENSEARCH_HOME=%%~dpI

:opensearch_home_loop
for %%I in ("%OPENSEARCH_HOME:~1,-1%") do set DIRNAME=%%~nxI
if not "%DIRNAME%" == "bin" (
:opensearch_home_loop
for %%I in ("%OPENSEARCH_HOME:~1,-1%") do set DIRNAME=%%~nxI
if not "%DIRNAME%" == "bin" (
for %%I in ("%OPENSEARCH_HOME%..") do set OPENSEARCH_HOME=%%~dpfI
goto opensearch_home_loop
)
for %%I in ("%OPENSEARCH_HOME%..") do set OPENSEARCH_HOME=%%~dpfI
goto opensearch_home_loop
)
for %%I in ("%OPENSEARCH_HOME%..") do set OPENSEARCH_HOME=%%~dpfI

rem now set the classpath
set OPENSEARCH_CLASSPATH=!OPENSEARCH_HOME!\lib\*
Expand Down