#!/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