From 892ef6fb7d9208a6bcf17bb79da2ffa6c0011130 Mon Sep 17 00:00:00 2001 From: Mikhail Chusavitin Date: Fri, 19 Jun 2026 09:18:30 +0300 Subject: [PATCH] Add Reboot and Shutdown buttons to Settings page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit POST /api/system/reboot → systemctl reboot POST /api/system/shutdown → systemctl poweroff Both require confirm() before executing. Co-Authored-By: Claude Sonnet 4.6 --- audit/internal/webui/api.go | 16 ++++++++++++++++ audit/internal/webui/page_settings.go | 23 +++++++++++++++++++++++ audit/internal/webui/server.go | 2 ++ 3 files changed, 41 insertions(+) diff --git a/audit/internal/webui/api.go b/audit/internal/webui/api.go index ae9a394..81a4a05 100644 --- a/audit/internal/webui/api.go +++ b/audit/internal/webui/api.go @@ -1292,6 +1292,22 @@ func (h *handler) handleAPIInstallToRAM(w http.ResponseWriter, r *http.Request) _ = json.NewEncoder(w).Encode(map[string]string{"task_id": t.ID}) } +func (h *handler) handleAPISystemReboot(w http.ResponseWriter, r *http.Request) { + if err := exec.Command("systemctl", "reboot").Start(); err != nil { + writeError(w, http.StatusInternalServerError, "reboot failed: "+err.Error()) + return + } + writeJSON(w, map[string]string{"status": "rebooting"}) +} + +func (h *handler) handleAPISystemShutdown(w http.ResponseWriter, r *http.Request) { + if err := exec.Command("systemctl", "poweroff").Start(); err != nil { + writeError(w, http.StatusInternalServerError, "shutdown failed: "+err.Error()) + return + } + writeJSON(w, map[string]string{"status": "shutting down"}) +} + // ── Tools ───────────────────────────────────────────────────────────────────── var standardTools = []string{ diff --git a/audit/internal/webui/page_settings.go b/audit/internal/webui/page_settings.go index 81bbb93..1dbc242 100644 --- a/audit/internal/webui/page_settings.go +++ b/audit/internal/webui/page_settings.go @@ -88,5 +88,28 @@ checkTools(); +
+
Power
+
+
+ + + +
+
+
+ + + ` } diff --git a/audit/internal/webui/server.go b/audit/internal/webui/server.go index c8e36d9..5501beb 100644 --- a/audit/internal/webui/server.go +++ b/audit/internal/webui/server.go @@ -332,6 +332,8 @@ func NewHandler(opts HandlerOptions) http.Handler { // System mux.HandleFunc("GET /api/system/ram-status", h.handleAPIRAMStatus) mux.HandleFunc("POST /api/system/install-to-ram", h.handleAPIInstallToRAM) + mux.HandleFunc("POST /api/system/reboot", h.handleAPISystemReboot) + mux.HandleFunc("POST /api/system/shutdown", h.handleAPISystemShutdown) // Preflight mux.HandleFunc("GET /api/preflight", h.handleAPIPreflight)