Skip to content

Commit

Permalink
fixed dead Dataverse after server restart
Browse files Browse the repository at this point in the history
  • Loading branch information
ErykKul committed Oct 11, 2024
1 parent a4f0706 commit b5e8b74
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion images/dataverse/build_dv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ git cherry-pick 86ad64b33ac55972b9e1180b69b9629db21116bb 3a9568e5a458157dab514e0
cd ..
wget -O dataverse/modules/container-base/src/main/docker/Dockerfile https://raw.githubusercontent.com/IQSS/dataverse/develop/modules/container-base/src/main/docker/Dockerfile
wget -O dataverse/modules/container-base/src/main/docker/scripts/entrypoint.sh https://raw.githubusercontent.com/IQSS/dataverse/develop/modules/container-base/src/main/docker/scripts/entrypoint.sh
wget -O dataverse/modules/container-base/src/main/docker/scripts/init_1_change_passwords.sh https://raw.githubusercontent.com/IQSS/dataverse/develop/modules/container-base/src/main/docker/scripts/init_1_change_passwords.sh
cp ../images/dataverse/scripts/init_1_change_passwords.sh dataverse/modules/container-base/src/main/docker/scripts/init_1_change_passwords.sh
wget -O dataverse/modules/container-base/src/main/docker/scripts/init_1_generate_deploy_commands.sh https://raw.githubusercontent.com/IQSS/dataverse/develop/modules/container-base/src/main/docker/scripts/init_1_generate_deploy_commands.sh
wget -O dataverse/modules/container-base/src/main/docker/scripts/init_1_generate_devmode_commands.sh https://raw.githubusercontent.com/IQSS/dataverse/develop/modules/container-base/src/main/docker/scripts/init_1_generate_devmode_commands.sh
wget -O dataverse/modules/container-base/src/main/docker/scripts/removeExpiredCaCerts.sh https://raw.githubusercontent.com/IQSS/dataverse/develop/modules/container-base/src/main/docker/scripts/removeExpiredCaCerts.sh
Expand Down
43 changes: 43 additions & 0 deletions images/dataverse/scripts/init_1_change_passwords.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
set -euo pipefail

# NOTE: ALL PASSWORD ENV VARS WILL BE SCRAMBLED IN startInForeground.sh FOR SECURITY!
# This is to avoid possible attack vectors where someone could extract the sensitive information
# from within an env var dump inside an application!

# Someone set the env var for passwords - get the new password in. Otherwise print warning.
# https://docs.openshift.com/container-platform/4.14/openshift_images/create-images.html#avoid-default-passwords
if [ "$LINUX_PASSWORD" != "payara" ]; then
echo -e "$LINUX_USER\n$LINUX_PASSWORD\n$LINUX_PASSWORD" | passwd || true
else
echo "IMPORTANT: THIS CONTAINER USES THE DEFAULT PASSWORD FOR USER \"${LINUX_USER}\"! ('payara')"
echo " To change the password, set the LINUX_PASSWORD env var."
fi

# Change the domain admin password if necessary
if [ "$PAYARA_ADMIN_PASSWORD" != "admin" ]; then
PASSWORD_FILE=$(mktemp)
echo "AS_ADMIN_PASSWORD=admin" > "$PASSWORD_FILE"
echo "AS_ADMIN_NEWPASSWORD=${PAYARA_ADMIN_PASSWORD}" >> "$PASSWORD_FILE"
asadmin --user="${PAYARA_ADMIN_USER}" --passwordfile="$PASSWORD_FILE" change-admin-password --domain_name="${DOMAIN_NAME}" || true
rm "$PASSWORD_FILE"
else
echo "IMPORTANT: THIS CONTAINER USES THE DEFAULT PASSWORD FOR PAYARA ADMIN \"${PAYARA_ADMIN_USER}\"! ('admin')"
echo " To change the password, set the PAYARA_ADMIN_PASSWORD env var."
fi

# Change the domain master password if necessary
# > The master password is not tied to a user account, and it is not used for authentication.
# > Instead, Payara Server strictly uses the master password to ONLY encrypt the keystore and truststore used to store keys and certificates for the DAS and instances usage.
# It will be requested when booting the application server!
# https://docs.payara.fish/community/docs/Technical%20Documentation/Payara%20Server%20Documentation/Security%20Guide/Administering%20System%20Security.html#to-change-the-master-password
if [ "$DOMAIN_PASSWORD" != "changeit" ]; then
PASSWORD_FILE=$(mktemp)
echo "AS_ADMIN_MASTERPASSWORD=changeit" >> "$PASSWORD_FILE"
echo "AS_ADMIN_NEWMASTERPASSWORD=${DOMAIN_PASSWORD}" >> "$PASSWORD_FILE"
asadmin --user="${PAYARA_ADMIN_USER}" --passwordfile="$PASSWORD_FILE" change-master-password --savemasterpassword false "${DOMAIN_NAME}" || true
rm "$PASSWORD_FILE"
else
echo "IMPORTANT: THIS CONTAINER USES THE DEFAULT DOMAIN \"MASTER\" PASSWORD! ('changeit')"
echo " To change the password, set the DOMAIN_PASSWORD env var."
fi

0 comments on commit b5e8b74

Please sign in to comment.