Update DB password if exists

Update DB password on boot in 2 container setup from env if exists
This commit is contained in:
Jeff Wong 2025-06-23 10:14:03 -07:00
parent 136aefe49d
commit 698099d4d4
No known key found for this signature in database
GPG Key ID: D4EEB78E484F8A83
1 changed files with 3 additions and 0 deletions

View File

@ -263,6 +263,9 @@ run:
su postgres -c 'psql $db_name -c "create extension if not exists vector;"'
su postgres -c 'psql $db_name -c "alter extension vector update;"' || true
sudo -u postgres psql $db_name <<< "update pg_database set encoding = pg_char_to_encoding('UTF8') where datname = '$db_name' AND encoding = pg_char_to_encoding('SQL_ASCII');" || true
if [ ! -z "$DISCOURSE_DB_PASSWORD" ]; then
echo "alter user $db_user with password '$DISCOURSE_DB_PASSWORD';" | su - postgres -c 'psql $db_name'
fi
- file:
path: /var/lib/postgresql/take-database-backup