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 <noreply@anthropic.com>
This commit is contained in:
+15
-17
@@ -109,42 +109,41 @@ func rewriteGrubConfig(original, answerURL string) string {
|
|||||||
lines := strings.Split(original, "\n")
|
lines := strings.Split(original, "\n")
|
||||||
var result []string
|
var result []string
|
||||||
depth := 0
|
depth := 0
|
||||||
firstMenuModified := false
|
|
||||||
|
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
trimmed := strings.TrimSpace(line)
|
trimmed := strings.TrimSpace(line)
|
||||||
|
|
||||||
// Strip comments to reclaim space for added kernel parameters
|
|
||||||
if strings.HasPrefix(trimmed, "#") {
|
if strings.HasPrefix(trimmed, "#") {
|
||||||
continue
|
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=") {
|
if strings.HasPrefix(trimmed, "set timeout=") {
|
||||||
result = append(result, "set timeout=0")
|
result = append(result, "set timeout=0")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(trimmed, "set default=") {
|
|
||||||
result = append(result, "set default=0")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.HasPrefix(trimmed, "menuentry") {
|
if strings.HasPrefix(trimmed, "menuentry") {
|
||||||
depth++
|
depth++
|
||||||
}
|
}
|
||||||
if trimmed == "}" && depth > 0 {
|
if trimmed == "}" && depth > 0 {
|
||||||
if depth == 1 {
|
|
||||||
firstMenuModified = true
|
|
||||||
}
|
|
||||||
depth--
|
depth--
|
||||||
}
|
}
|
||||||
|
|
||||||
if depth > 0 && !firstMenuModified &&
|
// Add answer URL to kernel lines that already have proxmox-start-auto-installer
|
||||||
(strings.HasPrefix(trimmed, "linux ") || strings.HasPrefix(trimmed, "linux\t")) {
|
if depth > 0 && (strings.HasPrefix(trimmed, "linux ") || strings.HasPrefix(trimmed, "linux\t")) {
|
||||||
if !strings.Contains(line, "proxmox-start-auto-installer") {
|
if strings.Contains(line, "proxmox-start-auto-installer") &&
|
||||||
line = strings.TrimRight(line, " \t") + " proxmox-start-auto-installer"
|
answerURL != "" && !strings.Contains(line, "proxmox-auto-installer-answer-url") {
|
||||||
}
|
line = strings.TrimRight(line, " \t") + " proxmox-auto-installer-answer-url=" + answerURL
|
||||||
if answerURL != "" && !strings.Contains(line, "proxmox-auto-installer-answer-url") {
|
|
||||||
line += " proxmox-auto-installer-answer-url=" + answerURL
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +151,6 @@ func rewriteGrubConfig(original, answerURL string) string {
|
|||||||
result = append(result, line)
|
result = append(result, line)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collapse consecutive blank lines
|
|
||||||
var collapsed []string
|
var collapsed []string
|
||||||
prevBlank := false
|
prevBlank := false
|
||||||
for _, line := range result {
|
for _, line := range result {
|
||||||
|
|||||||
Reference in New Issue
Block a user