feat: managed NUT setup, plugin config improvements, migration fix

- Add managed NUT mode: configure NUT daemon from Settings → Plugins
  (UPS plugin), writes /data/nut_managed.json read by entrypoint on
  restart — no env vars or USB passthrough required
- entrypoint.sh: start NUT from /data/nut_managed.json or NUT_MANAGED=1
  env var; drop to app user via gosu after NUT daemons start
- nut_setup.py: support --from-file <json> in addition to env vars
- Dockerfile: add nut, nut-client, gosu packages and entrypoint
- docker-compose.yml: document optional NUT_MANAGED env var block
- Fix plugin hot-reload migration failure: pass all plugin migration
  dirs to Alembic so previously-stamped revisions from other plugins
  remain resolvable (fixes UPS and any plugin with depends_on)
- Fix plugin list-type config (e.g. SNMP devices) rendering as broken
  text input — now shows a read-only note to edit plugin.yaml instead
- Fix _sync_nut_managed_config: only write JSON when nut_ups_host is
  non-empty, preventing NUT startup loop on container restart

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-23 08:15:48 -04:00
parent ced1eebe1d
commit 93d5ed8fb0
7 changed files with 444 additions and 21 deletions
+13
View File
@@ -10,6 +10,19 @@ services:
- /mnt/Data/traefik/log:/var/log/traefik:ro
environment:
- FABLEDSCRYER_DATABASE_URL=postgresql+asyncpg://fabledscryer:fabledscryer@db/fabledscryer
# ── Managed NUT (optional) ───────────────────────────────────────────────
# Set NUT_MANAGED=1 to run NUT inside this container and connect to your
# UPS over the network (SNMP or XML/HTTP). No USB or special privileges
# required — just network access to the UPS management card.
#
# - NUT_MANAGED=1
# - NUT_UPS_HOST=192.168.1.x # IP/hostname of UPS management card (required)
# - NUT_DRIVER=snmp-ups # snmp-ups (default) or netxml-ups for Eaton
# - NUT_UPS_NAME=ups # must match 'ups_name' in UPS plugin settings
# - NUT_SNMP_COMMUNITY=public # SNMP community string (snmp-ups only)
# - NUT_SNMP_VERSION=v1 # v1 or v2c (snmp-ups only)
# - NUT_USERNAME= # upsd auth username (blank = no auth)
# - NUT_PASSWORD= # upsd auth password
depends_on:
db:
condition: service_healthy