copy shim/grub on default profile container change
Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
committed by
Jonathon Anderson
parent
2fe98e5f55
commit
03ef7447e9
@@ -2,9 +2,11 @@ package warewulfd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
warewulfconf "github.com/hpcng/warewulf/internal/pkg/config"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/container"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
@@ -17,6 +19,7 @@ to the tftp directory
|
||||
*/
|
||||
|
||||
func CopyShimGrub() (err error) {
|
||||
wwlog.Debug("copy shim and grub binaries")
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -29,24 +32,34 @@ func CopyShimGrub() (err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, ok := profiles["default"]; ok {
|
||||
if _, ok := profiles["default"]; !ok {
|
||||
return fmt.Errorf("default profile doesn't exist")
|
||||
}
|
||||
if profiles["default"].BootMethod.Get() == "ipxe" {
|
||||
// *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("default")
|
||||
shimPath := container.ShimFind(profiles["default"].ContainerName.Get())
|
||||
if shimPath == "" {
|
||||
return fmt.Errorf("no shim found in the default profile")
|
||||
return fmt.Errorf("no shim found in the container: %s", profiles["default"].ContainerName.Get())
|
||||
}
|
||||
err = util.CopyFile(shimPath, path.Join(conf.TFTP.TftpRoot, "shim.efi"))
|
||||
err = util.CopyFile(shimPath, path.Join(conf.Paths.Tftpdir, "warewulf", "shim.efi"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
grubPath := container.GrubFind("default")
|
||||
if shimPath == "" {
|
||||
return fmt.Errorf("no grub found in the default profile")
|
||||
_ = os.Chmod(path.Join(conf.Paths.Tftpdir, "warewulf", "shim.efi"), 0o755)
|
||||
grubPath := container.GrubFind(profiles["default"].ContainerName.Get())
|
||||
if grubPath == "" {
|
||||
return fmt.Errorf("no grub found in the container: %s", profiles["default"].ContainerName.Get())
|
||||
}
|
||||
err = util.CopyFile(grubPath, path.Join(conf.TFTP.TftpRoot, "grub.efi"))
|
||||
err = util.CopyFile(grubPath, path.Join(conf.Paths.Tftpdir, "warewulf", "grub.efi"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_ = os.Chmod(path.Join(conf.Paths.Tftpdir, "warewulf", "grub.efi"), 0o755)
|
||||
err = util.CopyFile(grubPath, path.Join(conf.Paths.Tftpdir, "warewulf", "grubx64.efi"))
|
||||
_ = os.Chmod(path.Join(conf.Paths.Tftpdir, "warewulf", "grubx64.efi"), 0o755)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user