feat: show Restart/Restart & Update in admin panel when running under systemd
Tim Falken authored 6 months ago
Detection: INVOCATION_ID env var is set by systemd for every managed service.
Backend:
- GET /api/admin/update-status — checks INVOCATION_ID, runs git fetch +
git log HEAD..origin/HEAD --oneline, returns { underSystemd, commitsAhead[] }
- No changes to POST /api/admin/shutdown — start.sh already does git pull +
npm install on every boot, so systemd restart handles updates automatically
Frontend (public/app.js):
- showConfirm() extended with { html, okLabel } options; adds escHtml() helper
- refreshAdminUpdateStatus() fetches update-status and sets button label to
'Shut down server' / 'Restart Server' / 'Restart & Update'
- openAdminModal() fires refreshAdminUpdateStatus() in parallel (non-blocking)
- Shutdown button adapts confirm dialog text and toast message to context
Tests: 4 new tests in admin.routes.test.js (142 total, all passing)
Docs: technical-reference.md and tests.md updated