Skip to content

Commit b8e9cd4

Browse files
committed
[FIX] Odoo 8.0-10.0: override of config file pg credentials
We tried to remove usage of environment variables to set the connection parameters to the postgres database but we omit the case when they're set in the config file related to a3d207f Fixes #80
1 parent bb4cc45 commit b8e9cd4

File tree

3 files changed

+48
-9
lines changed

3 files changed

+48
-9
lines changed

10.0/entrypoint.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,26 @@
22

33
set -e
44

5-
# set the postgres database host, port, user and password
5+
# set the postgres database host, port, user and password according to the environment
6+
# and pass them as arguments to the odoo process if not present in the config file
67
: ${HOST:=${DB_PORT_5432_TCP_ADDR:='db'}}
78
: ${PORT:=${DB_PORT_5432_TCP_PORT:=5432}}
89
: ${USER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='odoo'}}}
910
: ${PASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=${POSTGRES_PASSWORD:='odoo'}}}
10-
# pass them as arguments to the odoo process
11-
DB_ARGS=("--db_user" $USER "--db_password" $PASSWORD "--db_host" $HOST "--db_port" $PORT)
11+
12+
DB_ARGS=()
13+
function check_config() {
14+
param="$1"
15+
value="$2"
16+
if ! grep -q -E "^\s*\b${param}\b\s*=" "$ODOO_RC" ; then
17+
DB_ARGS+=("--${param}")
18+
DB_ARGS+=("${value}")
19+
fi;
20+
}
21+
check_config "db_host" "$HOST"
22+
check_config "db_port" "$PORT"
23+
check_config "db_user" "$USER"
24+
check_config "db_password" "$PASSWORD"
1225

1326
case "$1" in
1427
-- | odoo)

8.0/entrypoint.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,26 @@
22

33
set -e
44

5-
# set the postgres database host, port, user and password
5+
# set the postgres database host, port, user and password according to the environment
6+
# and pass them as arguments to the odoo process if not present in the config file
67
: ${HOST:=${DB_PORT_5432_TCP_ADDR:='db'}}
78
: ${PORT:=${DB_PORT_5432_TCP_PORT:=5432}}
89
: ${USER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='odoo'}}}
910
: ${PASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=${POSTGRES_PASSWORD:='odoo'}}}
10-
# pass them as arguments to the odoo process
11-
DB_ARGS=("--db_user" $USER "--db_password" $PASSWORD "--db_host" $HOST "--db_port" $PORT)
11+
12+
DB_ARGS=()
13+
function check_config() {
14+
param="$1"
15+
value="$2"
16+
if ! grep -q -E "^\s*\b${param}\b\s*=" "$OPENERP_SERVER" ; then
17+
DB_ARGS+=("--${param}")
18+
DB_ARGS+=("${value}")
19+
fi;
20+
}
21+
check_config "db_host" "$HOST"
22+
check_config "db_port" "$PORT"
23+
check_config "db_user" "$USER"
24+
check_config "db_password" "$PASSWORD"
1225

1326
case "$1" in
1427
-- | openerp-server)

9.0/entrypoint.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,26 @@
22

33
set -e
44

5-
# set the postgres database host, port, user and password
5+
# set the postgres database host, port, user and password according to the environment
6+
# and pass them as arguments to the odoo process if not present in the config file
67
: ${HOST:=${DB_PORT_5432_TCP_ADDR:='db'}}
78
: ${PORT:=${DB_PORT_5432_TCP_PORT:=5432}}
89
: ${USER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='odoo'}}}
910
: ${PASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=${POSTGRES_PASSWORD:='odoo'}}}
10-
# pass them as arguments to the odoo process
11-
DB_ARGS=("--db_user" $USER "--db_password" $PASSWORD "--db_host" $HOST "--db_port" $PORT)
11+
12+
DB_ARGS=()
13+
function check_config() {
14+
param="$1"
15+
value="$2"
16+
if ! grep -q -E "^\s*\b${param}\b\s*=" "$OPENERP_SERVER" ; then
17+
DB_ARGS+=("--${param}")
18+
DB_ARGS+=("${value}")
19+
fi;
20+
}
21+
check_config "db_host" "$HOST"
22+
check_config "db_port" "$PORT"
23+
check_config "db_user" "$USER"
24+
check_config "db_password" "$PASSWORD"
1225

1326
case "$1" in
1427
-- | openerp-server)

0 commit comments

Comments
 (0)