From f691c6896ff460b403add836f829daf1c1cf18d1 Mon Sep 17 00:00:00 2001 From: Ken Sternberg Date: Mon, 25 Sep 2023 12:50:59 -0700 Subject: [PATCH] core/allow alternative postgres credentials This commit allows the `dev-reset` command in the Makefile to pick up and use credentials from the `.env` file if they are present, or fallback to the defaults provided if they are not. This is the only place in the Makefile where the database credentials are used directly against postgresql binaries. The syntax was tested with bash, zsh, and csh, and did not fail under those. The `$${:-}` syntax is a combination of a Makefile idiom for "Pass a single `$` to the environment where this command will be executed," and the shell expresion `${VARIABLE:-default}` means "dereference the environment variable; if it is undefined, used the default value provided." --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 4750b17ef..45e46e5a1 100644 --- a/Makefile +++ b/Makefile @@ -219,9 +219,9 @@ install: web-install website-install poetry install dev-reset: - dropdb -U postgres -h localhost authentik + dropdb -U $${PG_USER:-postgres} -h $${PG_HOST:-localhost} $${PG_DB:-authentik} # Also remove the test-db if it exists - dropdb -U postgres -h localhost test_authentik || true - createdb -U postgres -h localhost authentik + dropdb -U $${PG_USER:-postgres} -h $${PG_HOST:-localhost} test_authentik || true + createdb -U $${PG_USER:-postgres} -h $${PG_HOST:-localhost} $${PG_DB:-authentik} redis-cli -n 0 flushall make migrate