# Deploy — mail-bundle endpoint VM112 (Spec 035/043)

**Roger · 2026-07-01**

## Pré-requisitos

- `OPS_INTERNAL_TOKEN` no `/opt/ligbox-deploy/env/.env` ou `.env` wizard (igual VM122 Desk)
- Clone `ligbox-ops-platform` na VM112 ou copiar ficheiros via `scp`

## Passos (executar NA VM112)

```bash
cd /opt/ligbox-spec-hub/repos/ligbox-ops-platform
git pull origin main

python3 deploy/vm112-wizard/deploy-mail-bundle-vm112.py
systemctl restart ligbox-wizard
systemctl status ligbox-wizard --no-pager
```

## Teste local

```bash
source /opt/ligbox-deploy/env/.env 2>/dev/null || true
curl -s -X POST http://127.0.0.1:8090/api/internal/provision/mail-bundle \
  -H "X-Ops-Internal-Token: ${OPS_INTERNAL_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "domain": "empresa-teste.ligbox.com.br",
    "admin_email": "admin@empresa-teste.ligbox.com.br",
    "admin_name": "Teste Bundle",
    "seats": 25,
    "mail_gb_per_seat": 30,
    "files_gb_per_seat": 200
  }' | python3 -m json.tool
```

## Teste via Desk (após deploy VM122)

Activar conta no Desk → passo `wizard` deve retornar `provisioned: true` (não `skipped`).

## Rollback

```bash
git checkout HEAD~1 -- projects/wizard/backend/app/services/mail_bundle.py
# ou remover router de main.py manualmente
systemctl restart ligbox-wizard
```

## Ficheiros instalados

| Destino VM112 | Origem repo |
|---------------|-------------|
| `/opt/ligbox-wizard/backend/app/services/mail_bundle.py` | `projects/wizard/.../mail_bundle.py` |
| `/opt/ligbox-wizard/backend/app/routers/internal_provision.py` | `projects/wizard/.../internal_provision.py` |
| `main.py` (patch router) | `deploy-mail-bundle-vm112.py` |
