Skip to content

Commit

Permalink
Add support for OPENSEARCH_JAVA_HOME (opensearch-project#1603)
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
  • Loading branch information
reta authored Feb 10, 2022
1 parent b682db0 commit 4e7b8c6
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 12 deletions.
10 changes: 9 additions & 1 deletion tools/audit_config_migrater.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
@echo off
set SCRIPT_DIR=%~dp0
"%JAVA_HOME%\bin\java" -cp "%SCRIPT_DIR%\..\..\opendistro_security_ssl\*;%SCRIPT_DIR%\..\deps\*;%SCRIPT_DIR%\..\*;%SCRIPT_DIR%\..\..\..\lib\*" org.opensearch.security.tools.AuditConfigMigrater %*

rem comparing to empty string makes this equivalent to bash -v check on env var
if not "%OPENSEARCH_JAVA_HOME%" == "" (
set BIN_PATH="%OPENSEARCH_JAVA_HOME%\bin\java.exe"
) else (
set BIN_PATH="%JAVA_HOME%\bin\java.exe"
)

%BIN_PATH% -cp "%SCRIPT_DIR%\..\..\opendistro_security_ssl\*;%SCRIPT_DIR%\..\deps\*;%SCRIPT_DIR%\..\*;%SCRIPT_DIR%\..\..\..\lib\*" org.opensearch.security.tools.AuditConfigMigrater %*
9 changes: 6 additions & 3 deletions tools/audit_config_migrater.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ fi

BIN_PATH="java"

if [ -z "$JAVA_HOME" ]; then
echo "WARNING: JAVA_HOME not set, will use $(which $BIN_PATH)"
else
# now set the path to java: first OPENSEARCH_JAVA_HOME, then JAVA_HOME
if [ ! -z "$OPENSEARCH_JAVA_HOME" ]; then
BIN_PATH="$OPENSEARCH_JAVA_HOME/bin/java"
elif [ ! -z "$JAVA_HOME" ]; then
BIN_PATH="$JAVA_HOME/bin/java"
else
echo "WARNING: nor OPENSEARCH_JAVA_HOME nor JAVA_HOME is set, will use $(which $BIN_PATH)"
fi

"$BIN_PATH" $JAVA_OPTS -cp "$DIR/../../opendistro_security_ssl/*:$DIR/../*:$DIR/../deps/*:$DIR/../../../lib/*" org.opensearch.security.tools.AuditConfigMigrater "$@"
10 changes: 9 additions & 1 deletion tools/hash.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
@echo off
set SCRIPT_DIR=%~dp0
"%JAVA_HOME%\bin\java" -cp "%SCRIPT_DIR%\..\..\opendistro_security_ssl\*;%SCRIPT_DIR%\..\deps\*;%SCRIPT_DIR%\..\*;%SCRIPT_DIR%\..\..\..\lib\*" org.opensearch.security.tools.Hasher %*

rem comparing to empty string makes this equivalent to bash -v check on env var
if not "%OPENSEARCH_JAVA_HOME%" == "" (
set BIN_PATH="%OPENSEARCH_JAVA_HOME%\bin\java.exe"
) else (
set BIN_PATH="%JAVA_HOME%\bin\java.exe"
)

%BIN_PATH% -cp "%SCRIPT_DIR%\..\..\opendistro_security_ssl\*;%SCRIPT_DIR%\..\deps\*;%SCRIPT_DIR%\..\*;%SCRIPT_DIR%\..\..\..\lib\*" org.opensearch.security.tools.Hasher %*

10 changes: 7 additions & 3 deletions tools/hash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ fi

BIN_PATH="java"

if [ -z "$JAVA_HOME" ]; then
echo "WARNING: JAVA_HOME not set, will use $(which $BIN_PATH)"
else
# now set the path to java: first OPENSEARCH_JAVA_HOME, then JAVA_HOME
if [ ! -z "$OPENSEARCH_JAVA_HOME" ]; then
BIN_PATH="$OPENSEARCH_JAVA_HOME/bin/java"
elif [ ! -z "$JAVA_HOME" ]; then
BIN_PATH="$JAVA_HOME/bin/java"
else
echo "WARNING: nor OPENSEARCH_JAVA_HOME nor JAVA_HOME is set, will use $(which $BIN_PATH)"
fi


"$BIN_PATH" $JAVA_OPTS -cp "$DIR/../../opendistro_security_ssl/*:$DIR/../*:$DIR/../deps/*:$DIR/../../../lib/*" org.opensearch.security.tools.Hasher "$@"
10 changes: 9 additions & 1 deletion tools/securityadmin.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
@echo off
set SCRIPT_DIR=%~dp0
"%JAVA_HOME%\bin\java" -Dorg.apache.logging.log4j.simplelog.StatusLogger.level=OFF -cp "%SCRIPT_DIR%\..\..\opendistro_security-ssl\*;%SCRIPT_DIR%\..\deps\*;%SCRIPT_DIR%\..\*;%SCRIPT_DIR%\..\..\..\lib\*" org.opensearch.security.tools.SecurityAdmin %* 2> nul

rem comparing to empty string makes this equivalent to bash -v check on env var
if not "%OPENSEARCH_JAVA_HOME%" == "" (
set BIN_PATH="%OPENSEARCH_JAVA_HOME%\bin\java.exe"
) else (
set BIN_PATH="%JAVA_HOME%\bin\java.exe"
)

%BIN_PATH% -Dorg.apache.logging.log4j.simplelog.StatusLogger.level=OFF -cp "%SCRIPT_DIR%\..\..\opendistro_security-ssl\*;%SCRIPT_DIR%\..\deps\*;%SCRIPT_DIR%\..\*;%SCRIPT_DIR%\..\..\..\lib\*" org.opensearch.security.tools.SecurityAdmin %* 2> nul
9 changes: 6 additions & 3 deletions tools/securityadmin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ fi

BIN_PATH="java"

if [ -z "$JAVA_HOME" ]; then
echo "WARNING: JAVA_HOME not set, will use $(which $BIN_PATH)"
else
# now set the path to java: first OPENSEARCH_JAVA_HOME, then JAVA_HOME
if [ ! -z "$OPENSEARCH_JAVA_HOME" ]; then
BIN_PATH="$OPENSEARCH_JAVA_HOME/bin/java"
elif [ ! -z "$JAVA_HOME" ]; then
BIN_PATH="$JAVA_HOME/bin/java"
else
echo "WARNING: nor OPENSEARCH_JAVA_HOME nor JAVA_HOME is set, will use $(which $BIN_PATH)"
fi

"$BIN_PATH" $JAVA_OPTS -Dorg.apache.logging.log4j.simplelog.StatusLogger.level=OFF -cp "$DIR/../*:$DIR/../../../lib/*:$DIR/../deps/*" org.opensearch.security.tools.SecurityAdmin "$@" 2>/dev/null
Expand Down

0 comments on commit 4e7b8c6

Please sign in to comment.