2022-09-08 13:39:26 +00:00
|
|
|
package hook
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2022-09-17 16:43:51 +00:00
|
|
|
config "github.com/kairos-io/kairos/pkg/config"
|
2022-10-02 22:16:01 +00:00
|
|
|
"github.com/kairos-io/kairos/pkg/machine"
|
2022-09-17 16:43:51 +00:00
|
|
|
"github.com/kairos-io/kairos/pkg/utils"
|
2022-09-08 13:39:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type GrubOptions struct{}
|
|
|
|
|
|
|
|
func (b GrubOptions) Run(c config.Config) error {
|
|
|
|
|
2022-10-02 22:16:01 +00:00
|
|
|
machine.Mount("COS_OEM", "/tmp/oem") //nolint:errcheck
|
|
|
|
defer func() {
|
|
|
|
machine.Umount("/tmp/oem")
|
|
|
|
}()
|
2022-09-08 13:39:26 +00:00
|
|
|
for k, v := range c.Install.GrubOptions {
|
2022-10-18 05:45:07 +00:00
|
|
|
out, err := utils.SH(fmt.Sprintf(`grub2-editenv /tmp/oem/grubenv set "%s=%s"`, k, v))
|
2022-09-08 13:39:26 +00:00
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("could not set boot option: %s\n", out+err.Error())
|
|
|
|
return nil // do not error out
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|