#!/bin/bash # Usage: odoo [odoo args...] # Example: odoo 001-003-abcdef -u my_custom_module --stop-after-init # # Thin wrapper around `docker exec 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 [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" \ "$@"