Files
FabledSteward/entrypoint.sh
T
bvandeusen 93d5ed8fb0 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>
2026-03-23 08:15:48 -04:00

46 lines
1.7 KiB
Bash

#!/bin/sh
# FabledScryer container entrypoint.
#
# When NUT_MANAGED=1:
# - Generates /etc/nut/*.conf from environment variables
# - Starts NUT driver (upsdrvctl) and network daemon (upsd)
# - Connects to the UPS over the network — no USB passthrough required
# - Then drops to 'app' user via gosu to run fabledscryer
#
# When NUT_MANAGED=0 (default):
# - Drops directly to 'app' user and runs the command
#
# Required env vars when NUT_MANAGED=1:
# NUT_UPS_HOST IP or hostname of the UPS management card (required)
# NUT_DRIVER NUT driver — snmp-ups (default) or netxml-ups for Eaton
# NUT_UPS_NAME UPS name in NUT (default: ups) — must match UPS plugin setting
# NUT_SNMP_COMMUNITY SNMP community string (default: public) [snmp-ups only]
# NUT_SNMP_VERSION SNMP version: v1, v2c (default: v1) [snmp-ups only]
# NUT_USERNAME Optional upsd auth username
# NUT_PASSWORD Optional upsd auth password
set -e
NUT_MANAGED_JSON="/data/nut_managed.json"
if [ "${NUT_MANAGED:-0}" = "1" ] || [ -f "$NUT_MANAGED_JSON" ]; then
if [ -f "$NUT_MANAGED_JSON" ]; then
echo "[entrypoint] Found $NUT_MANAGED_JSON — configuring NUT from settings..."
python3 /app/fabledscryer/nut_setup.py --from-file "$NUT_MANAGED_JSON"
else
echo "[entrypoint] NUT_MANAGED=1 — configuring NUT from environment..."
python3 /app/fabledscryer/nut_setup.py
fi
echo "[entrypoint] Starting NUT driver..."
/sbin/upsdrvctl start || echo "[entrypoint] Warning: upsdrvctl returned non-zero"
echo "[entrypoint] Starting NUT daemon..."
/sbin/upsd || echo "[entrypoint] Warning: upsd returned non-zero"
sleep 1
echo "[entrypoint] NUT ready on 127.0.0.1:3493."
fi
exec gosu app "$@"