Synapse/manifests/bridges/telegram/create_db.sh

15 lines
501 B
Bash
Raw Permalink Normal View History

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