Synapse/manifests/bridges/discord/create_db.sh

15 lines
491 B
Bash
Raw Permalink Normal View History

2024-12-16 15:52:47 +00:00
#!/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