From fa2ed4663c7095752877b198bbf14afa0190c911 Mon Sep 17 00:00:00 2001 From: Titi Wangsa bin Damhore Date: Mon, 2 Sep 2024 08:56:33 -0700 Subject: [PATCH] Update kexec.go --- kexec/cmd/kexec.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kexec/cmd/kexec.go b/kexec/cmd/kexec.go index ba6e598..d0d9848 100644 --- a/kexec/cmd/kexec.go +++ b/kexec/cmd/kexec.go @@ -30,6 +30,7 @@ var kexecCmd = &cobra.Command{ filesystemType := os.Getenv("FS_TYPE") kernelPath := os.Getenv("KERNEL_PATH") initrdPath := os.Getenv("INITRD_PATH") + grubCfgPath := os.Getenv("GRUBCFG_PATH") cmdLine := os.Getenv("CMD_LINE") // These two strings contain the updated paths including the mountAction path @@ -39,6 +40,10 @@ var kexecCmd = &cobra.Command{ log.Fatalf("No Block Device speified with Environment Variable [BLOCK_DEVICE]") } + if grubCfgPath == "" { + grubCfgPath = "boot/grub/grub.cfg" + } + // Create the /mountAction mountpoint (no folders exist previously in scratch container) err := os.Mkdir(mountAction, os.ModeDir) if err != nil { @@ -55,7 +60,7 @@ var kexecCmd = &cobra.Command{ // If we specify no kernelPath then we will fallback to autodetect and ignore the initrd and cmdline that may be passed // by environment variables if kernelPath == "" { - grubFile, err := ioutil.ReadFile(fmt.Sprintf("%s/boot/grub/grub.cfg", mountAction)) + grubFile, err := ioutil.ReadFile(fmt.Sprintf("%s/%s", mountAction, grubCfgPath)) if err != nil { log.Fatal(err) }