kairos-agent/internal/agent/hooks/gruboptions.go
Ettore Di Giacinto 5c4e29f3d3 sparkles: Minor enhancements (#239)
* 🐛 Fixup grub option quoting

* ⚙️ Copy discovery to oem if found

*  Add environment block to install

* ⚙️ Use /oem for mount in kcrypt post-hook

* 📝 Update docs with installer env reference

* 🤖 Add test deps

* ⚙️ Be consistent and set env also for post-hooks

* ⚙️ propagate env in post-hooks
2022-10-18 07:45:07 +02:00

29 lines
622 B
Go

package hook
import (
"fmt"
config "github.com/kairos-io/kairos/pkg/config"
"github.com/kairos-io/kairos/pkg/machine"
"github.com/kairos-io/kairos/pkg/utils"
)
type GrubOptions struct{}
func (b GrubOptions) Run(c config.Config) error {
machine.Mount("COS_OEM", "/tmp/oem") //nolint:errcheck
defer func() {
machine.Umount("/tmp/oem")
}()
for k, v := range c.Install.GrubOptions {
out, err := utils.SH(fmt.Sprintf(`grub2-editenv /tmp/oem/grubenv set "%s=%s"`, k, v))
if err != nil {
fmt.Printf("could not set boot option: %s\n", out+err.Error())
return nil // do not error out
}
}
return nil
}