cmdline query param for boot.iso

This commit is contained in:
Mikaël Cluseau 2020-03-05 00:06:49 +01:00
parent 1ee5d1c15a
commit a54d4bc15e
4 changed files with 19 additions and 4 deletions

View File

@ -1,5 +1,5 @@
# ------------------------------------------------------------------------
from mcluseau/golang-builder:1.13.5 as build
from mcluseau/golang-builder:1.14.0 as build
# ------------------------------------------------------------------------
from debian:stretch

View File

@ -57,7 +57,7 @@ insmod all_video
set timeout=3
menuentry "Direktil" {
linux /vmlinuz direktil.boot=DEVNAME=sr0 direktil.boot.fs=iso9660
linux /vmlinuz direktil.boot=DEVNAME=sr0 direktil.boot.fs=iso9660 `+ctx.CmdLine+`
initrd /initrd
}
`), 0644)

View File

@ -7,6 +7,7 @@ import (
"io"
"log"
"net/http"
"net/url"
"path/filepath"
"text/template"
@ -20,17 +21,25 @@ import (
type renderContext struct {
Host *localconfig.Host
SSLConfig string
// Linux kernel extra cmdline
CmdLine string `yaml:"-"`
}
func renderCtx(w http.ResponseWriter, r *http.Request, ctx *renderContext, what string,
create func(out io.Writer, ctx *renderContext) error) error {
log.Printf("sending %s for %q", what, ctx.Host.Name)
tag, err := ctx.Tag()
if err != nil {
return err
}
ctx.CmdLine = r.URL.Query().Get("cmdline")
if ctx.CmdLine != "" {
what = what + "?cmdline=" + url.QueryEscape(ctx.CmdLine)
}
// get it or create it
content, meta, err := casStore.GetOrCreate(tag, what, func(out io.Writer) error {
log.Printf("building %s for %q", what, ctx.Host.Name)
@ -42,6 +51,7 @@ func renderCtx(w http.ResponseWriter, r *http.Request, ctx *renderContext, what
}
// serve it
log.Printf("sending %s for %q", what, ctx.Host.Name)
http.ServeContent(w, r, what, meta.ModTime(), content)
return nil
}

View File

@ -12,7 +12,11 @@ import (
"novit.nc/direktil/pkg/localconfig"
)
var trustXFF = flag.Bool("trust-xff", true, "Trust the X-Forwarded-For header")
var (
trustXFF = flag.Bool("trust-xff", true, "Trust the X-Forwarded-For header")
cmdlineParam = restful.QueryParameter("cmdline", "Linux kernel cmdline addition")
)
type wsHost struct {
prefix string
@ -59,6 +63,7 @@ func (ws *wsHost) register(rws *restful.WebService, alterRB func(*restful.RouteB
// read-only ISO support
b("boot.iso").
Produces(mime.ISO).
Param(cmdlineParam).
Doc("Get the " + ws.hostDoc + "'s boot CD-ROM image"),
// netboot support