-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathentrypoint.sh
executable file
·51 lines (45 loc) · 1.46 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
#!/bin/bash
set -e
# Fonctions
##########################################
function check_config() {
param_config="$1"
param_cmdline="$2"
value="$3"
if ! grep -q -E "^\s*\b${param_config}\b\s*=" $ODOO_CFG ; then
echo "ENTRYPOINT: \"$param_config\" not found in config file, add \"$param_cmdline $value\" in command line"
DB_ARGS+=("${param_cmdline}")
DB_ARGS+=("${value}")
else
echo "ENTRYPOINT: \"$param_config\" defined in config file"
fi;
}
# Main
##########################################
# set the postgres database host, port, user and password according to the environment
# and pass them as arguments to the odoo process if not present in the config file
: ${HOST:=${DB_HOST:=${DB_ADDR:='db'}}}
: ${PORT:=${DB_PORT:=5432}}
: ${NAME:=${DB_NAME:='odoo'}}
: ${USER:=${DB_USER:=${POSTGRES_USER:='odoo'}}}
: ${PASSWORD:=${DB_PASSWORD:=${POSTGRES_PASSWORD:='odoo'}}}
DB_ARGS=()
check_config "db_host" "--db_host" "$HOST"
check_config "db_port" "--db_port" "$PORT"
check_config "db_name" "--database" "$NAME"
check_config "db_user" "--db_user" "$USER"
check_config "db_password" "--db_password" "$PASSWORD"
if [[ -v ADDONS_PATHS ]]; then
check_config "addons_path" "--addons-path" "$ADDONS_PATHS"
fi
case "$1" in
-- | openerp-server)
shift
COMMAND="/usr/bin/openerp-server -c $ODOO_CFG $@ ${DB_ARGS[@]}"
;;
*)
COMMAND="$@"
esac
echo "ENTRYPOINT: exec $COMMAND"
exec $COMMAND
exit 0