[IMP] use PG var envs to find the database

This commit is contained in:
Samus CTO 2015-02-27 15:17:44 +01:00
parent 5829e2968d
commit 097483779d
2 changed files with 10 additions and 28 deletions

View File

@ -1,9 +1,9 @@
[options] [options]
addons_path = /usr/lib/python2.7/dist-packages/openerp/addons addons_path = /usr/lib/python2.7/dist-packages/openerp/addons
db_host = False ; db_host = False
db_password = False ; db_password = False
db_port = False ; db_port = False
db_user = odoo ; db_user = odoo
; admin_passwd = admin ; admin_passwd = admin
; auto_reload = False ; auto_reload = False
; csv_internal_sep = , ; csv_internal_sep = ,

View File

@ -1,28 +1,10 @@
#!/bin/bash #!/bin/bash
[ "$1" != "--" ] && exec "$@" || shift # set odoo database host, port, user and password
export PGHOST=$DB_PORT_5432_TCP_ADDR
CONFIG_FILE=/etc/odoo/openerp-server.conf export PGPORT=$DB_PORT_5432_TCP_PORT
export PGUSER=$DB_ENV_POSTGRES_USER
# sets a configuration variable in openerp-server.conf export PGPASSWORD=$DB_ENV_POSTGRES_PASSWORD
# $1: key, $2: value
function set_config {
temp=`mktemp`
if grep -q "^$1.*" $CONFIG_FILE
then
sed "s/^$1.*$/$1 = $2/" $CONFIG_FILE > $temp
else
sed "$ a$1 = $2" $CONFIG_FILE > $temp
fi
cat $temp > $CONFIG_FILE
}
# set odoo data directory and database host, port, user and password
set_config "data_dir" "\/var\/lib\/odoo"
set_config "db_host" $DB_PORT_5432_TCP_ADDR
set_config "db_port" $DB_PORT_5432_TCP_PORT
set_config "db_user" $DB_ENV_POSTGRES_USER
set_config "db_password" $DB_ENV_POSTGRES_PASSWORD
# start Odoo # start Odoo
exec /usr/bin/openerp-server --config $CONFIG_FILE "$@" exec /usr/bin/openerp-server --config=/etc/odoo/openerp-server.conf "$@"