using ProvisionSend instean of GrubSend
Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
committed by
Jonathon Anderson
parent
60dc8f6251
commit
0c9bf78cd0
@@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
warewulfconf "github.com/hpcng/warewulf/internal/pkg/config"
|
||||
@@ -14,6 +15,21 @@ import (
|
||||
|
||||
// TODO: https://github.com/danderson/netboot/blob/master/pixiecore/dhcp.go
|
||||
// TODO: https://github.com/pin/tftp
|
||||
/*
|
||||
wrapper type for the server mux as him requests http://efiboot//grub.efi which is filtered out by http to `301 Moved Permanently` which
|
||||
which shim.fi can't handle. So filter out `//` before they hit http
|
||||
*/
|
||||
type slashFix struct {
|
||||
mux http.Handler
|
||||
}
|
||||
|
||||
/*
|
||||
Filter out the '//'
|
||||
*/
|
||||
func (h *slashFix) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
r.URL.Path = strings.Replace(r.URL.Path, "//", "/", -1)
|
||||
h.mux.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
func RunServer() error {
|
||||
err := DaemonInitLogging()
|
||||
@@ -53,23 +69,33 @@ func RunServer() error {
|
||||
if err != nil {
|
||||
wwlog.Warn("couldn't copy default shim: %s", err)
|
||||
}
|
||||
|
||||
http.HandleFunc("/provision/", ProvisionSend)
|
||||
http.HandleFunc("/ipxe/", ProvisionSend)
|
||||
http.HandleFunc("/grub/", GrubSend)
|
||||
http.HandleFunc("/kernel/", ProvisionSend)
|
||||
http.HandleFunc("/kmods/", ProvisionSend)
|
||||
http.HandleFunc("/container/", ProvisionSend)
|
||||
http.HandleFunc("/overlay-system/", ProvisionSend)
|
||||
http.HandleFunc("/overlay-runtime/", ProvisionSend)
|
||||
http.HandleFunc("/status", StatusSend)
|
||||
var wwHandler http.ServeMux
|
||||
wwHandler.HandleFunc("/provision/", ProvisionSend)
|
||||
wwHandler.HandleFunc("/ipxe/", ProvisionSend)
|
||||
wwHandler.HandleFunc("/efiboot/", ProvisionSend)
|
||||
wwHandler.HandleFunc("/kernel/", ProvisionSend)
|
||||
wwHandler.HandleFunc("/kmods/", ProvisionSend)
|
||||
wwHandler.HandleFunc("/container/", ProvisionSend)
|
||||
wwHandler.HandleFunc("/overlay-system/", ProvisionSend)
|
||||
wwHandler.HandleFunc("/overlay-runtime/", ProvisionSend)
|
||||
wwHandler.HandleFunc("/status", StatusSend)
|
||||
|
||||
conf := warewulfconf.Get()
|
||||
|
||||
daemonPort := conf.Warewulf.Port
|
||||
wwlog.Serv("Starting HTTPD REST service on port %d", daemonPort)
|
||||
/*
|
||||
wwlog.Serv("Starting HTTPD REST service on port %d", daemonPort)
|
||||
s := &http.Server{
|
||||
Addr: ":" + strconv.Itoa(daemonPort),
|
||||
Handler: &slashFix{&wwHandler},
|
||||
ReadTimeout: 10 * time.Second,
|
||||
IdleTimeout: 10 * time.Second,
|
||||
WriteTimeout: 10 * time.Second,
|
||||
}
|
||||
err = s.ListenAndServe()
|
||||
*/
|
||||
err = http.ListenAndServe(":"+strconv.Itoa(daemonPort), &slashFix{&wwHandler})
|
||||
|
||||
err = http.ListenAndServe(":"+strconv.Itoa(daemonPort), nil)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Could not start listening service")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user