Skip to content

Commit b48e45b

Browse files
committed
Fixes to create-user-db
1 parent c24194b commit b48e45b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

commands/create-user-db

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ wait_postgres
3333

3434
# Is this a bad idea?
3535
# Required for the GRANT below
36-
current_user="${user:-${PGUSER:-${USER}}}"
37-
36+
current_user="${username:-${PGUSER:-${USER}}}"
3837

3938
echoerr ">>> Creating new user (ROLE)"
4039
# Check is new user already exists
@@ -44,7 +43,7 @@ if [[ "$(/usr/bin/psql "${connection[@]}" -tAc "SELECT 1 FROM pg_roles WHERE rol
4443
new_password="$(genpasswd)"
4544
echoerr ">>> Generated a random password: ${new_password}"
4645
else
47-
new_password="${args[2]}"
46+
new_password="${args[1]}"
4847
fi
4948
/usr/bin/psql "${connection[@]}" -c "CREATE ROLE ${new_user} WITH LOGIN PASSWORD '${new_password}';"
5049
else
@@ -70,9 +69,9 @@ else
7069
# shellcheck disable=SC2034
7170
dbname="${new_user}"
7271
connection=()
73-
for item in host port user dbname; do
72+
for item in host port username dbname; do
7473
if [[ -n "${!item:-}" ]]; then
75-
connection+=("--${item}" "${!item}")
74+
connection+=("--${item}=${!item}")
7675
fi
7776
done
7877

0 commit comments

Comments
 (0)