mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-09-19 17:25:01 +00:00
Try to fix hooks (#718)
* fix hooks --------- Signed-off-by: Itxaka <itxaka@kairos.io>
This commit is contained in:
@@ -2,7 +2,6 @@ package uki
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/kairos-io/kairos-agent/v2/pkg/action"
|
||||
"github.com/kairos-io/kairos-agent/v2/pkg/config"
|
||||
"github.com/kairos-io/kairos-agent/v2/pkg/constants"
|
||||
@@ -35,14 +34,12 @@ func (r *ResetAction) Run() (err error) {
|
||||
cleanup := utils.NewCleanStack()
|
||||
defer func() { err = cleanup.Cleanup(err) }()
|
||||
|
||||
// Unmount partitions if any is already mounted before formatting
|
||||
err = e.UnmountPartitions(r.spec.Partitions.PartitionsByMountPoint(true))
|
||||
if err != nil {
|
||||
r.cfg.Logger.Errorf("unmounting partitions: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
// At this point, both partitions are unlocked but they might not be mounted, like persistent
|
||||
// And the /dev/disk/by-label are not pointing to the proper ones
|
||||
// We need to manually trigger udev to make sure the symlinks are correct
|
||||
_, err = utils.SH("udevadm trigger --type=all || udevadm trigger")
|
||||
_, err = utils.SH("udevadm settle")
|
||||
|
||||
// Reformat persistent partition
|
||||
if r.spec.FormatPersistent {
|
||||
persistent := r.spec.Partitions.Persistent
|
||||
if persistent != nil {
|
||||
@@ -58,11 +55,20 @@ func (r *ResetAction) Run() (err error) {
|
||||
if r.spec.FormatOEM {
|
||||
oem := r.spec.Partitions.OEM
|
||||
if oem != nil {
|
||||
err = e.UnmountPartition(oem)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = e.FormatPartition(oem)
|
||||
if err != nil {
|
||||
r.cfg.Logger.Errorf("formatting OEM partition: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
// Mount it back, as oem is mounted during recovery, keep everything as is
|
||||
err = e.MountPartition(oem)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,14 +107,6 @@ func (r *ResetAction) Run() (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if mnt, err := elementalUtils.IsMounted(r.cfg, r.spec.Partitions.OEM); !mnt && err == nil {
|
||||
err = e.MountPartition(r.spec.Partitions.OEM)
|
||||
if err != nil {
|
||||
r.cfg.Logger.Errorf("mounting oem partition: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err = Hook(r.cfg, constants.AfterResetHook)
|
||||
if err != nil {
|
||||
r.cfg.Logger.Errorf("running after install hook: %s", err.Error())
|
||||
|
Reference in New Issue
Block a user