-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
42 lines (34 loc) · 859 Bytes
/
entrypoint.sh
File metadata and controls
42 lines (34 loc) · 859 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
40
41
42
#!/bin/bash
set -eo pipefail
shopt -s nullglob
source ./paths.sh
source "${LIB_PATH}/core/logging.sh"
source "${LIB_PATH}/postgres-config.sh"
source "${LIB_PATH}/cleanup-functions.sh"
# Set up cleanup trap
trap cleanup SIGTERM SIGINT EXIT
# Main entrypoint logic
main() {
# Environment setup
HOST=${HOST:-localhost}
PORT=${POSTGRES_PORT:-5432}
NODE_ID="${HOSTNAME:-$(hostname)}:${PORT}"
# Check if command starts with an option
if [ "${1:0:1}" = '-' ]; then
set -- postgres "$@"
fi
# Check for help flags
for arg; do
case "$arg" in
--help|--version|-V)
exec "$@"
;;
esac
done
if [ "$1" = 'postgres' ]; then
exec "${LIB_PATH}/standalone-start.sh" "$@"
fi
# If we got here, just execute the command
exec "$@"
}
main "$@"