feat(entrypoint): rename entrypoint-log to log-entrypoint and refactor related scripts

This commit is contained in:
Janik von Rotz committed 2025-08-18 14:52:46 +02:00
1 parent d4c6f24d3e
commit d174954a4d
18 files changed
+52 -47

No files matched your search

+4 -4
View File
@@ -1,7 +1,7 @@
#!/bin/bash
set -e
entrypoint-log() {
log-entrypoint() {
echo "$@"
}
@@ -63,8 +63,8 @@ fi
for MAIL_ALIAS in $MAIL_ALIASES; do
echo "$MAIL_ALIAS: \"|/usr/local/bin/odoo-mailgate.py -l ${ODOO_URL} -d ${ODOO_DATABASE} -u ${ODOO_USERNAME} -p ${ODOO_PASSWORD}${MAIL_MODEL_PARAM}${MAIL_THREAD_ID_PARAM}\"" >> /etc/aliases
newaliases
entrypoint-log "Forward alias $MAIL_ALIAS to Odoo database $ODOO_DATABASE at ${ODOO_HOST}:${ODOO_PORT}."
log-entrypoint "Forward alias $MAIL_ALIAS to Odoo database $ODOO_DATABASE at ${ODOO_HOST}:${ODOO_PORT}."
done
entrypoint-log "Starting Postfix in foreground."
postfix start-fg
log-entrypoint "Starting Postfix in foreground."
postfix start-fg
+2 -2
View File
@@ -206,8 +206,8 @@ The scripts are configured with environment variables.
Once you start the container the `entrypoint.sh` script will:
* Run the `set-addons-path` script to assemble the addons path.
* Run the `auto-envsubst` script to template the `odoo.conf` file.
* Run the `python-install` script to install the Python packages.
* Run the `template-odoo-rc` script to template the `odoo.conf` file.
* Run the `install-python-packages` script to install the Python packages.
* Wait for the database to be ready.
* Run the `update-modules` script to update modules.
* Start the Odoo server.
+7 -7
View File
@@ -10,19 +10,19 @@ if [ -n "$ADDONS_GIT_REPOS" ]; then
mkdir -p ~/.ssh
chmod 700 ~/.ssh
if [ -n "$GIT_SSH_PRIVATE_KEY" ]; then
entrypoint-log "Setup SSH key from env vars."
log-entrypoint "Setup SSH key from env vars."
DECODED_GIT_SSH_PRIVATE_KEY=$(echo -e "$GIT_SSH_PRIVATE_KEY" | base64 -d)
echo "$DECODED_GIT_SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519 || (entrypoint-log "Dumping ~/.ssh/id_ed25519 content:" && cat ~/.ssh/id_ed25519)
ssh-add ~/.ssh/id_ed25519 || (log-entrypoint "Dumping ~/.ssh/id_ed25519 content:" && cat ~/.ssh/id_ed25519)
fi
# Make every git directory a safe directory
git config --global --add safe.directory "*"
# Clone git repo addons into local path
entrypoint-log "Cloning git repos: $ADDONS_GIT_REPOS"
log-entrypoint "Cloning git repos: $ADDONS_GIT_REPOS"
ADDONS_GIT_REPOS=$(echo "$ADDONS_GIT_REPOS" | tr "," "\n")
for ADDON_GIT_REPO in $ADDONS_GIT_REPOS; do
@@ -61,21 +61,21 @@ if [ -n "$ADDONS_GIT_REPOS" ]; then
GIT_URL="${GIT_PROTO}${FORGEJO_USERNAME}:${FORGEJO_PAT}@${GIT_HOSTNAME}/${GIT_PATH}.git"
fi
entrypoint-log "Clone ${GIT_PROTO}${GIT_HOSTNAME} branch $GIT_BRANCH."
log-entrypoint "Clone ${GIT_PROTO}${GIT_HOSTNAME} branch $GIT_BRANCH."
git clone --depth "$GIT_CLONE_DEPTH" --single-branch --branch "$GIT_BRANCH" "$GIT_URL" "$GIT_LOCAL_PATH"
else
entrypoint-log "Pull $GIT_BRANCH branch in $GIT_LOCAL_PATH."
log-entrypoint "Pull $GIT_BRANCH branch in $GIT_LOCAL_PATH."
git -C "$GIT_LOCAL_PATH" switch "$GIT_BRANCH"
git -C "$GIT_LOCAL_PATH" pull
fi
if [ -n "$GIT_COMMIT" ];then
entrypoint-log "Checkout $GIT_COMMIT commit in $GIT_LOCAL_PATH."
log-entrypoint "Checkout $GIT_COMMIT commit in $GIT_LOCAL_PATH."
git -C "$GIT_LOCAL_PATH" checkout "$GIT_COMMIT"
fi
if [ -f "$GIT_LOCAL_PATH/.gitmodules" ]; then
entrypoint-log "Init and update git submodules in $GIT_LOCAL_PATH."
log-entrypoint "Init and update git submodules in $GIT_LOCAL_PATH."
git -C "$GIT_LOCAL_PATH" submodule update --init --recursive --depth "$GIT_CLONE_DEPTH"
fi
done
+1 -1
View File
@@ -7,7 +7,7 @@ fi
LOCAL_PATH="${LOCAL_PATH:="/var/lib/odoo/enterprise"}"
entrypoint-log "Downloading Odoo Enterprise $ODOO_ENTERPRISE_REF to $LOCAL_PATH."
log-entrypoint "Downloading Odoo Enterprise $ODOO_ENTERPRISE_REF to $LOCAL_PATH."
mkdir -p "$LOCAL_PATH"
curl -L -o "$LOCAL_PATH/archive.tar.gz" \
"https://${GITHUB_USERNAME}:${GITHUB_PAT}@github.com/odoo/enterprise/archive/$ODOO_ENTERPRISE_REF.tar.gz"
+6 -6
View File
@@ -2,16 +2,16 @@
if [ -n "$ODOO_DATABASE" ]; then
entrypoint-log "Check if database $ODOO_DATABASE exists."
log-entrypoint "Check if database $ODOO_DATABASE exists."
DATABASE_EXISTS=$(exec psql "postgres://$PGUSER:$PGPASSWORD@$PGHOST:$PGPORT/postgres" -tAc "SELECT COUNT(*) FROM pg_database WHERE datname = '$ODOO_DATABASE'")
# If it does not exist, create it
if [ "$DATABASE_EXISTS" = "0" ]; then
entrypoint-log "Create database $ODOO_DATABASE."
log-entrypoint "Create database $ODOO_DATABASE."
(exec psql "postgres://$PGUSER:$PGPASSWORD@$PGHOST:$PGPORT/postgres" -tAc "CREATE DATABASE \"$ODOO_DATABASE\";") || true
fi
entrypoint-log "Check if database $ODOO_DATABASE is initialized"
log-entrypoint "Check if database $ODOO_DATABASE is initialized"
DATABASE_INITIALIZED=$(exec psql "postgres://$PGUSER:$PGPASSWORD@$PGHOST:$PGPORT/$ODOO_DATABASE" -tAc "SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 'ir_module_module'")
if [ "$DATABASE_INITIALIZED" = "0" ]; then
@@ -20,11 +20,11 @@ if [ -n "$ODOO_DATABASE" ]; then
ODOO_INIT_LANG=${ODOO_INIT_LANG:="en_US"}
ODOO_INIT_ADDONS=${ODOO_INIT_ADDONS:="web"}
entrypoint-log "Initialize database $ODOO_DATABASE with modules: $ODOO_INIT_ADDONS."
log-entrypoint "Initialize database $ODOO_DATABASE with modules: $ODOO_INIT_ADDONS."
(exec odoo "${DB_ARGS[@]}" --database "$ODOO_DATABASE" --init "$ODOO_INIT_ADDONS" --config "$ODOO_RC" --stop-after-init --no-http --load-language "$ODOO_INIT_LANG" --without-demo=all) || true
if [ "$ODOO_INIT_LOGIN" != "admin" ] || [ "$ODOO_INIT_PASSWORD" != "admin" ]; then
entrypoint-log "Updating admin user credentials to login: $ODOO_INIT_LOGIN"
log-entrypoint "Updating admin user credentials to login: $ODOO_INIT_LOGIN"
(exec odoo shell --database "$ODOO_DATABASE" --config "$ODOO_RC" << EOF
admin_user = env['res.users'].browse(2)
admin_user.write({
@@ -47,7 +47,7 @@ EOF
export ODOO_MAIL_IMAP_PORT=${ODOO_MAIL_IMAP_PORT:="993"}
export ODOO_MAIL_IMAP_SSL=${ODOO_MAIL_IMAP_SSL:="True"}
entrypoint-log "Setup mail server configuration for database $ODOO_DATABASE."
log-entrypoint "Setup mail server configuration for database $ODOO_DATABASE."
(odoo shell "${DB_ARGS[@]}" --database "$ODOO_DATABASE" --config "$ODOO_RC" --stop-after-init --no-http < /usr/local/bin/setup-mail) || true
fi
fi
+2 -2
View File
@@ -1,13 +1,13 @@
#!/bin/bash
if [ -n "$ODOO_DATABASE" ]; then
entrypoint-log "Check if database $ODOO_DATABASE is initialized"
log-entrypoint "Check if database $ODOO_DATABASE is initialized"
DATABASE_INITIALIZED=$(exec psql "postgres://$PGUSER:$PGPASSWORD@$PGHOST:$PGPORT/$ODOO_DATABASE" -tAc "SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 'ir_module_module'")
if [ "$DATABASE_INITIALIZED" = "1" ]; then
ODOO_INIT_LANG="${ODOO_INIT_LANG:="en_US"}"
entrypoint-log "Initialize module $1 on database $ODOO_DATABASE."
log-entrypoint "Initialize module $1 on database $ODOO_DATABASE."
(exec odoo "${DB_ARGS[@]}" --database "$ODOO_DATABASE" --init "$1" --config "$ODOO_RC" --stop-after-init --no-http --load-language "$ODOO_INIT_LANG" --without-demo=all) || true
fi
fi
@@ -2,11 +2,11 @@
if [ -n "$PYTHON_INSTALL" ]; then
entrypoint-log "Check status of PyPi."
log-entrypoint "Check status of PyPi."
HTTP_PYPI_OK=$(curl -s --head --request GET https://pypi.org/simple/ | grep "HTTP/2 200")
if [ -n "$HTTP_PYPI_OK" ]; then
entrypoint-log "Install python packages: $PYTHON_INSTALL"
log-entrypoint "Install python packages: $PYTHON_INSTALL"
uv pip install --no-cache-dir $(echo "$PYTHON_INSTALL" | tr "," " ")
fi
fi
fi
File renamed without changes.
+2 -2
View File
@@ -9,8 +9,8 @@ fi
source set-addons-path
entrypoint-log "Run test for these modules: $TEST_MODULES"
entrypoint-log "Test coverage includes: $TEST_ADDONS_DIR/*"
log-entrypoint "Run test for these modules: $TEST_MODULES"
log-entrypoint "Test coverage includes: $TEST_ADDONS_DIR/*"
unbuffer coverage run --include "$TEST_ADDONS_DIR/*" --branch \
/opt/odoo-venv/bin/odoo \
-d "$ODOO_DATABASE" \
+1 -1
View File
@@ -16,7 +16,7 @@ if [ -n "$TEST_ADDONS_DIR" ]; then
fi
if [ -n "$ODOO_ADDONS_PATH" ]; then
entrypoint-log "Resolve addons path: $ODOO_ADDONS_PATH"
log-entrypoint "Resolve addons path: $ODOO_ADDONS_PATH"
# Search for module manifest files and return list of module paths
ODOO_ADDONS_PATH=$(echo "$ODOO_ADDONS_PATH" | tr "," "\n" | xargs -I {} find {} -type f -name "__manifest__.py" | xargs grep -l -iE "version.*['\"]([0-9]+\.[0-9]+['\"]|${ODOO_VERSION})" | xargs -r dirname | sort -u | tr "\n" "," | sed 's/,$//')
+4 -4
View File
@@ -1,11 +1,11 @@
#!/bin/bash
set -e
entrypoint-log "Install python packages required for testing."
log-entrypoint "Install python packages required for testing."
uv pip install --no-cache-dir coverage \
websocket-client
entrypoint-log "Collect external python dependencies from modules in $TEST_ADDONS_DIR."
log-entrypoint "Collect external python dependencies from modules in $TEST_ADDONS_DIR."
if [ -n "$TEST_INCLUDE" ]; then
manifestoo --select-include "$TEST_INCLUDE" --select-exclude "$TEST_EXCLUDE" list-external-dependencies python \
> test-requirements.txt
@@ -14,7 +14,7 @@ else
> test-requirements.txt
fi
entrypoint-log "Install collected python dependencies."
log-entrypoint "Install collected python dependencies."
uv pip install -r test-requirements.txt
if [ -n "$TEST_INCLUDE" ]; then
@@ -23,7 +23,7 @@ else
TEST_DEPENDS_MODULES=$(manifestoo --select-addons-dir "$TEST_ADDONS_DIR" --select-exclude "$TEST_EXCLUDE" list-depends --separator=,)
fi
entrypoint-log "Install depends modules for testing: $TEST_DEPENDS_MODULES"
log-entrypoint "Install depends modules for testing: $TEST_DEPENDS_MODULES"
unbuffer /opt/odoo-venv/bin/odoo \
-d "$ODOO_DATABASE" \
-i "${TEST_DEPENDS_MODULES:-base}" \
@@ -36,6 +36,6 @@ source set-addons-path
DEFINED_ENVS=$(printf '${%s} ' $(awk "END { for (name in ENVIRON) { print ( name ~ /${FILTER}/ ) ? name : \"\" } }" < /dev/null ))
if [[ -f "$TEMPLATE_FILE" ]]; then
entrypoint-log "Run envsubst on $TEMPLATE_FILE and output: $OUTPUT_FILE"
log-entrypoint "Run envsubst on $TEMPLATE_FILE and output: $OUTPUT_FILE"
envsubst "$DEFINED_ENVS" < "$TEMPLATE_FILE" > "$OUTPUT_FILE"
fi
+2 -2
View File
@@ -1,13 +1,13 @@
#!/bin/bash
if [ -n "$ODOO_DATABASE" ]; then
entrypoint-log "Check if database $ODOO_DATABASE is initialized"
log-entrypoint "Check if database $ODOO_DATABASE is initialized"
DATABASE_INITIALIZED=$(exec psql "postgres://$PGUSER:$PGPASSWORD@$PGHOST:$PGPORT/$ODOO_DATABASE" -tAc "SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 'ir_module_module'")
if [ "$DATABASE_INITIALIZED" = "1" ]; then
ODOO_INIT_LANG="${ODOO_INIT_LANG:="en_US"}"
entrypoint-log "Update module $1 on database $ODOO_DATABASE."
log-entrypoint "Update module $1 on database $ODOO_DATABASE."
(exec odoo "${DB_ARGS[@]}" --upgrade-path=/var/lib/upgrade-util/src --database "$ODOO_DATABASE" --update "$1" --config "$ODOO_RC" \
--stop-after-init --no-http --load-language "$ODOO_INIT_LANG" --without-demo=all) || true
fi
+1 -1
View File
@@ -3,6 +3,6 @@
source set-addons-path
if [ -n "$ADDONS_PATH" ] && [ -n "$ODOO_DATABASE" ]; then
entrypoint-log "Run click-odoo-update for: $ADDONS_PATH"
log-entrypoint "Run click-odoo-update for: $ADDONS_PATH"
(exec click-odoo-update --addons-path="$ADDONS_PATH" -d "$ODOO_DATABASE" ) || true
fi
+1 -1
View File
@@ -3,7 +3,7 @@
source set-addons-path
if [ -n "$ODOO_DATABASE" ]; then
entrypoint-log "Updating translations for all active languages and installed modules."
log-entrypoint "Updating translations for all active languages and installed modules."
(exec odoo shell --database "$ODOO_DATABASE" --config "$ODOO_RC" << EOF
for lang in env['res.lang'].search([]):
env['ir.module.module'].search([('state', '=', 'installed')])._update_translations(lang.code, overwrite=True)
+2 -2
View File
@@ -7,9 +7,9 @@ ATTEMPTS=0
until pg_isready -h "$PGHOST" -p "$PGPORT"; do
ATTEMPTS=$((ATTEMPTS+1))
if [ "$ATTEMPTS" -ge $MAX_ATTEMPTS ]; then
entrypoint-log "Database is not reachable after 30 attempts."
log-entrypoint "Database is not reachable after 30 attempts."
exit 1
fi
entrypoint-log "Waiting for database... ($ATTEMPTS)"
log-entrypoint "Waiting for database... ($ATTEMPTS)"
sleep $SLEEP_SECONDS
done
+6 -6
View File
@@ -1,7 +1,7 @@
#!/bin/bash
set -e
entrypoint-log() {
log-entrypoint() {
echo "$@"
}
@@ -13,10 +13,10 @@ echo " \___/ \__,_|\___/ \___/ |____/ \__,_|_|_|\__,_|"
echo
echo "Maintainer: Mint System GmbH <info@mint-system.ch>"
entrypoint-log "Run as user with id: $(id)"
log-entrypoint "Run as user with id: $(id)"
auto-envsubst
python-install
template-odoo-rc
install-python-packages
# Set the postgres database host, port, user and password according to the environment
# and pass them as arguments to the odoo process if not present in the config file
@@ -48,7 +48,7 @@ check_config "db_user" "$PGUSER"
check_config "db_password" "$PGPASSWORD"
check_config "db_sslmode" "$PGSSLMODE"
entrypoint-log "Resolve database hostname: $PGHOST"
log-entrypoint "Resolve database hostname: $PGHOST"
getent hosts "$PGHOST"
wait-for-pg
@@ -65,7 +65,7 @@ fi
case "$1" in
memray)
shift
entrypoint-log "Start Odoo with memray."
log-entrypoint "Start Odoo with memray."
rm -f /var/lib/odoo/memray-capture.bin
exec python3 -m memray run -o /var/lib/odoo/memray-capture.bin $(which odoo) "$@" "${DB_ARGS[@]}"
;;
+7 -2
View File
@@ -771,10 +771,10 @@ function test-image() {
export ADDONS_GIT_REPOS="https://github.com/OCA/server-tools.git#${ODOO_VERSION}#${SERVER_TOOLS_GIT_REF}"
mkdir -p "$LOCAL_PATH"
export PATH=./images/odoo/bin/:$PATH
./images/odoo/bin/git-clone-addons
./images/odoo/bin/clone-git-addons
rm -rf "$LOCAL_PATH/github.com"
echo -e "\033[38;5;214mTEST\033[0m: Test set addons path regex with version: $ODOO_VERSION"
echo -e "\033[38;5;214mTEST\033[0m: Check addons path regex with version: $ODOO_VERSION"
echo "'version': '1.0'" | grep -iE "version.*['\"]([0-9]+\.[0-9]+['\"]|${ODOO_VERSION})"
echo "'version': '1.1'" | grep -iE "version.*['\"]([0-9]+\.[0-9]+['\"]|${ODOO_VERSION})"
echo "'version': '2.5'" | grep -iE "version.*['\"]([0-9]+\.[0-9]+['\"]|${ODOO_VERSION})"
@@ -782,6 +782,11 @@ function test-image() {
echo "'version': '14.0.2.1.1'" | grep -iE "version.*['\"]([0-9]+\.[0-9]+['\"]|${ODOO_VERSION})" || echo "Must not match"
echo "'version': '${ODOO_VERSION}.0.0.0'" | grep -iE "version.*['\"]([0-9]+\.[0-9]+['\"]|${ODOO_VERSION})"
echo '"Version": "1.0"' | grep -iE "version.*['\"]([0-9]+\.[0-9]+['\"]|${ODOO_VERSION})"
echo -e "\033[38;5;214mTEST\033[0m: Install python package."
export PYTHON_INSTALL="cowsay"
activate-venv
./images/odoo/bin/install-python-packages
fi
if [[ "$CONTAINER_TAG" =~ ^odoo-upgrade ]]; then