# XBP Systemd Provisioning (Ubuntu)
This folder contains baseline systemd service units for running the XBP API daemon.
## 1) Install the binary
Place the `xbp` binary at:
```bash
sudo install -m 0755 ./target/release/xbp /usr/local/bin/xbp
```
## 2) Install the service unit
From repo root:
```bash
sudo install -m 0644 provision/xbp-api.service /etc/systemd/system/xbp-api.service
```
## 3) Optional runtime environment file
Create `/etc/default/xbp` if you want to override defaults from the unit:
```bash
sudo tee /etc/default/xbp >/dev/null <<'EOF'
XBP_API_BIND=127.0.0.1
PORT_XBP_API=8080
XBP_ATHENA_BACKEND=supabase
XBP_ATHENA_URL=https://your-athena-endpoint
XBP_ATHENA_KEY=your-athena-key
EOF
```
The service already has `EnvironmentFile=-/etc/default/xbp`, so it works even if this file is missing.
By default, API bind is local-only (`127.0.0.1`) so command endpoints are available on the host without exposing them publicly.
## 4) Reload and enable the daemon
```bash
sudo systemctl daemon-reload
sudo systemctl enable --now xbp-api.service
```
## 5) Verify status and logs
```bash
sudo systemctl status xbp-api.service --no-pager
sudo journalctl -u xbp-api.service -f
curl -sS http://127.0.0.1:8080/health
curl -sS http://127.0.0.1:8080/services
curl -sS http://127.0.0.1:8080/metrics
curl -sS -X POST http://127.0.0.1:8080/commands/exec -H "Content-Type: application/json" -d '{"command":"services"}'
```
## 6) Update after changes
When the binary or service file changes:
```bash
sudo install -m 0755 ./target/release/xbp /usr/local/bin/xbp
sudo install -m 0644 provision/xbp-api.service /etc/systemd/system/xbp-api.service
sudo systemctl daemon-reload
sudo systemctl restart xbp-api.service
```