Add automated PXE installation via ISO GRUB modification and auto-answer endpoint
Modifies uploaded ISO's GRUB config in-place to set timeout=0 and inject proxmox-start-auto-installer + answer-url kernel params, enabling fully hands-off installation. Adds /api/boot/auto-answer endpoint that identifies hosts by ARP-resolving the requester's IP to MAC address. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
@@ -13,8 +14,9 @@ import (
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
Store *store.Images
|
||||
ImageDir string
|
||||
Store *store.Images
|
||||
ImageDir string
|
||||
PublicURL string
|
||||
}
|
||||
|
||||
type UploadParams struct {
|
||||
@@ -53,6 +55,20 @@ func (s *Service) Upload(ctx context.Context, p UploadParams) (*model.Image, err
|
||||
return nil, fmt.Errorf("extract ISO: %w", err)
|
||||
}
|
||||
|
||||
if s.PublicURL != "" {
|
||||
report := func(stage, detail string) {
|
||||
if p.OnProgress != nil {
|
||||
p.OnProgress(stage, detail)
|
||||
}
|
||||
}
|
||||
report("packaging", "Configuring ISO for automated installation...")
|
||||
isoFile := filepath.Join(destDir, result.ISOFilename)
|
||||
answerURL := s.PublicURL + "/api/boot/auto-answer"
|
||||
if err := ModifyISOForAutoInstall(isoFile, answerURL); err != nil {
|
||||
log.Printf("image: ISO auto-install modification failed (non-fatal): %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
kernelPath := filepath.Join(p.Name, result.KernelFilename)
|
||||
initrdPath := filepath.Join(p.Name, result.InitrdFilename)
|
||||
isoPath := filepath.Join(p.Name, result.ISOFilename)
|
||||
|
||||
Reference in New Issue
Block a user