Skip to content

Commit

Permalink
Restore batch file as much as possible
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <[email protected]>
  • Loading branch information
peternied committed Sep 26, 2023
1 parent 3e4e8b0 commit ae34718
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tools/install_demo_configuration.bat
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ echo plugins.security.system_indices.indices: [".plugins-ml-config", ".plugins-m
setlocal enabledelayedexpansion

set "ADMIN_PASSWORD_FILE=%OPENSEARCH_CONF_DIR%opensearch-security\initialAdminPassword.txt"
set "INTERNAL_USERS_FILE=%OPENSEARCH_CONF_DIR%opensearch-security\internal_users.yml"

if "%initialAdminPassword%" NEQ "" (
set "ADMIN_PASSWORD=!initialAdminPassword!"
Expand All @@ -335,6 +336,8 @@ if not defined ADMIN_PASSWORD (
exit /b 1
)

echo " *** ADMIN PASSWORD SET TO: $ADMIN_PASSWORD ***"

set "HASH_SCRIPT=%OPENSEARCH_PLUGINS_DIR%\opensearch-security\tools\hash.bat"

REM Run the command and capture its output
Expand All @@ -347,10 +350,13 @@ if errorlevel 1 (
exit /b 1
)

echo Clear the ADMIN_PASSWORD variable
set "ADMIN_PASSWORD="

set "default_line= hash: "$2a$12$VcCDgh2NDk07JGN0rjGbM.Ad41qVR/YFJcgHp0UGns5JDymv..TOG""

set "search=%default_line%"
set "replace= hash: "%HASHED_ADMIN_PASSWORD%""
set "INTERNAL_USERS_FILE=%OPENSEARCH_CONF_DIR%opensearch-security\internal_users.yml"

setlocal enableextensions
for /f "delims=" %%i in ('type "%INTERNAL_USERS_FILE%" ^& break ^> "%INTERNAL_USERS_FILE%" ') do (
Expand Down

0 comments on commit ae34718

Please sign in to comment.