Skip to content

Commit 9cbbc52

Browse files
authored
Merge pull request #144 from rostilos/1.5.1-rc
feat: Update database credential retrieval in server-deploy.sh to avo…
2 parents d51c758 + 5b0a795 commit 9cbbc52

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

deployment/ci/server-deploy.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ mkdir -p "$BACKUP_DIR"
7070
BACKUP_TIMESTAMP=$(date '+%Y%m%d_%H%M%S')
7171
BACKUP_FILE="$BACKUP_DIR/codecrow_pre_deploy_${BACKUP_TIMESTAMP}.sql.gz"
7272

73-
# Read DB credentials from .env
73+
# Read DB credentials from .env (grep instead of source to avoid
74+
# unbound-variable errors from passwords containing $ characters)
7475
DB_NAME="codecrow_ai"
7576
DB_USER="codecrow_user"
7677
if [ -f "$DEPLOY_DIR/.env" ]; then
77-
# shellcheck disable=SC1091
78-
set -a; source "$DEPLOY_DIR/.env"; set +a
79-
DB_NAME="${POSTGRES_DB:-codecrow_ai}"
80-
DB_USER="${POSTGRES_USER:-codecrow_user}"
78+
_val=$(grep -m1 '^POSTGRES_DB=' "$DEPLOY_DIR/.env" | cut -d'=' -f2- | tr -d '[:space:]') && [ -n "$_val" ] && DB_NAME="$_val"
79+
_val=$(grep -m1 '^POSTGRES_USER=' "$DEPLOY_DIR/.env" | cut -d'=' -f2- | tr -d '[:space:]') && [ -n "$_val" ] && DB_USER="$_val"
80+
unset _val
8181
fi
8282

8383
if docker compose -f "$COMPOSE_FILE" ps --status running 2>/dev/null | grep -q postgres; then

0 commit comments

Comments
 (0)