-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
57 lines (45 loc) · 1.36 KB
/
entrypoint.sh
File metadata and controls
57 lines (45 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
set -euo pipefail
POSTGRES_CONFIG_FILE_DEFAULT="/etc/postgresql/postgresql.conf"
POSTGRES_HBA_FILE_DEFAULT="/etc/postgresql/pg_hba.conf"
POSTGRES_CONFIG_FILE="${POSTGRES_CONFIG_FILE:-$POSTGRES_CONFIG_FILE_DEFAULT}"
POSTGRES_HBA_FILE="${POSTGRES_HBA_FILE:-$POSTGRES_HBA_FILE_DEFAULT}"
# Render pgbackrest.conf from the template using env vars if template exists.
if [ -f /usr/local/share/pgbackrest/pgbackrest.conf.template ]; then
envsubst </usr/local/share/pgbackrest/pgbackrest.conf.template >/etc/pgbackrest/pgbackrest.conf
else
# Generate a minimal default pgbackrest.conf
cat >/etc/pgbackrest/pgbackrest.conf <<EOF
[global]
repo1-path=/var/lib/pgbackrest
repo1-retention-full=7
repo1-retention-diff=30
process-max=4
log-level-console=info
log-path=/var/log/pgbackrest
[main]
pg1-path=/var/lib/postgresql/data
EOF
fi
has_postgres_setting() {
local key="$1"
shift
for arg in "$@"; do
case "$arg" in
*"${key}="*)
return 0
;;
esac
done
return 1
}
args=("$@")
if [ "${#args[@]}" -gt 0 ] && [ "${args[0]}" = "postgres" ]; then
if ! has_postgres_setting "config_file" "${args[@]}"; then
args+=("-c" "config_file=${POSTGRES_CONFIG_FILE}")
fi
if ! has_postgres_setting "hba_file" "${args[@]}"; then
args+=("-c" "hba_file=${POSTGRES_HBA_FILE}")
fi
fi
exec /usr/local/bin/docker-entrypoint.sh "${args[@]}"