mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
Fix postgres users when re-provisioning
If we run provision.py a second time, there will already be zulip/zulip_test users, so the CREATE USER will fail and the password won't get updated to the newly generated value. By creating the user and setting the password in two commands, we allow the creation to fail without affecting whether the password is set. Also the quoting for updating .pgpass was wrong. (imported from commit 5e249813c17cb4829e4e4958e92aaa30563c5f96)
This commit is contained in:
@@ -29,7 +29,8 @@ fi
|
||||
DBNAME_BASE=${DBNAME}_base
|
||||
|
||||
$ROOT_POSTGRES $DEFAULT_DB << EOF
|
||||
CREATE USER $USERNAME WITH PASSWORD '$PASSWORD';
|
||||
CREATE USER $USERNAME;
|
||||
ALTER USER $USERNAME PASSWORD '$PASSWORD';
|
||||
ALTER USER $USERNAME CREATEDB;
|
||||
ALTER ROLE $USERNAME SET search_path TO $SEARCH_PATH;
|
||||
|
||||
@@ -53,7 +54,7 @@ PGPASS_ESCAPED_PREFIX="*:\*:\*:$USERNAME:"
|
||||
if ! $(grep -q "$PGPASS_ESCAPED_PREFIX" ~/.pgpass); then
|
||||
echo $PGPASS_PREFIX$PASSWORD >> ~/.pgpass
|
||||
else
|
||||
sed -i 's/$PGPASS_ESCAPED_PREFIX.*$/$PGPASS_PREFIX$PASSWORD/' ~/.pgpass
|
||||
sed -i "s/$PGPASS_ESCAPED_PREFIX.*\$/$PGPASS_PREFIX$PASSWORD/" ~/.pgpass
|
||||
fi
|
||||
chmod go-rw ~/.pgpass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user