mirror of
https://github.com/kairos-io/kairos-sdk.git
synced 2025-04-28 03:20:52 +00:00
Semi force the umount of oem when dealing with mounts (#40)
This commit is contained in:
parent
396c5553ca
commit
7203787534
@ -35,14 +35,11 @@ func addCloudConfig(cloudConfig, filename string) error {
|
|||||||
|
|
||||||
func writeCloudConfig(oem state.PartitionState, cloudConfig, subpath, filename string) error {
|
func writeCloudConfig(oem state.PartitionState, cloudConfig, subpath, filename string) error {
|
||||||
mountPath := "/tmp/oem"
|
mountPath := "/tmp/oem"
|
||||||
|
defer mounts.Umount(state.PartitionState{Mounted: true, MountPoint: mountPath}) //nolint:errcheck
|
||||||
|
|
||||||
if err := mounts.PrepareWrite(oem, mountPath); err != nil {
|
if err := mounts.PrepareWrite(oem, mountPath); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer func() {
|
|
||||||
oem.MountPoint = mountPath
|
|
||||||
mounts.Umount(oem) //nolint:errcheck
|
|
||||||
}()
|
|
||||||
_ = os.MkdirAll(filepath.Join(mountPath, subpath), 0650)
|
_ = os.MkdirAll(filepath.Join(mountPath, subpath), 0650)
|
||||||
return os.WriteFile(filepath.Join(mountPath, subpath, fmt.Sprintf("%s.yaml", filename)), []byte(cloudConfig), 0650)
|
return os.WriteFile(filepath.Join(mountPath, subpath, fmt.Sprintf("%s.yaml", filename)), []byte(cloudConfig), 0650)
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ func SetGRUBOptions(opts map[string]string) Option {
|
|||||||
|
|
||||||
func setGRUBOptions(opts map[string]string) error {
|
func setGRUBOptions(opts map[string]string) error {
|
||||||
mountPath := "/tmp/oem"
|
mountPath := "/tmp/oem"
|
||||||
|
defer mounts.Umount(state.PartitionState{Mounted: true, MountPoint: mountPath}) //nolint:errcheck
|
||||||
runtime, err := state.NewRuntime()
|
runtime, err := state.NewRuntime()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -32,10 +33,6 @@ func setGRUBOptions(opts map[string]string) error {
|
|||||||
if err := mounts.PrepareWrite(oem, mountPath); err != nil {
|
if err := mounts.PrepareWrite(oem, mountPath); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer func() {
|
|
||||||
oem.MountPoint = mountPath
|
|
||||||
mounts.Umount(oem) //nolint:errcheck
|
|
||||||
}()
|
|
||||||
|
|
||||||
for k, v := range opts {
|
for k, v := range opts {
|
||||||
out, err := utils.SH(fmt.Sprintf(`%s /tmp/oem/grubenv set "%s=%s"`, utils.FindCommand("grub2-editenv", []string{"grub2-editenv", "grub-editenv"}), k, v))
|
out, err := utils.SH(fmt.Sprintf(`%s /tmp/oem/grubenv set "%s=%s"`, utils.FindCommand("grub2-editenv", []string{"grub2-editenv", "grub-editenv"}), k, v))
|
||||||
|
Loading…
Reference in New Issue
Block a user