postgres-init-db: Don't duplicate lines in .pgpass

(imported from commit 2a9d56a2aee2a7fcb2c12e4647bdfedabaee390b)
This commit is contained in:
Zev Benjamin 2014-01-30 17:42:25 -05:00
parent 8767c33536
commit 655bacc06d
1 changed files with 4 additions and 1 deletions

View File

@ -33,7 +33,10 @@ ALTER ROLE $USERNAME SET search_path TO $SEARCH_PATH;
EOF
umask go-rw
echo "*:*:*:$USERNAME:$PASSWORD" >> ~/.pgpass
PGPASS_LINE="*:*:*:$USERNAME:$PASSWORD"
if ! $(grep -q "$PGPASS_LINE" ~/.pgpass); then
echo $PGPASS_LINE >> ~/.pgpass
fi
chmod go-rw ~/.pgpass
psql -h localhost postgres $USERNAME <<EOF