-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·97 lines (88 loc) · 4.96 KB
/
entrypoint.sh
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh
set -e
export POSTGRES_DB=${POSTGRES_DB:-postgres}
export POSTGRES_HOST=${POSTGRES_HOST:-postgres}
export POSTGRES_PORT=${POSTGRES_PORT:-5432}
export POSTGRES_USER=${POSTGRES_USER:-postgres}
export POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
export PGBOUNCER_USER=${PGBOUNCER_USER:-${POSTGRES_USER}}
export PGBOUNCER_PASS=${PGBOUNCER_PASS:-${POSTGRES_PASSWORD}}
export PGBOUNCER_PASS_MD5=$(echo -n "${PGBOUNCER_PASS}${PGBOUNCER_USER}" | md5sum - | cut -f 1 -d ' ')
export PGBOUNCER_ADMIN_USER=${PGBOUNCER_ADMIN_USER:-${PGBOUNCER_USER}}
export PGBOUNCER_ADMIN_PASS=${PGBOUNCER_ADMIN_PASS:-${PGBOUNCER_PASS}}
export PGBOUNCER_ADMIN_PASS_MD5=$(echo -n "${PGBOUNCER_ADMIN_PASS}${PGBOUNCER_ADMIN_USER}" | md5sum - | cut -f 1 -d ' ')
export PGBOUNCER_STATS_USER=${PGBOUNCER_STATS_USER:-${PGBOUNCER_USER}}
export PGBOUNCER_STATS_PASS=${PGBOUNCER_STATS_PASS:-${PGBOUNCER_PASS}}
export PGBOUNCER_STATS_PASS_MD5=$(echo -n "${PGBOUNCER_STATS_PASS}${PGBOUNCER_STATS_USER}" | md5sum - | cut -f 1 -d ' ')
envsubst < /etc/pgbouncer/auth_file.template | sort -u > /etc/pgbouncer/auth_file
export LISTEN_ADDR=${LISTEN_ADDR:-0.0.0.0}
export LISTEN_PORT=${LISTEN_PORT:-5432}
export POOL_MODE=${POOL_MODE:-session}
export MAX_CLIENT_CONN=${MAX_CLIENT_CONN:-100}
export DEFAULT_POOL_SIZE=${DEFAULT_POOL_SIZE:-20}
export MIN_POOL_SIZE=${MIN_POOL_SIZE:-0}
export RESERVE_POOL_SIZE=${RESERVE_POOL_SIZE:-0}
export RESERVE_POOL_TIMEOUT=${RESERVE_POOL_TIMEOUT:-5.0}
export MAX_DB_CONNECTIONS=${MAX_DB_CONNECTIONS:-0}
export MAX_USER_CONNECTIONS=${MAX_USER_CONNECTIONS:-0}
export SERVER_ROUND_ROBIN=${SERVER_ROUND_ROBIN:-0}
export IGNORE_STARTUP_PARAMETERS=${IGNORE_STARTUP_PARAMETERS:-}
export DISABLE_PQEXEC=${DISABLE_PQEXEC:-0}
export APPLICATION_NAME_ADD_HOST=${APPLICATION_NAME_ADD_HOST:-0}
export STATS_PERIOD=${STATS_PERIOD:-60}
export LOG_CONNECTIONS=${LOG_CONNECTIONS:-1}
export LOG_DISCONNECTIONS=${LOG_DISCONNECTIONS:-1}
export LOG_POOLER_ERRORS=${LOG_POOLER_ERRORS:-1}
export LOG_STATS=${LOG_STATS:-1}
export VERBOSE=${VERBOSE:-0}
export ADMIN_USERS=${ADMIN_USERS:-${POSTGRES_USER}}
export STATS_USERS=${STATS_USERS:-${POSTGRES_USER}}
export SERVER_RESET_QUERY=${SERVER_RESET_QUERY:-DISCARD ALL}
export SERVER_RESET_QUERY_ALWAYS=${SERVER_RESET_QUERY_ALWAYS:-0}
export SERVER_CHECK_DELAY=${SERVER_CHECK_DELAY:-30.0}
export SERVER_CHECK_QUERY=${SERVER_CHECK_QUERY:-select 1}
export SERVER_FAST_CLOSE=${SERVER_FAST_CLOSE:-0}
export SERVER_LIFETIME=${SERVER_LIFETIME:-3600.0}
export SERVER_IDLE_TIMEOUT=${SERVER_IDLE_TIMEOUT:-600.0}
export SERVER_CONNECT_TIMEOUT=${SERVER_CONNECT_TIMEOUT:-15.0}
export SERVER_LOGIN_RETRY=${SERVER_LOGIN_RETRY:-15.0}
export CLIENT_LOGIN_TIMEOUT=${CLIENT_LOGIN_TIMEOUT:-60.0}
export AUTODB_IDLE_TIMEOUT=${AUTODB_IDLE_TIMEOUT:-3600.0}
export DNS_MAX_TTL=${DNS_MAX_TTL:-15.0}
export DNS_NXDOMAIN_TTL=${DNS_NXDOMAIN_TTL:-15.0}
export DNS_ZONE_CHECK_PERIOD=${DNS_ZONE_CHECK_PERIOD:-0.0}
export CLIENT_TLS_SSLMODE=${CLIENT_TLS_SSLMODE:-disable}
export CLIENT_TLS_PROTOCOLS=${CLIENT_TLS_PROTOCOLS:-secure}
export CLIENT_TLS_CIPHERS=${CLIENT_TLS_CIPHERS:-fast}
export CLIENT_TLS_ECDHCURVE=${CLIENT_TLS_ECDHCURVE:-auto}
export CLIENT_TLS_DHEPARAMS=${CLIENT_TLS_DHEPARAMS:-auto}
export SERVER_TLS_SSLMODE=${SERVER_TLS_SSLMODE:-disable}
export SERVER_TLS_PROTOCOLS=${SERVER_TLS_PROTOCOLS:-secure}
export SERVER_TLS_CIPHERS=${SERVER_TLS_CIPHERS:-fast}
export QUERY_TIMEOUT=${QUERY_TIMEOUT:-0.0}
export QUERY_WAIT_TIMEOUT=${QUERY_WAIT_TIMEOUT:-120}
export CLIENT_IDLE_TIMEOUT=${CLIENT_IDLE_TIMEOUT:-0.0}
export IDLE_TRANSACTION_TIMEOUT=${IDLE_TRANSACTION_TIMEOUT:-0.0}
export SUSPEND_TIMEOUT=${SUSPEND_TIMEOUT:-10}
export PKT_BUF=${PKT_BUF:-4096}
export MAX_PACKET_SIZE=${MAX_PACKET_SIZE:-2147483647}
export LISTEN_BACKLOG=${LISTEN_BACKLOG:-128}
export SBUF_LOOPCNT=${SBUF_LOOPCNT:-5}
export SO_REUSEPORT=${SO_REUSEPORT:-0}
export TCP_DEFER_ACCEPT=${TCP_DEFER_ACCEPT:-1}
export TCP_KEEPALIVE=${TCP_KEEPALIVE:-1}
export TCP_USER_TIMEOUT=${TCP_USER_TIMEOUT:-0}
envsubst < /etc/pgbouncer/pgbouncer.ini.template > /etc/pgbouncer/pgbouncer.ini
export CLIENT_TLS_KEY_FILE=${CLIENT_TLS_KEY_FILE:-}
export CLIENT_TLS_CERT_FILE=${CLIENT_TLS_CERT_FILE:-}
export CLIENT_TLS_CA_FILE=${CLIENT_TLS_CA_FILE:-}
[ -f ${CLIENT_TLS_KEY_FILE} ] && echo "client_tls_key_file=${CLIENT_TLS_KEY_FILE}" >> /etc/pgbouncer/pgbouncer.init
[ -f ${CLIENT_TLS_CERT_FILE} ] && echo "client_tls_cert_file=${CLIENT_TLS_CERT_FILE}" >> /etc/pgbouncer/pgbouncer.init
[ -f ${CLIENT_TLS_CA_FILE} ] && echo "client_tls_ca_file=${CLIENT_TLS_CA_FILE}" >> /etc/pgbouncer/pgbouncer.init
export SERVER_TLS_CA_FILE=${SERVER_TLS_CA_FILE:-}
export SERVER_TLS_KEY_FILE=${SERVER_TLS_KEY_FILE:-}
export SERVER_TLS_CERT_FILE=${SERVER_TLS_CERT_FILE:-}
[ -f ${SERVER_TLS_KEY_FILE} ] && echo "server_tls_key_file=${SERVER_TLS_KEY_FILE}" >> /etc/pgbouncer/pgbouncer.init
[ -f ${SERVER_TLS_CERT_FILE} ] && echo "server_tls_cert_file=${SERVER_TLS_CERT_FILE}" >> /etc/pgbouncer/pgbouncer.init
[ -f ${SERVER_TLS_CA_FILE} ] && echo "server_tls_ca_file=${SERVER_TLS_CA_FILE}" >> /etc/pgbouncer/pgbouncer.init
exec $@