Synapse/manifests/bridges/whatsapp/create_db.sh

15 lines
501 B
Bash
Raw Permalink Normal View History

2024-12-16 10:53:36 +00:00
#!/bin/bash
echo "Checking if $WHATSAPP_DB database exists..."
if psql -lqt | cut -d \| -f 1 | grep -qw $WHATSAPP_DB; then
echo "Database exists, skipping creation"
else
echo "Database does not exist, creating..."
createdb $WHATSAPP_DB
createuser $WHATSAPP_USER
psql -c "ALTER USER $WHATSAPP_USER WITH ENCRYPTED PASSWORD '$WHATSAPP_PASSWORD';"
psql -c "GRANT ALL PRIVILEGES ON DATABASE $WHATSAPP_DB TO $WHATSAPP_USER;"
psql -c "ALTER DATABASE $WHATSAPP_DB OWNER TO $WHATSAPP_USER;"
fi