#!/usr/bin/env bash
# to execute, open a terminal in directory and run chmod +x <filename>.sh
user="{user name}"
database="{database name}"
args="--host=localhost --dbname=$database --username=$user"
echo -e "Creating user $user.....
"
sudo -u postgres createuser --createdb --pwprompt $user
echo -e "User Created!
"
echo -e "Creating database $database.....
"
sudo -u postgres createdb --owner=$user $database
echo -e "Database Created!
"
echo -e "Restarting server and starting psql....
"
sudo service postgresql restart
psql $args