Skip to content

Commit

Permalink
fix bat file
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Crawford <[email protected]>
  • Loading branch information
stephen-crawford committed Sep 21, 2023
1 parent 95e6e8f commit e8164a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
21 changes: 11 additions & 10 deletions tools/install_demo_configuration.bat
Original file line number Diff line number Diff line change
Expand Up @@ -323,17 +323,18 @@ echo plugins.security.system_indices.indices: [".plugins-ml-config", ".plugins-m

setlocal enabledelayedexpansion

:: Check if initialAdminPassword environment variable is set
if defined initialAdminPassword (
set "ADMIN_PASSWORD=!initialAdminPassword!"
if not "%initialAdminPassword%"=="" (
set "ADMIN_PASSWORD=%initialAdminPassword%"
) else (
:: Read the admin password from the file
for /f %%a in ('type "%ADMIN_PASSWORD_FILE%"') do set "ADMIN_PASSWORD=%%a"
)

if not defined ADMIN_PASSWORD (
echo Unable to find the admin password for the cluster. Please set initialAdminPassword or create a file {OPENSEARCH_ROOT}\config\initialAdminPassword.txt with a single line that contains the password.
exit /b 1
if exist "%OPENSEARCH_CONF_DIR%\opensearch-security\initialAdminPassword.txt" (
for /f "delims=" %%a in ('type "%OPENSEARCH_CONF_DIR%\opensearch-security\initialAdminPassword.txt"') do (
set "ADMIN_PASSWORD=%%a"
goto :password_found
)
) else (
echo Unable to find the admin password for the cluster. Please set 'initialAdminPassword' or create a file %OPENSEARCH_ROOT%\config\initialAdminPassword.txt with a single line that contains the password.
exit /b 1
)
)

:: Use the Hasher script to hash the admin password
Expand Down
9 changes: 0 additions & 9 deletions tools/install_demo_configuration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,6 @@ echo 'plugins.security.restapi.roles_enabled: ["all_access", "security_rest_api_
echo 'plugins.security.system_indices.enabled: true' | $SUDO_CMD tee -a "$OPENSEARCH_CONF_FILE" > /dev/null
echo 'plugins.security.system_indices.indices: [".plugins-ml-config", ".plugins-ml-connector", ".plugins-ml-model-group", ".plugins-ml-model", ".plugins-ml-task", ".plugins-ml-conversation-meta", ".plugins-ml-conversation-interactions", ".opendistro-alerting-config", ".opendistro-alerting-alert*", ".opendistro-anomaly-results*", ".opendistro-anomaly-detector*", ".opendistro-anomaly-checkpoints", ".opendistro-anomaly-detection-state", ".opendistro-reports-*", ".opensearch-notifications-*", ".opensearch-notebooks", ".opensearch-observability", ".ql-datasources", ".opendistro-asynchronous-search-response*", ".replication-metadata-store", ".opensearch-knn-models", ".geospatial-ip2geo-data*", ".opendistro-job-scheduler-lock"]' | $SUDO_CMD tee -a "$OPENSEARCH_CONF_FILE" > /dev/null

# Read the admin password from the file or use the initialAdminPassword if set
echo "Path is " $(pwd)
echo "Checking for password file in: " $OPENSEARCH_CONF_DIR/opensearch-security/
echo "Content of security config dir is: $(ls $OPENSEARCH_CONF_DIR/opensearch-security/)
echo "HEAD of password file is: $(head $OPENSEARCH_CONF_DIR/opensearch-security/initialAdminPassword.txt)"
if [[ -n "$initialAdminPassword" ]]; then
ADMIN_PASSWORD="$initialAdminPassword"
elif [[ -f "$OPENSEARCH_CONF_DIR/opensearch-security/initialAdminPassword.txt" && -s "$OPENSEARCH_CONF_DIR/opensearch-security/initialAdminPassword.txt" ]]; then
Expand All @@ -405,9 +399,6 @@ else
exit 1
fi

echo "ADMIN PASSWORD SET TO: $ADMIN_PASSWORD"
# Use the Hasher script to hash the admin password
HASHED_ADMIN_PASSWORD=$(./hash.sh -p "$ADMIN_PASSWORD")

Expand Down

0 comments on commit e8164a5

Please sign in to comment.