15 lines
511 B
Bash
15 lines
511 B
Bash
#!/bin/bash
|
|
|
|
echo "Checking if $MESSENGER_DB database exists..."
|
|
|
|
if psql -lqt | cut -d \| -f 1 | grep -qw $MESSENGER_DB; then
|
|
echo "Database exists, skipping creation"
|
|
else
|
|
echo "Database does not exist, creating..."
|
|
createdb $MESSENGER_DB
|
|
createuser $MESSENGER_USER
|
|
psql -c "ALTER USER $MESSENGER_USER WITH ENCRYPTED PASSWORD '$MESSENGER_PASSWORD';"
|
|
psql -c "GRANT ALL PRIVILEGES ON DATABASE $MESSENGER_DB TO $MESSENGER_USER;"
|
|
psql -c "ALTER DATABASE $MESSENGER_DB OWNER TO $MESSENGER_USER;"
|
|
fi
|