Skip to content

Commit ba79c2b

Browse files
committed
leave PG* env vars be when PGSERVICE is defined
1 parent 88b67cc commit ba79c2b

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed
Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
# handle legacy DB_SSL configuration, as we couldn't conditionally template that in docker-compose.yml
2-
if [[ -v DB_SSL && "${DB_SSL}" = "true" ]]; then
3-
if [[ -v PGSSLMODE && -v PGREQUIRESSL ]]; then
4-
export PGSSLMODE="require"
5-
else
6-
echo "Fatal: legacy 'DB_SSL=true' specified, but PGSSLMODE or PGREQUIRESSL has already been set. To resolve ambiguity, remove 'DB_SSL=true' from your .env file." > /dev/stderr
7-
exit 100
1+
# if the PGSERVICE mechanism — libpq named configurations (specified through this env var)
2+
# sourced from a file (referenced through PGSERVICEFILE env var) is used, leave everything be.
3+
if ! [[ -v PGSERVICE ]]; then
4+
5+
# handle legacy DB_SSL configuration, as we couldn't conditionally template that in docker-compose.yml
6+
if [[ -v DB_SSL && "${DB_SSL}" = "true" ]]; then
7+
if [[ -v PGSSLMODE && -v PGREQUIRESSL ]]; then
8+
export PGSSLMODE="require"
9+
else
10+
echo "Fatal: legacy 'DB_SSL=true' specified, but PGSSLMODE or PGREQUIRESSL has already been set. To resolve ambiguity, remove 'DB_SSL=true' from your .env file." > /dev/stderr
11+
exit 100
12+
fi
813
fi
9-
fi
1014

11-
# handle other legacy DB_* configuration, and fill in our defaults if nothing is specified
12-
# When these PG* variables are _defined_ (even if _empty_), they will be left as-is.
13-
[[ -v PGHOST ]] || export PGHOST=${DB_HOST:-postgres14}
14-
[[ -v PGUSER ]] || export PGUSER=${DB_USER:-odk}
15-
[[ -v PGPASSWORD ]] || export PGPASSWORD=${DB_PASSWORD:-odk}
16-
[[ -v PGDATABASE ]] || export PGDATABASE=${DB_NAME:-odk}
17-
[[ -v PGAPPNAME ]] || export PGAPPNAME=odkcentral
15+
# handle other legacy DB_* configuration, and fill in our defaults if nothing is specified
16+
# When these PG* variables are _defined_ (even if _empty_), they will be left as-is.
17+
[[ -v PGHOST ]] || export PGHOST=${DB_HOST:-postgres14}
18+
[[ -v PGUSER ]] || export PGUSER=${DB_USER:-odk}
19+
[[ -v PGPASSWORD ]] || export PGPASSWORD=${DB_PASSWORD:-odk}
20+
[[ -v PGDATABASE ]] || export PGDATABASE=${DB_NAME:-odk}
21+
[[ -v PGAPPNAME ]] || export PGAPPNAME=odkcentral
22+
23+
fi

0 commit comments

Comments
 (0)