diff --git a/Dockerfile b/Dockerfile index d2f971d..2cbfb3d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/cmd/dkl-local-server/boot-iso.go b/cmd/dkl-local-server/boot-iso.go index 1298440..b9c568d 100644 --- a/cmd/dkl-local-server/boot-iso.go +++ b/cmd/dkl-local-server/boot-iso.go @@ -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) diff --git a/cmd/dkl-local-server/render-context.go b/cmd/dkl-local-server/render-context.go index 4a9c76e..7a756cb 100644 --- a/cmd/dkl-local-server/render-context.go +++ b/cmd/dkl-local-server/render-context.go @@ -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 } diff --git a/cmd/dkl-local-server/ws-host.go b/cmd/dkl-local-server/ws-host.go index 200de1c..edee5ef 100644 --- a/cmd/dkl-local-server/ws-host.go +++ b/cmd/dkl-local-server/ws-host.go @@ -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