From 1bb6a44fc6e12ae2620cd0a535336d6f2dadca67 Mon Sep 17 00:00:00 2001 From: josh Date: Thu, 14 May 2026 18:27:59 -0400 Subject: [PATCH] Activate Proxmox auto-installer by bypassing file-existence gate in GRUB config The auto-installer menuentry was wrapped in 'if [ -f auto-installer-mode.toml ]' which never evaluated true. Replace the condition with 'if true' to activate the built-in auto-installer entry, and only add the answer-url to kernel lines that already have proxmox-start-auto-installer (rather than modifying the graphical install entry). Co-Authored-By: Claude Opus 4.6 --- internal/image/isomod.go | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/internal/image/isomod.go b/internal/image/isomod.go index eef74d8..ab302e2 100644 --- a/internal/image/isomod.go +++ b/internal/image/isomod.go @@ -109,42 +109,41 @@ func rewriteGrubConfig(original, answerURL string) string { lines := strings.Split(original, "\n") var result []string depth := 0 - firstMenuModified := false for _, line := range lines { trimmed := strings.TrimSpace(line) - // Strip comments to reclaim space for added kernel parameters if strings.HasPrefix(trimmed, "#") { continue } + // Activate auto-installer mode by bypassing the file-existence check + if strings.Contains(line, "auto-installer-mode.toml") { + if strings.Contains(line, "! -f") { + line = strings.Replace(line, "[ ! -f auto-installer-mode.toml ]", "false", 1) + } else { + line = strings.Replace(line, "[ -f auto-installer-mode.toml ]", "true", 1) + } + trimmed = strings.TrimSpace(line) + } + if strings.HasPrefix(trimmed, "set timeout=") { result = append(result, "set timeout=0") continue } - if strings.HasPrefix(trimmed, "set default=") { - result = append(result, "set default=0") - continue - } if strings.HasPrefix(trimmed, "menuentry") { depth++ } if trimmed == "}" && depth > 0 { - if depth == 1 { - firstMenuModified = true - } depth-- } - if depth > 0 && !firstMenuModified && - (strings.HasPrefix(trimmed, "linux ") || strings.HasPrefix(trimmed, "linux\t")) { - if !strings.Contains(line, "proxmox-start-auto-installer") { - line = strings.TrimRight(line, " \t") + " proxmox-start-auto-installer" - } - if answerURL != "" && !strings.Contains(line, "proxmox-auto-installer-answer-url") { - line += " proxmox-auto-installer-answer-url=" + answerURL + // Add answer URL to kernel lines that already have proxmox-start-auto-installer + if depth > 0 && (strings.HasPrefix(trimmed, "linux ") || strings.HasPrefix(trimmed, "linux\t")) { + if strings.Contains(line, "proxmox-start-auto-installer") && + answerURL != "" && !strings.Contains(line, "proxmox-auto-installer-answer-url") { + line = strings.TrimRight(line, " \t") + " proxmox-auto-installer-answer-url=" + answerURL } } @@ -152,7 +151,6 @@ func rewriteGrubConfig(original, answerURL string) string { result = append(result, line) } - // Collapse consecutive blank lines var collapsed []string prevBlank := false for _, line := range result {