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