This commit is contained in:
oliver committed 2026-10-15 18:33:33 -03:00
1 parent 7263c859a2
commit 10f0422155
2 files changed
+39

No files matched your search

Executable
+38
View File
@@ -0,0 +1,38 @@
#!/bin/bash
# Usage: odoo <UUID> [odoo args...]
# Example: odoo 001-003-abcdef -u my_custom_module --stop-after-init
#
# Thin wrapper around `docker exec <UUID> odoo` that injects the database login
# parameters (database, host, port, user, password) so callers only pass the
# Odoo CLI options they care about.
if [ -z "$1" ]; then
echo "Usage: $0 <UUID> [odoo args...]"
exit 1
fi
UUID="$1"
shift
source /4server/sbin/helpers
get_contract_info
# The container talks to the shared Postgres as its own per-UUID user.
ODOO_DB_USER="$UUID"
if ! doas docker ps --format '{{.Names}}' | grep -q "^${UUID}$"; then
echo "Error: container $UUID is not running" >&2
exit 1
fi
# Attach a TTY only when we have one, so piped/non-interactive use still works.
DOCKER_TTY=""
[ -t 0 ] && DOCKER_TTY="-it"
doas docker exec $DOCKER_TTY -u odoo "$UUID" odoo \
-d "$UUID" \
--db_host="$POSTGRES_HOST" \
--db_port="$POSTGRES_PORT" \
--db_user="$ODOO_DB_USER" \
--db_password="$ODOO_DB_PASSWORD" \
"$@"