Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize a db with only the base module in case install fails #95

Merged
merged 3 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/runboat/kubefiles/runboat-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
set -ex

dropdb --if-exists --force $PGDATABASE
dropdb --if-exists --force $PGDATABASE-baseonly
15 changes: 13 additions & 2 deletions src/runboat/kubefiles/runboat-initialize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,24 @@ bash /runboat/runboat-clone-and-install.sh
oca_wait_for_postgres

# 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=,)

# 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) \
--data-dir=/mnt/data/odoo-data-dir \
--db-template=template1 \
-d ${PGDATABASE} \
-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)
5 changes: 3 additions & 2 deletions src/runboat/kubefiles/runboat-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ fi
# show what is installed (the venv in /opt/odoo-venv has been mounted)
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,
# but $ODOO_RC is not on a persistent volume, so it is lost when we
# start in another container).
Expand All @@ -35,8 +38,6 @@ oca_wait_for_postgres
# --db_user is necessary for Odoo <= 10
unbuffer $(which odoo || which openerp-server) \
--data-dir=/mnt/data/odoo-data-dir \
--no-database-list \
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure users cannot create databases

--database ${PGDATABASE} \
--db-filter=^${PGDATABASE} \
--db_user=${PGUSER} \
--smtp=localhost \
Expand Down
Loading