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