mirror of https://github.com/zulip/zulip.git
Create vagrant postgres user and grant it rights to zulip{,_test}
(imported from commit bb57a3f5ef8bc48553f1eff95c47894aed4ef975)
This commit is contained in:
parent
7cffb41e13
commit
54adbb1737
|
@ -7,6 +7,8 @@ if [ "$(uname)" = "Darwin" ]; then
|
|||
DEFAULT_DB="postgres"
|
||||
fi
|
||||
|
||||
VAGRANTUSERNAME=$(whoami)
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
USERNAME=zulip
|
||||
PASSWORD=$($(dirname $0)/../bin/get-django-setting LOCAL_DATABASE_PASSWORD)
|
||||
|
@ -30,6 +32,19 @@ $ROOT_POSTGRES $DEFAULT_DB << EOF
|
|||
CREATE USER $USERNAME WITH PASSWORD '$PASSWORD';
|
||||
ALTER USER $USERNAME CREATEDB;
|
||||
ALTER ROLE $USERNAME SET search_path TO $SEARCH_PATH;
|
||||
|
||||
DO \$\$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT * FROM pg_catalog.pg_user WHERE usename -- [sic]
|
||||
= '$VAGRANTUSERNAME') THEN
|
||||
|
||||
CREATE USER $VAGRANTUSERNAME;
|
||||
END IF;
|
||||
END
|
||||
\$\$ ;
|
||||
GRANT $USERNAME TO $VAGRANTUSERNAME;
|
||||
ALTER ROLE $VAGRANTUSERNAME SET search_path TO $SEARCH_PATH;
|
||||
EOF
|
||||
|
||||
umask go-rw
|
||||
|
|
Loading…
Reference in New Issue