default profile needs to have a container
Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
committed by
Jonathon Anderson
parent
a36cb23319
commit
2fe98e5f55
52
internal/pkg/warewulfd/copyshim.go
Normal file
52
internal/pkg/warewulfd/copyshim.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package warewulfd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
|
||||
warewulfconf "github.com/hpcng/warewulf/internal/pkg/config"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/container"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
)
|
||||
|
||||
/*
|
||||
Copies the default shim, which is the shim located in the default container
|
||||
to the tftp directory
|
||||
*/
|
||||
|
||||
func CopyShimGrub() (err error) {
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
conf := warewulfconf.Get()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
profiles, err := nodeDB.MapAllProfiles()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, ok := profiles["default"]; ok {
|
||||
return fmt.Errorf("default profile doesn't exist")
|
||||
}
|
||||
if profiles["default"].BootMethod.Get() == "ipxe" {
|
||||
return
|
||||
}
|
||||
shimPath := container.ShimFind("default")
|
||||
if shimPath == "" {
|
||||
return fmt.Errorf("no shim found in the default profile")
|
||||
}
|
||||
err = util.CopyFile(shimPath, path.Join(conf.TFTP.TftpRoot, "shim.efi"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
grubPath := container.GrubFind("default")
|
||||
if shimPath == "" {
|
||||
return fmt.Errorf("no grub found in the default profile")
|
||||
}
|
||||
err = util.CopyFile(grubPath, path.Join(conf.TFTP.TftpRoot, "grub.efi"))
|
||||
return
|
||||
}
|
||||
@@ -49,6 +49,11 @@ func RunServer() error {
|
||||
wwlog.Error("Could not prepopulate node status DB: %s", err)
|
||||
}
|
||||
|
||||
err = CopyShimGrub()
|
||||
if err != nil {
|
||||
wwlog.Warn("couldn't copy default shim: %s", err)
|
||||
}
|
||||
|
||||
http.HandleFunc("/provision/", ProvisionSend)
|
||||
http.HandleFunc("/ipxe/", ProvisionSend)
|
||||
http.HandleFunc("/kernel/", ProvisionSend)
|
||||
|
||||
Reference in New Issue
Block a user