From c383c3c31de4b589c2b097637d54a8428cc7c51c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Mon, 20 Dec 2021 22:59:58 +0100 Subject: [PATCH] Improve readability of initialize and start scripts --- .../kubefiles/runboat-clone-and-install.sh | 16 ++++------------ src/runboat/kubefiles/runboat-initialize.sh | 3 +-- src/runboat/kubefiles/runboat-start.sh | 17 ++++++++++++----- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/runboat/kubefiles/runboat-clone-and-install.sh b/src/runboat/kubefiles/runboat-clone-and-install.sh index d6af904..d666548 100755 --- a/src/runboat/kubefiles/runboat-clone-and-install.sh +++ b/src/runboat/kubefiles/runboat-clone-and-install.sh @@ -2,21 +2,12 @@ set -ex - -# If it exists, copy the previously initialized venv. -if [ -f /mnt/data/initialized ] ; then - pip list - # Install 'deb' external dependencies of all Odoo addons found in path. - DEBIAN_FRONTEND=noninteractive apt-get install -qq --no-install-recommends $(oca_list_external_dependencies deb) - exit 0 -fi - -DEBIAN_FRONTEND=noninteractive apt-get -yqq install rsync +# Remove initialization sentinel, in case we are reinitializing. +rm -fr /mnt/data/initialized # Remove addons dir, in case we are reinitializing after a previously # failed installation. rm -fr $ADDONS_DIR - # Clone the repository at git reference into $ADDONS_DIR. git clone --quiet --filter=blob:none $RUNBOAT_GIT_REPO $ADDONS_DIR cd $ADDONS_DIR @@ -27,6 +18,7 @@ git checkout build oca_install_addons # Keep a copy of the venv that we can re-use for shorter startup time. -rsync -a /opt/odoo-venv/ /mnt/data/odoo-venv +DEBIAN_FRONTEND=noninteractive apt-get -yqq install rsync +rsync -a --delete /opt/odoo-venv/ /mnt/data/odoo-venv touch /mnt/data/initialized diff --git a/src/runboat/kubefiles/runboat-initialize.sh b/src/runboat/kubefiles/runboat-initialize.sh index 9d8eba5..a4c9fdc 100755 --- a/src/runboat/kubefiles/runboat-initialize.sh +++ b/src/runboat/kubefiles/runboat-initialize.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# Install all addons in the test database. +# Clone repo and install all addons in the test database. # set -ex @@ -17,7 +17,6 @@ ADDONS=$(addons --addons-dir ${ADDONS_DIR} --include "${INCLUDE}" --exclude "${E unbuffer $(which odoo || which openerp-server) \ --data-dir=/mnt/data/odoo-data-dir \ - --db-template=template1 \ -d ${PGDATABASE} \ -i ${ADDONS:-base} \ --stop-after-init diff --git a/src/runboat/kubefiles/runboat-start.sh b/src/runboat/kubefiles/runboat-start.sh index ba68511..55fe4e2 100755 --- a/src/runboat/kubefiles/runboat-start.sh +++ b/src/runboat/kubefiles/runboat-start.sh @@ -6,16 +6,23 @@ set -ex -bash /runboat/runboat-clone-and-install.sh +if [ ! -f /mnt/data/initialized ] ; then + echo "Build is not initialized. Cannot start." + exit 1 +fi + +# show what is installed (the venv in /opt/odoo-venv has been mounted) +pip list + +# Install 'deb' external dependencies of all Odoo addons found in path. +DEBIAN_FRONTEND=noninteractive apt-get install -qq --no-install-recommends $(oca_list_external_dependencies deb) oca_wait_for_postgres - -# --db_user and --db_filter is necessary for Odoo <= 10 - +# --db_user is necessary for Odoo <= 10 unbuffer $(which odoo || which openerp-server) \ --data-dir=/mnt/data/odoo-data-dir \ --no-database-list \ - -d ${PGDATABASE} \ + --database ${PGDATABASE} \ --db-filter=^${PGDATABASE} \ --db_user=${PGUSER}