package recovery import ( "fmt" "os" "path/filepath" "time" ) // Info holds the data needed for the recovery info file and settings UI. type Info struct { CustomerID string RetrievalPassword string HubURL string SupportEmail string SupportURL string } // GenerateRecoveryFile writes a plain text recovery-info.txt to the given directory. func GenerateRecoveryFile(info Info, version, outputDir string) error { if err := os.MkdirAll(outputDir, 0755); err != nil { return fmt.Errorf("creating recovery info directory: %w", err) } content := fmt.Sprintf(`Felhom Controller — Vészhelyzeti információk ============================================= Ügyfél azonosító: %s Hub URL: %s Visszaállítási jelszó: %s Támogatás: Email: %s Web: %s Visszaállítási útmutató: 1. Telepítse az operációs rendszert (Debian 13) 2. Futtassa a docker-setup.sh szkriptet: sudo ./docker-setup.sh --domain 3. Nyissa meg a böngészőben: http://:8081 4. Válassza a "Visszaállítás mentésből" opciót 5. Adja meg az ügyfél azonosítót és a visszaállítási jelszót 6. Kövesse a varázsló utasításait Generálva: %s Controller verzió: %s `, info.CustomerID, info.HubURL, info.RetrievalPassword, info.SupportEmail, info.SupportURL, time.Now().Format("2006-01-02 15:04:05"), version, ) path := filepath.Join(outputDir, "recovery-info.txt") tmp := path + ".tmp" if err := os.WriteFile(tmp, []byte(content), 0600); err != nil { os.Remove(tmp) return err } if err := os.Rename(tmp, path); err != nil { os.Remove(tmp) return err } return nil }