Skip to content

Commit

Permalink
Modifies script execution to allow for random password generation if …
Browse files Browse the repository at this point in the history
…an admin password was not supplied

Signed-off-by: Darshit Chanpura <[email protected]>
  • Loading branch information
DarshitChanpura committed Oct 5, 2023
1 parent 1af041d commit 208e625
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ function setupSecurityPlugin {
echo "OpenSearch 2.11.0 onwards, the security plugin introduces a change that requires an initial password for 'admin' user."
echo "Please define an environment variable 'initialAdminPassword' with a password string."
echo "Or create a file 'initialAdminPassword.txt' with a single line that contains the password string and place it under $OPENSEARCH_PATH_CONF folder."
bash $OPENSEARCH_HOME/plugins/opensearch-security/tools/install_demo_configuration.sh -y -i -s || exit 1
echo "If no password is provided, a password will be generated for you"
bash $OPENSEARCH_HOME/plugins/opensearch-security/tools/install_demo_configuration.sh -y -i -s -g || exit 1
fi

if [ "$DISABLE_SECURITY_PLUGIN" = "true" ]; then
Expand Down
3 changes: 2 additions & 1 deletion scripts/opensearch-onetime-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ if [ -d "$OPENSEARCH_HOME/plugins/$SECURITY_PLUGIN" ]; then
echo "OpenSearch 2.11.0 onwards, the security plugin introduces a change that requires an initial password for 'admin' user."
echo "Please define an environment variable 'initialAdminPassword' with a password string."
echo "Or create a file 'initialAdminPassword.txt' with a single line that contains the password string and place it under $OPENSEARCH_PATH_CONF folder."
bash $OPENSEARCH_HOME/plugins/opensearch-security/tools/install_demo_configuration.sh -y -i -s || exit 1
echo "If no password is provided, a password will be generated for you"
bash $OPENSEARCH_HOME/plugins/opensearch-security/tools/install_demo_configuration.sh -y -i -s -g || exit 1
fi

if [ "$DISABLE_SECURITY_PLUGIN" = "true" ]; then
Expand Down
3 changes: 2 additions & 1 deletion scripts/pkg/build_templates/opensearch/deb/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ if [ -d ${product_dir}/plugins/opensearch-security ]; then
echo "OpenSearch 2.11.0 onwards, the security plugin introduces a change that requires an initial password for 'admin' user."
echo "Please define an environment variable 'initialAdminPassword' with a password string."
echo "Or create a file 'initialAdminPassword.txt' with a single line that contains the password string and place it under $OPENSEARCH_PATH_CONF folder."
bash $OPENSEARCH_HOME/plugins/opensearch-security/tools/install_demo_configuration.sh -y -i -s || exit 1 > ${log_dir}/install_demo_configuration.log 2>&1
echo "If no password is provided, a password will be generated for you"
bash $OPENSEARCH_HOME/plugins/opensearch-security/tools/install_demo_configuration.sh -y -i -s -g || exit 1 > ${log_dir}/install_demo_configuration.log 2>&1
fi

# Apply PerformanceAnalyzer Settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ if [ -d %{product_dir}/plugins/opensearch-security ]; then
echo "OpenSearch 2.11.0 onwards, the security plugin introduces a change that requires an initial password for 'admin' user."
echo "Please define an environment variable 'initialAdminPassword' with a password string."
echo "Or create a file 'initialAdminPassword.txt' with a single line that contains the password string and place it under $OPENSEARCH_PATH_CONF folder."
sh %{product_dir}/plugins/opensearch-security/tools/install_demo_configuration.sh -y -i -s || exit 1> %{log_dir}/install_demo_configuration.log 2>&1
echo "If no password is provided, a password will be generated for you"
sh %{product_dir}/plugins/opensearch-security/tools/install_demo_configuration.sh -y -i -s -g || exit 1> %{log_dir}/install_demo_configuration.log 2>&1
fi
chown -R %{name}.%{name} %{config_dir}
chown -R %{name}.%{name} %{log_dir}
Expand Down
9 changes: 7 additions & 2 deletions scripts/startup/tar/linux/opensearch-tar-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ cd $OPENSEARCH_HOME
KNN_LIB_DIR=$OPENSEARCH_HOME/plugins/opensearch-knn/lib
##Security Plugin
if [ -d "$OPENSEARCH_HOME/plugins/opensearch-security" ]; then
bash $OPENSEARCH_HOME/plugins/opensearch-security/tools/install_demo_configuration.sh -y -i -s
echo "done security"
echo "Enabling execution of install_demo_configuration.sh for OpenSearch Security Plugin"
echo "OpenSearch 2.11.0 onwards, the security plugin introduces a change that requires an initial password for 'admin' user."
echo "Please define an environment variable 'initialAdminPassword' with a password string."
echo "Or create a file 'initialAdminPassword.txt' with a single line that contains the password string and place it under $OPENSEARCH_PATH_CONF folder."
echo "If no password is provided, a password will be generated for you"
bash $OPENSEARCH_HOME/plugins/opensearch-security/tools/install_demo_configuration.sh -y -i -s -g || exit 1
echo "Demo security config installed"
fi

PA_AGENT_JAVA_OPTS="-Dlog4j.configurationFile=$OPENSEARCH_PATH_CONF/opensearch-performance-analyzer/log4j2.xml \
Expand Down
7 changes: 6 additions & 1 deletion scripts/startup/zip/windows/opensearch-windows-install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ ECHO "OPENSEARCH_PATH_CONF: %OPENSEARCH_PATH_CONF%"
:: Security Plugin Setups
IF EXIST "%OPENSEARCH_HOME%\plugins\opensearch-security" (
ECHO "Running Security Plugin Install Demo Configuration"
CALL "%OPENSEARCH_HOME%/plugins/opensearch-security/tools/install_demo_configuration.bat" -y -i -s
ECHO OpenSearch 2.11.0 onwards, the security plugin introduces a change that requires an initial password for 'admin' user.
ECHO Please define an environment variable 'initialAdminPassword' with a password string.
ECHO Or create a file 'initialAdminPassword.txt' with a single line that contains the password string and place it under %OPENSEARCH_PATH_CONF% folder.
ECHO If no password is provided, a password will be generated for you
CALL "%OPENSEARCH_HOME%\plugins\opensearch-security\tools\install_demo_configuration.bat" -y -i -s -g || exit /b 1
ECHO "Demo security config installed"
)

:: k-NN Plugin Setups
Expand Down

0 comments on commit 208e625

Please sign in to comment.