Also you don't need to sudo over to psql you can just run psql -U psql < setup_postgresql.sql as the default is to trust the username passed. If not is passed it will use the account name it is running under.
Or you can do something like this.
#!/bin/bash
createuser -U psql -s dummbyuser
createdb -U psql -O dummbyuser dummbyuser
or even using a shell here doc
psql -U psql <<EOF
Create USER dummbyuser;
ALTER USER dummbyuser with superuser;
ALTER USER dummbyuser with LOGIN;
EOF
---answering question from comments---
you can use positional arguments to such as $1 and $2
so for example if your script was called build_sql.sh you could right it like this
#!/bin/bash
createuser -U psql -s $1
createdb -U psql -O $1 $2
and then call it like ./build_sql.sh dummbyuser dummbybd
which would replace $1 with dummbyuser and $2 with dummbydb
or you can prompt the user for input and capture it using the read command
so the same build_sql.sh script could become
#!/bin/bash
echo "please enter username followed by [enter]"
read user
echo "please enter db_name followed by [enter]"
read dbname
createuser -U psql -s $user
createdb -U psql -O $user $dbname
then if you want to be really fancy you can combine them
#!/bin/bash
if [ "$1" != "" ]; then
user=$1
else
echo "please enter username followed by [enter]"
read user
fi
if [ "$2" != "" ]; then
dbname=$2
else
echo "please enter db_name followed by [enter]"
read dbname
fi
createuser -U psql -s $user
createdb -U psql -O $user $dbname
echo "created new user $user, and gave them a db called $dbname"