Manage .env from the admin panel

Add an Environment tab to /admin that lists every variable in .env.example
and lets keys, OAuth settings, email settings and generated secrets be
changed without SSH. Secrets are write-only; infrastructure variables are
shown read-only.

The backend never writes .env or touches Docker. It validates an edit and
queues it in env-apply/run/request.json; env-apply/apply.py, run on the host
by a systemd path unit (env-apply/install.sh), rewrites .env atomically,
keeps .env.bak, and recreates only the services that read the change.

backend/services/env_registry.json is the single list of variables, shared
by the backend and the host script; a test keeps it in step with
.env.example. It replaces the drifted checklist in handle_admin.go. The job
capture token card moves to the new tab.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-12 14:02:28 +01:00
co-authored by Claude Opus 5.5
parent 26f312e307
commit 2786bce022
24 changed files with 2293 additions and 306 deletions
+10
View File
@@ -17,6 +17,16 @@
# cp .env.example .env then fill in every value.
# Distribute to the Raspberry Pi with ./sync-secrets.sh (newer file wins in
# either direction — see that script's header before editing on both hosts).
# On the Pi, keys and settings can also be changed from the admin panel's
# Environment tab, which rewrites this file in place (previous version kept
# as .env.bak) and restarts what reads the change. See "Editing from the
# admin panel" in DEPLOYMENT.md.
#
# ADDING A VARIABLE
# Add it to backend/services/env_registry.json as well. That file decides
# whether the admin panel shows it, whether it is editable there, and which
# services are restarted when it changes; a backend test fails if the two
# lists differ.
#
# CAUTION: an unset variable does not fail loudly. envsubst renders it as an
# empty string, which for a password field means "no password". After editing,