use grub/shim from host system
Also the boot method is now configured globaly as this is the only way to make sure that unkonwn nodes get the right stuff Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
committed by
Jonathon Anderson
parent
938eff2cfa
commit
4379c4c18d
@@ -9,49 +9,29 @@ import (
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
|
||||
"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
|
||||
Copies the default shim, which is the shim located on host
|
||||
to the tftp directory
|
||||
*/
|
||||
|
||||
func CopyShimGrub() (err error) {
|
||||
wwlog.Debug("copy shim and grub binaries")
|
||||
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")
|
||||
}
|
||||
// *Entry.Get doesn't work the same as it works for nodes!
|
||||
if profiles["default"].BootMethod.Get() == "ipxe" || profiles["default"].BootMethod.Get() == "" {
|
||||
wwlog.Verbose("default profile uses ipxe boot")
|
||||
return
|
||||
}
|
||||
shimPath := container.ShimFind(profiles["default"].ContainerName.Get())
|
||||
wwlog.Debug("copy shim and grub binaries from host")
|
||||
shimPath := container.ShimFindPath("/")
|
||||
if shimPath == "" {
|
||||
return fmt.Errorf("no shim found in the container: %s", profiles["default"].ContainerName.Get())
|
||||
return fmt.Errorf("no shim found on the host os")
|
||||
}
|
||||
err = util.CopyFile(shimPath, path.Join(conf.Paths.Tftpdir, "warewulf", "shim.efi"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_ = os.Chmod(path.Join(conf.Paths.Tftpdir, "warewulf", "shim.efi"), 0o755)
|
||||
grubPath := container.GrubFind(profiles["default"].ContainerName.Get())
|
||||
grubPath := container.GrubFindPath("/")
|
||||
if grubPath == "" {
|
||||
return fmt.Errorf("no grub found in the container: %s", profiles["default"].ContainerName.Get())
|
||||
return fmt.Errorf("no grub found on host os")
|
||||
}
|
||||
err = util.CopyFile(grubPath, path.Join(conf.Paths.Tftpdir, "warewulf", "grub.efi"))
|
||||
if err != nil {
|
||||
|
||||
@@ -65,7 +65,6 @@ 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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user