Files
warewulf/internal/pkg/warewulfd/ipxe.go
Jonathon Anderson 91723a258a Refactor server to separate handlers
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2026-03-09 21:42:18 -06:00

36 lines
901 B
Go

package warewulfd
import (
"net/http"
"path"
"github.com/warewulf/warewulf/internal/pkg/wwlog"
)
// HandleIpxe handles iPXE boot script requests
func HandleIpxe(w http.ResponseWriter, req *http.Request) {
ctx, err := initHandleRequest(w, req)
if err != nil {
return // response already written
}
var stageFile string
var tmplData *templateVars
if !ctx.remoteNode.Valid() {
wwlog.Error("%s (unknown/unconfigured node)", ctx.rinfo.hwaddr)
stageFile = path.Join(ctx.conf.Paths.Sysconfdir, "/warewulf/ipxe/unconfigured.ipxe")
tmplData = &templateVars{
Hwaddr: ctx.rinfo.hwaddr}
} else {
template := ctx.remoteNode.Ipxe
if template == "" {
template = "default"
}
stageFile = path.Join(ctx.conf.Paths.Sysconfdir, "warewulf/ipxe", template+".ipxe")
tmplData = buildTemplateVars(ctx.conf, ctx.rinfo, ctx.remoteNode)
}
sendResponse(w, req, stageFile, tmplData, ctx)
}