Merge pull request #95 from sbidoul/baseonly-db
Initialize a db with only the base module in case install fails
This commit is contained in:
commit
4dd762ed13
3 changed files with 17 additions and 4 deletions
|
|
@ -3,3 +3,4 @@
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
dropdb --if-exists --force $PGDATABASE
|
dropdb --if-exists --force $PGDATABASE
|
||||||
|
dropdb --if-exists --force $PGDATABASE-baseonly
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,24 @@ bash /runboat/runboat-clone-and-install.sh
|
||||||
oca_wait_for_postgres
|
oca_wait_for_postgres
|
||||||
|
|
||||||
# Drop database, in case we are reinitializing.
|
# Drop database, in case we are reinitializing.
|
||||||
dropdb --if-exists $PGDATABASE
|
dropdb --if-exists ${PGDATABASE}
|
||||||
|
dropdb --if-exists ${PGDATABASE}-baseonly
|
||||||
|
|
||||||
ADDONS=$(manifestoo --select-addons-dir ${ADDONS_DIR} --select-include "${INCLUDE}" --select-exclude "${EXCLUDE}" list --separator=,)
|
ADDONS=$(manifestoo --select-addons-dir ${ADDONS_DIR} --select-include "${INCLUDE}" --select-exclude "${EXCLUDE}" list --separator=,)
|
||||||
|
|
||||||
|
# Try to install all addons, but do not fail in case of error, to let the build start
|
||||||
|
# so users can work with the 'baseonly' database.
|
||||||
unbuffer $(which odoo || which openerp-server) \
|
unbuffer $(which odoo || which openerp-server) \
|
||||||
--data-dir=/mnt/data/odoo-data-dir \
|
--data-dir=/mnt/data/odoo-data-dir \
|
||||||
--db-template=template1 \
|
--db-template=template1 \
|
||||||
-d ${PGDATABASE} \
|
-d ${PGDATABASE} \
|
||||||
-i ${ADDONS:-base} \
|
-i ${ADDONS:-base} \
|
||||||
--stop-after-init
|
--stop-after-init || \
|
||||||
|
# Create the baseonly database if installation failed.
|
||||||
|
(dropdb --if-exists ${PGDATABASE} && \
|
||||||
|
unbuffer $(which odoo || which openerp-server) \
|
||||||
|
--data-dir=/mnt/data/odoo-data-dir \
|
||||||
|
--db-template=template1 \
|
||||||
|
-d ${PGDATABASE}-baseonly \
|
||||||
|
-i base \
|
||||||
|
--stop-after-init)
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@ fi
|
||||||
# show what is installed (the venv in /opt/odoo-venv has been mounted)
|
# show what is installed (the venv in /opt/odoo-venv has been mounted)
|
||||||
pip list
|
pip list
|
||||||
|
|
||||||
|
# Make sure users cannot create databases.
|
||||||
|
echo "admin_passwd=$(python3 -c 'import secrets; print(secrets.token_hex())')" >> ${ODOO_RC}
|
||||||
|
|
||||||
# Add ADDONS_DIR to addons_path (because that oca_install_addons did,
|
# Add ADDONS_DIR to addons_path (because that oca_install_addons did,
|
||||||
# but $ODOO_RC is not on a persistent volume, so it is lost when we
|
# but $ODOO_RC is not on a persistent volume, so it is lost when we
|
||||||
# start in another container).
|
# start in another container).
|
||||||
|
|
@ -35,8 +38,6 @@ oca_wait_for_postgres
|
||||||
# --db_user is necessary for Odoo <= 10
|
# --db_user is necessary for Odoo <= 10
|
||||||
unbuffer $(which odoo || which openerp-server) \
|
unbuffer $(which odoo || which openerp-server) \
|
||||||
--data-dir=/mnt/data/odoo-data-dir \
|
--data-dir=/mnt/data/odoo-data-dir \
|
||||||
--no-database-list \
|
|
||||||
--database ${PGDATABASE} \
|
|
||||||
--db-filter=^${PGDATABASE} \
|
--db-filter=^${PGDATABASE} \
|
||||||
--db_user=${PGUSER} \
|
--db_user=${PGUSER} \
|
||||||
--smtp=localhost \
|
--smtp=localhost \
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue