#!/bin/bash # Check if username and password arguments are provided if [ $# -ne 2 ]; then echo "Usage: $0 " exit 1 fi username=$1 password=$2 # Install PostgreSQL sudo apt-get update sudo apt-get install -y postgresql # Create a new database named "jfl" sudo -u postgres psql -c "CREATE DATABASE $username;" # Create a user with provided username and password sudo -u postgres psql -c "CREATE USER $username WITH PASSWORD '$password';" # Grant all privileges on the "jfl" database to the user sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $username TO $username;" # Grant permission to create and delete databases sudo -u postgres psql -c "ALTER USER $username CREATEDB;" echo "Database setup complete."