-
Notifications
You must be signed in to change notification settings - Fork 11
/
docker-entrypoint.sh
executable file
·68 lines (56 loc) · 1.78 KB
/
docker-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
#!/bin/bash
set -e
# 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
: ${PSQL_HOST:=${DB_PORT_5432_TCP_ADDR:='db'}}
: ${PSQL_PORT:=${DB_PORT_5432_TCP_PORT:=5432}}
: ${PSQL_USER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='odoo'}}}
: ${PSQL_PASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=${POSTGRES_PASSWORD:='odoo'}}}
DB_ARGS=("--config=${ODOO_CONFIG}" "--logfile=${ODOO_LOG}")
ADDONS=("/usr/lib/python2.7/site-packages/openerp/addons" \
"/usr/lib/python2.7/site-packages/odoo/addons" \
"/opt/addons" \
"/opt/odoo/addons" \
"/mnt/addons" \
)
# Install requirements.txt and oca_dependencies.txt from root of mount
if [[ "${SKIP_DEPENDS}" != "1" ]] ; then
export VERSION=$ODOO_VERSION
clone_oca_dependencies /opt/community /mnt/addons
# Iterate the newly cloned addons & add into possible dirs
for dir in /opt/community/*/ ; do
ADDONS+=("$dir")
done
VALID_ADDONS="$(get_addons ${ADDONS[*]})"
DB_ARGS+=("--addons-path=${VALID_ADDONS}")
fi
# Pull database from config file if present & validate
function check_config() {
param="$1"
value="$2"
if ! grep -q -E "^\s*\b${param}\b\s*=" "$ODOO_CONFIG" ; then
DB_ARGS+=("--${param}")
DB_ARGS+=("${value}")
fi;
}
check_config "db_host" "$PSQL_HOST"
check_config "db_port" "$PSQL_PORT"
check_config "db_user" "$PSQL_USER"
check_config "db_password" "$PSQL_PASSWORD"
# Execute
case "$1" in
-- | odoo)
shift
if [[ "$1" == "scaffold" ]] ; then
exec odoo "$@"
else
exec odoo "$@" "${DB_ARGS[@]}"
fi
;;
-*)
exec odoo "$@" "${DB_ARGS[@]}"
;;
*)
"$@"
esac
exit 1