odoo/entrypoint.d/001_set_report_url

28 lines
715 B
Bash
Executable File

#!/bin/sh
# link: https://github.com/camptocamp/docker-odoo-project
if [ -n "${ODOO_REPORT_URL}" ]; then
if [ "$( psql -tAc "SELECT 1 FROM pg_database WHERE datname='${DB_NAME}'" )" != '1' ]
then
echo "Database does not exist, ignoring script"
exit 0
fi
echo "Setting Report URL to domain ${ODOO_REPORT_URL}"
psql --quiet << EOF
WITH update_param AS (
UPDATE ir_config_parameter
SET value = '${ODOO_REPORT_URL}'
WHERE key = 'report.url'
RETURNING *
)
INSERT INTO ir_config_parameter
(value, key, create_uid, write_uid, create_date, write_date)
SELECT '${ODOO_REPORT_URL}', 'report.url', 1, 1, now(), now()
WHERE NOT EXISTS (SELECT * FROM update_param);
EOF
fi