Commit Graph

2 Commits

Author SHA1 Message Date
Carlos Garcia
6d15859779 fix(setup.sh): detect stale DB volume, run Alembic migrations on startup
- Before bringing up the stack, check if the agent-db volume exists but
  is missing the expected database (left from a previous broken run with
  wrong POSTGRES_DB). Offer to wipe and re-init automatically.
- After docker compose up, wait for pg_isready then run
  `alembic upgrade head` inside the agent container so tables are created
  before the agent attempts to use them.
- Restart agent-service after migrations so it connects to a fully
  initialized database on its first attempt.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-24 17:39:51 -04:00
Carlos Garcia
7765824c70 feat: add setup.sh — zero-config interactive installer
Replaces manual .env editing with a guided setup script.

Auto-discovers:
- Odoo container name and database (via `docker ps` + odoo.conf inspection)
- Ollama endpoint (scans 192.168.2.10/9, 192.168.2.1, localhost on port 11434)
- Ollama model list (lets user pick from available, auto-selects if only one)

Auto-generates (idempotent — preserves on re-run):
- POSTGRES_PASSWORD (openssl rand -hex 24)
- AGENT_API_KEY     (openssl rand -hex 32)
- WEBHOOK_SECRET    (openssl rand -hex 32)

Postgres constants always written correctly:
- POSTGRES_HOST=agent-db, POSTGRES_DB=activeblue_ai, POSTGRES_USER=activeblue
  (fixes previous issue where these were blank or wrong in .env)

Odoo API key:
- Attempts auto-creation via Odoo HTTP session + res.users.apikeys.description
  wizard (works on Odoo 16/17/18 with valid admin credentials)
- Falls back to clear manual instructions + paste prompt on failure

Writes .env with chmod 600. Offers to `docker compose up -d` when done.

Usage:
  cd /root/odoo/odoo-ai
  bash setup.sh

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-24 17:35:23 -04:00