# ZMB Webui — Backend FastAPI-Backend für ZFS-, Samba- und NFS-Verwaltung. Läuft als root (PAM-Auth benötigt `/etc/shadow`). ## Lokale Entwicklung ```bash cd backend python3 -m venv venv source venv/bin/activate pip install -r requirements.txt python3 main.py # → http://localhost:8000 # → http://localhost:8000/docs (API-Docs) ``` Login mit jedem Linux-Systembenutzer der eine Login-Shell hat. ## API-Endpunkte Auth-Cookie wird beim Login automatisch gesetzt (`httpOnly`). Für curl-Tests: ```bash # Login — setzt Cookie curl -c cookies.txt -X POST http://localhost:8000/api/auth/login \ -H "Content-Type: application/json" \ -d '{"username":"user","password":"pass"}' # Alle weiteren Requests mit Cookie curl -b cookies.txt http://localhost:8000/api/pools/ ``` ### Pools | Methode | Pfad | Beschreibung | |---------|------|--------------| | GET | `/api/pools/` | Alle Pools auflisten | | GET | `/api/pools/{name}` | Pool-Status | | POST | `/api/pools/{name}/scrub` | Scrub starten | | POST | `/api/pools/{name}/scrub/stop` | Scrub stoppen | ### Datasets | Methode | Pfad | Beschreibung | |---------|------|--------------| | GET | `/api/datasets/` | Alle Datasets | | POST | `/api/datasets/` | Dataset erstellen | | DELETE | `/api/datasets/{name}` | Dataset löschen | ### Snapshots | Methode | Pfad | Beschreibung | |---------|------|--------------| | GET | `/api/snapshots/` | Alle Snapshots | | POST | `/api/snapshots/` | Snapshot erstellen | | DELETE | `/api/snapshots/{name}` | Snapshot löschen | | POST | `/api/snapshots/rollback` | Rollback | ### Shares | Methode | Pfad | Beschreibung | |---------|------|--------------| | GET | `/api/shares/samba` | Samba-Shares auflisten | | POST | `/api/shares/samba` | Share erstellen | | DELETE | `/api/shares/samba/{name}` | Share löschen | | GET | `/api/shares/nfs` | NFS-Exports auflisten | | POST | `/api/shares/nfs` | Export erstellen | | DELETE | `/api/shares/nfs/{path}` | Export löschen | | GET | `/api/shares/samba/config` | Samba Global-Config | | POST | `/api/shares/samba/config` | Parameter setzen | | DELETE | `/api/shares/samba/config/{key}` | Parameter löschen | ### System | Methode | Pfad | Beschreibung | |---------|------|--------------| | GET | `/api/system/info` | CPU, RAM, Disk | | GET | `/api/system/logs` | Systemlogs | ### Identities | Methode | Pfad | Beschreibung | |---------|------|--------------| | GET | `/api/identities/users` | Systembenutzer auflisten | | POST | `/api/identities/users` | Benutzer anlegen | | DELETE | `/api/identities/users/{name}` | Benutzer löschen | | GET | `/api/identities/groups` | Gruppen auflisten | ## Caching ZFS-Befehle sind mit TTL gecacht: - Pools: 30s - Datasets/Snapshots: 60s Mutationen (erstellen/löschen) löschen den Cache sofort. ## Troubleshooting ```bash # Logs live journalctl -u zmb-webui-backend -f # Manuell starten (für Fehlerausgabe direkt im Terminal) cd backend && source venv/bin/activate python3 main.py # ZFS prüfen zpool list # Samba Registry prüfen net conf list ```