From fd627f3d557bd0a8b1fa435fee68856460cb46ec Mon Sep 17 00:00:00 2001 From: kisfenyo Date: Mon, 16 Feb 2026 08:44:34 +0100 Subject: [PATCH] v0.4.6: MariaDB validation fix + dashboard deployed-only + protected stack restart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix ValidateDump() to scan first 10 lines for header (MariaDB 11.4+ sandbox comment) - Dashboard shows only deployed/protected stacks, heading "Telepített alkalmazások" - Protected stacks show restart button when operational (both dashboard + stacks page) - API blocks all actions except restart on protected stacks - docker-setup.sh creates .felhom.yml for FileBrowser (subdomain: files) Co-Authored-By: Claude Opus 4.6 --- controller/internal/api/router.go | 6 +++ controller/internal/backup/dbdump.go | 38 ++++++++++++++----- controller/internal/web/handlers.go | 10 ++++- .../internal/web/templates/dashboard.html | 5 ++- controller/internal/web/templates/stacks.html | 3 ++ scripts/docker-setup.sh | 21 ++++++++++ 6 files changed, 72 insertions(+), 11 deletions(-) diff --git a/controller/internal/api/router.go b/controller/internal/api/router.go index 1057a4b..caf80f6 100644 --- a/controller/internal/api/router.go +++ b/controller/internal/api/router.go @@ -207,6 +207,12 @@ func (r *Router) deployStack(w http.ResponseWriter, req *http.Request, name stri func (r *Router) actionStack(w http.ResponseWriter, action, name string) { r.logger.Printf("[API] %s requested for stack: %s", action, name) + // Protected stacks only allow restart — block all other actions + if r.cfg.IsProtectedStack(name) && action != "restart" { + writeJSON(w, http.StatusForbidden, apiResponse{OK: false, Error: fmt.Sprintf("cannot %s protected stack %s", action, name)}) + return + } + var err error switch action { case "start": diff --git a/controller/internal/backup/dbdump.go b/controller/internal/backup/dbdump.go index 5594731..1582c3e 100644 --- a/controller/internal/backup/dbdump.go +++ b/controller/internal/backup/dbdump.go @@ -264,18 +264,38 @@ func ValidateDump(filePath string, dbType DBType) DumpValidation { } v.TableCount = tableCount - // Basic header check - switch dbType { - case DBTypePostgres: - if !strings.HasPrefix(content, "--") { - v.Error = "PostgreSQL dump missing comment header" - return v + // Header check — scan first 10 lines for expected dump header + // MariaDB 11.4+ prepends a sandbox comment before the header line + headerFound := false + lines := strings.SplitN(content, "\n", 11) // at most 11 parts = 10 lines + for i, line := range lines { + if i >= 10 { + break } - case DBTypeMariaDB: - if !strings.HasPrefix(content, "-- ") { + switch dbType { + case DBTypeMariaDB: + if strings.HasPrefix(line, "-- MariaDB dump") || + strings.HasPrefix(line, "-- MySQL dump") || + strings.HasPrefix(line, "-- mysqldump") { + headerFound = true + } + case DBTypePostgres: + if strings.HasPrefix(line, "-- PostgreSQL database dump") { + headerFound = true + } + } + if headerFound { + break + } + } + if !headerFound { + switch dbType { + case DBTypeMariaDB: v.Error = "MariaDB dump missing comment header" - return v + case DBTypePostgres: + v.Error = "PostgreSQL dump missing comment header" } + return v } if tableCount == 0 { diff --git a/controller/internal/web/handlers.go b/controller/internal/web/handlers.go index 89a50cb..1aabcc4 100644 --- a/controller/internal/web/handlers.go +++ b/controller/internal/web/handlers.go @@ -36,10 +36,18 @@ func (s *Server) dashboardHandler(w http.ResponseWriter, _ *http.Request) { } } + // Filter to deployed + protected stacks only for dashboard display + var deployedStacks []stacks.Stack + for _, st := range stackList { + if st.Deployed || st.Protected { + deployedStacks = append(deployedStacks, st) + } + } + sysInfo := system.GetInfo(s.cfg.Paths.HDDPath, s.cpuCollector) data := s.baseData("dashboard", "Vezérlőpult") - data["Stacks"] = stackList + data["Stacks"] = deployedStacks data["RunningCount"] = running data["StoppedCount"] = stopped data["TotalCount"] = len(stackList) diff --git a/controller/internal/web/templates/dashboard.html b/controller/internal/web/templates/dashboard.html index f3ee789..a17c9ec 100644 --- a/controller/internal/web/templates/dashboard.html +++ b/controller/internal/web/templates/dashboard.html @@ -120,7 +120,7 @@ {{end}} -

Alkalmazások állapota

+

Telepített alkalmazások

{{range .Stacks}} @@ -139,6 +139,9 @@ {{if .Protected}} Védett + {{if isOperational .State}} + + {{end}} {{else if not .Deployed}} Telepítés {{else}} diff --git a/controller/internal/web/templates/stacks.html b/controller/internal/web/templates/stacks.html index c779277..ac01a94 100644 --- a/controller/internal/web/templates/stacks.html +++ b/controller/internal/web/templates/stacks.html @@ -59,6 +59,9 @@
{{if .Protected}} Védett rendszerkomponens + {{if isOperational .State}} + + {{end}} {{else if not .Deployed}} Telepítés Részletek diff --git a/scripts/docker-setup.sh b/scripts/docker-setup.sh index 800109a..4d75637 100644 --- a/scripts/docker-setup.sh +++ b/scripts/docker-setup.sh @@ -1323,6 +1323,27 @@ networks: external: true EOF + # Create .felhom.yml metadata + cat > "${FILEBROWSER_DIR}/.felhom.yml" << 'METAEOF' +display_name: Filebrowser +slug: filebrowser +description: Fájlkezelő a külső merevlemezhez +subdomain: files +category: storage +app_info: + tagline: Web-alapú fájlkezelő a külső merevlemezhez + use_cases: + - Fájlok böngészése és letöltése a külső HDD-ről + - Médiafájlok megosztása családtagokkal + - Dokumentumok feltöltése és kezelése + first_steps: + - Nyisd meg a files.DOMAIN címet a böngészőben + - Jelentkezz be az admin fiókkal + - Tallózd a /srv mappákat + prerequisites: + - Külső HDD csatlakoztatva és felcsatolva +METAEOF + # Create .env file cat > "${FILEBROWSER_DIR}/.env" << ENVEOF # FileBrowser environment — generated by docker-setup.sh