From 04286226e03d8897db36e472516a4cb44b230ad9 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Thu, 12 Jan 2023 09:45:36 -0500 Subject: [PATCH] [Backport 1.X] Update tool scripts to run in windows (#2371) (#2388) (#2399) Backport 8ccad5c7d2653fda12acabc1b94afe2b3d9a99dd from #2371 Signed-off-by: Peter Nied (cherry picked from commit ffc64e576211490c460cea177a884ac3066e1bee) Co-authored-by: Peter Nied --- tools/audit_config_migrater.bat | 13 ++++++++----- tools/hash.bat | 13 ++++++++----- tools/securityadmin.bat | 13 ++++++++----- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/tools/audit_config_migrater.bat b/tools/audit_config_migrater.bat index bf0222b5f1..78f1b1abc0 100644 --- a/tools/audit_config_migrater.bat +++ b/tools/audit_config_migrater.bat @@ -1,11 +1,14 @@ @echo off -set SCRIPT_DIR=%~dp0 +set DIR=%~dp0 -rem comparing to empty string makes this equivalent to bash -v check on env var -if not "%OPENSEARCH_JAVA_HOME%" == "" ( +if defined OPENSEARCH_JAVA_HOME ( set BIN_PATH="%OPENSEARCH_JAVA_HOME%\bin\java.exe" -) else ( +) else if defined JAVA_HOME ( set BIN_PATH="%JAVA_HOME%\bin\java.exe" +) else ( + echo Unable to find java runtime + echo OPENSEARCH_JAVA_HOME or JAVA_HOME must be defined + exit /b 1 ) -%BIN_PATH% -cp "%SCRIPT_DIR%\..\..\opendistro_security_ssl\*;%SCRIPT_DIR%\..\deps\*;%SCRIPT_DIR%\..\*;%SCRIPT_DIR%\..\..\..\lib\*" org.opensearch.security.tools.AuditConfigMigrater %* +%BIN_PATH% -cp "%DIR%\..\*;%DIR%\..\..\..\lib\*;%DIR%\..\deps\*" org.opensearch.security.tools.AuditConfigMigrater %* diff --git a/tools/hash.bat b/tools/hash.bat index b34bcdd4c1..a50611465c 100644 --- a/tools/hash.bat +++ b/tools/hash.bat @@ -1,12 +1,15 @@ @echo off -set SCRIPT_DIR=%~dp0 +set DIR=%~dp0 -rem comparing to empty string makes this equivalent to bash -v check on env var -if not "%OPENSEARCH_JAVA_HOME%" == "" ( +if defined OPENSEARCH_JAVA_HOME ( set BIN_PATH="%OPENSEARCH_JAVA_HOME%\bin\java.exe" -) else ( +) else if defined JAVA_HOME ( set BIN_PATH="%JAVA_HOME%\bin\java.exe" +) else ( + echo Unable to find java runtime + echo OPENSEARCH_JAVA_HOME or JAVA_HOME must be defined + exit /b 1 ) -%BIN_PATH% -cp "%SCRIPT_DIR%\..\..\opendistro_security_ssl\*;%SCRIPT_DIR%\..\deps\*;%SCRIPT_DIR%\..\*;%SCRIPT_DIR%\..\..\..\lib\*" org.opensearch.security.tools.Hasher %* +%BIN_PATH% -cp "%DIR%\..\*;%DIR%\..\..\..\lib\*;%DIR%\..\deps\*" org.opensearch.security.tools.Hasher %* diff --git a/tools/securityadmin.bat b/tools/securityadmin.bat index ce6ae49a46..a44562b6d9 100644 --- a/tools/securityadmin.bat +++ b/tools/securityadmin.bat @@ -1,11 +1,14 @@ @echo off -set SCRIPT_DIR=%~dp0 +set DIR=%~dp0 -rem comparing to empty string makes this equivalent to bash -v check on env var -if not "%OPENSEARCH_JAVA_HOME%" == "" ( +if defined OPENSEARCH_JAVA_HOME ( set BIN_PATH="%OPENSEARCH_JAVA_HOME%\bin\java.exe" -) else ( +) else if defined JAVA_HOME ( set BIN_PATH="%JAVA_HOME%\bin\java.exe" +) else ( + echo Unable to find java runtime + echo OPENSEARCH_JAVA_HOME or JAVA_HOME must be defined + exit /b 1 ) -%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 +%BIN_PATH% -Dorg.apache.logging.log4j.simplelog.StatusLogger.level=OFF -cp "%DIR%\..\*;%DIR%\..\..\..\lib\*;%DIR%\..\deps\*" org.opensearch.security.tools.SecurityAdmin %* 2> nul \ No newline at end of file