You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2026/07/22 06:51:54 UTC

(airavata-custos) 17/29: Read database credentials from the DSN in the setup scripts

This is an automated email from the ASF dual-hosted git repository.

lahirujayathilake pushed a commit to branch pearc26
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git

commit efa1ed223a3c3accdc15301477b91ab74ca11952
Author: lahiruj <la...@gmail.com>
AuthorDate: Thu Jul 16 11:46:26 2026 -0400

    Read database credentials from the DSN in the setup scripts
---
 dev-ops/compose/seeds/pearc26/setup-live.sh | 10 +++++++++-
 scripts/reset-trial-test-user.sh            | 10 +++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/dev-ops/compose/seeds/pearc26/setup-live.sh b/dev-ops/compose/seeds/pearc26/setup-live.sh
index 4895800cd..275a8af41 100755
--- a/dev-ops/compose/seeds/pearc26/setup-live.sh
+++ b/dev-ops/compose/seeds/pearc26/setup-live.sh
@@ -13,7 +13,15 @@ set -euo pipefail
 cd "$(dirname "$0")/../../../.."
 
 API="${CUSTOS_API:-http://localhost:8080}"
-DB_EXEC=(docker exec -i custos_db mariadb -u admin -padmin custos)
+# DB credentials come from DATABASE_DSN when present (deployment hosts
+# differ from the local compose defaults).
+DB_USER=admin; DB_PASS=admin
+if [ -f .env ] && grep -q "^DATABASE_DSN=" .env; then
+  _dsn=$(grep "^DATABASE_DSN=" .env | cut -d= -f2- | tr -d '"' | tr -d "'")
+  DB_USER=$(echo "$_dsn" | cut -d: -f1)
+  DB_PASS=$(echo "$_dsn" | sed -E 's/^[^:]*:([^@]*)@.*/\1/')
+fi
+DB_EXEC=(docker exec -i custos_db mariadb -u"$DB_USER" -p"$DB_PASS" custos)
 
 set -a; source .env; set +a
 : "${CUSTOS_CLUSTER_ID:?missing in .env}"
diff --git a/scripts/reset-trial-test-user.sh b/scripts/reset-trial-test-user.sh
index 4de0643cd..94a7abd14 100755
--- a/scripts/reset-trial-test-user.sh
+++ b/scripts/reset-trial-test-user.sh
@@ -17,7 +17,15 @@ cd "$(dirname "$0")/.."
 EMAIL="${1:-lahirujayathilake@gmail.com}"
 CONFIRM="${2:-}"
 CLUSTER="exouser@149.165.159.51"
-DB_EXEC=(docker exec -i custos_db mariadb -u admin -padmin custos)
+# DB credentials come from DATABASE_DSN when present (deployment hosts
+# differ from the local compose defaults).
+DB_USER=admin; DB_PASS=admin
+if [ -f .env ] && grep -q "^DATABASE_DSN=" .env; then
+  _dsn=$(grep "^DATABASE_DSN=" .env | cut -d= -f2- | tr -d '"' | tr -d "'")
+  DB_USER=$(echo "$_dsn" | cut -d: -f1)
+  DB_PASS=$(echo "$_dsn" | sed -E 's/^[^:]*:([^@]*)@.*/\1/')
+fi
+DB_EXEC=(docker exec -i custos_db mariadb -u"$DB_USER" -p"$DB_PASS" custos)
 
 set -a; source .env; set +a
 : "${COMANAGE_REGISTRY_URL:?missing in .env}" "${COMANAGE_CO_ID:?}" "${COMANAGE_API_USER:?}" "${COMANAGE_API_KEY:?}"