From a3d207f2d49c3a0eb0e959fbf2cb33909c382a3f Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Fri, 28 Oct 2016 15:15:57 +0200 Subject: [PATCH] [REF] Odoo 8.0-10.0: pass pg connection parameters as CLI arguments Do not assume that Odoo will handle correctly the PG* environment variables, because it won't. We also rename the PG* variables in order to avoid confusion since we do not export them anymore. --- 10.0/entrypoint.sh | 17 +++++++++-------- 8.0/entrypoint.sh | 17 +++++++++-------- 9.0/entrypoint.sh | 17 +++++++++-------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/10.0/entrypoint.sh b/10.0/entrypoint.sh index c1e4ecb..208c93d 100755 --- a/10.0/entrypoint.sh +++ b/10.0/entrypoint.sh @@ -2,20 +2,21 @@ set -e -# set odoo database host, port, user and password -: ${PGHOST:=${DB_PORT_5432_TCP_ADDR:='db'}} -: ${PGPORT:=${DB_PORT_5432_TCP_PORT:=5432}} -: ${PGUSER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='postgres'}}} -: ${PGPASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=$POSTGRES_PASSWORD}} -export PGHOST PGPORT PGUSER PGPASSWORD +# set the postgres database host, port, user and password +: ${HOST:=${DB_PORT_5432_TCP_ADDR:='db'}} +: ${PORT:=${DB_PORT_5432_TCP_PORT:=5432}} +: ${USER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='postgres'}}} +: ${PASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=$POSTGRES_PASSWORD}} +# pass them as arguments to the odoo process +DB_ARGS=("--db_user" $USER "--db_password" $PASSWORD "--db_host" $HOST "--db_port" $PORT) case "$1" in --) shift - exec odoo "$@" + exec odoo "${DB_ARGS[@]}" "$@" ;; -*) - exec odoo "$@" + exec odoo "${DB_ARGS[@]}" "$@" ;; *) exec "$@" diff --git a/8.0/entrypoint.sh b/8.0/entrypoint.sh index ce41742..85bc49b 100755 --- a/8.0/entrypoint.sh +++ b/8.0/entrypoint.sh @@ -2,20 +2,21 @@ set -e -# set odoo database host, port, user and password -: ${PGHOST:=${DB_PORT_5432_TCP_ADDR:='db'}} -: ${PGPORT:=${DB_PORT_5432_TCP_PORT:=5432}} -: ${PGUSER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='postgres'}}} -: ${PGPASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=$POSTGRES_PASSWORD}} -export PGHOST PGPORT PGUSER PGPASSWORD +# set the postgres database host, port, user and password +: ${HOST:=${DB_PORT_5432_TCP_ADDR:='db'}} +: ${PORT:=${DB_PORT_5432_TCP_PORT:=5432}} +: ${USER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='postgres'}}} +: ${PASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=$POSTGRES_PASSWORD}} +# pass them as arguments to the odoo process +DB_ARGS=("--db_user" $USER "--db_password" $PASSWORD "--db_host" $HOST "--db_port" $PORT) case "$1" in --) shift - exec openerp-server "$@" + exec openerp-server "${DB_ARGS[@]}" "$@" ;; -*) - exec openerp-server "$@" + exec openerp-server "${DB_ARGS[@]}" "$@" ;; *) exec "$@" diff --git a/9.0/entrypoint.sh b/9.0/entrypoint.sh index ce41742..85bc49b 100755 --- a/9.0/entrypoint.sh +++ b/9.0/entrypoint.sh @@ -2,20 +2,21 @@ set -e -# set odoo database host, port, user and password -: ${PGHOST:=${DB_PORT_5432_TCP_ADDR:='db'}} -: ${PGPORT:=${DB_PORT_5432_TCP_PORT:=5432}} -: ${PGUSER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='postgres'}}} -: ${PGPASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=$POSTGRES_PASSWORD}} -export PGHOST PGPORT PGUSER PGPASSWORD +# set the postgres database host, port, user and password +: ${HOST:=${DB_PORT_5432_TCP_ADDR:='db'}} +: ${PORT:=${DB_PORT_5432_TCP_PORT:=5432}} +: ${USER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='postgres'}}} +: ${PASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=$POSTGRES_PASSWORD}} +# pass them as arguments to the odoo process +DB_ARGS=("--db_user" $USER "--db_password" $PASSWORD "--db_host" $HOST "--db_port" $PORT) case "$1" in --) shift - exec openerp-server "$@" + exec openerp-server "${DB_ARGS[@]}" "$@" ;; -*) - exec openerp-server "$@" + exec openerp-server "${DB_ARGS[@]}" "$@" ;; *) exec "$@"