-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-postgresql.sh
More file actions
39 lines (31 loc) · 959 Bytes
/
start-postgresql.sh
File metadata and controls
39 lines (31 loc) · 959 Bytes
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
#!/usr/bin/env bash
# This script will run as the postgres user due to the Dockerfile USER directive
set -e
# Setup postgres CONF file
source /env-data.sh
# Setup ssl
source /setup-ssl-certificates.sh
# Optimize kernel
source /optimize-kernel.sh
if [ -z "$REPLICATE_FROM" ]; then
# This means this is a master instance. We check that database exists
echo "Setup master database"
source /setup-database.sh
else
# This means this is a slave/replication instance.
echo "Setup slave database"
source /setup-replication.sh
fi
# If no arguments passed to entrypoint, then run postgres by default
if [ $# -eq 0 ];
then
echo "Start Postgres in foreground"
su - postgres -c "$SETVARS $POSTGRES -D $DATADIR -c config_file=$CONF"
fi
# If arguments passed, run postgres with these arguments
# This will make sure entrypoint will always be executed
if [ "${1:0:1}" = '-' ]; then
# append postgres into the arguments
set -- postgres "$@"
fi
exec su - "$@"