Export PGPORT is not enough, because sudo clears the environment. Whoops.
- sudo -u postgres psql -h postgres -c "CREATE USER $USERNAME" template1
- sudo -u postgres psql -h postgres -c "ALTER TABLESPACE user_$USERNAME OWNER TO $USERNAME"
+ sudo -u postgres psql -h postgres -p $PGPORT -c "CREATE USER $USERNAME" template1
+ sudo -u postgres psql -h postgres -p $PGPORT -c "ALTER TABLESPACE user_$USERNAME OWNER TO $USERNAME"
ENCODING="-E $ENCODING"
fi
ENCODING="-E $ENCODING"
fi
- sudo -u postgres createdb -h postgres -O $USERNAME -D user_$USERNAME $ENCODING $DBNAME
+ sudo -u postgres createdb -h postgres -p $PGPORT -O $USERNAME -D user_$USERNAME $ENCODING $DBNAME
DBNAME_BASE=$4
DBNAME="${USERNAME}_${DBNAME_BASE}"
DBNAME_BASE=$4
DBNAME="${USERNAME}_${DBNAME_BASE}"
- sudo -u postgres dropdb -h postgres $DBNAME
+ sudo -u postgres dropdb -h postgres -p $PGPORT $DBNAME