mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-09-18 16:06:58 +00:00
Try to fix hooks (#718)
* fix hooks --------- Signed-off-by: Itxaka <itxaka@kairos.io>
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
config "github.com/kairos-io/kairos-agent/v2/pkg/config"
|
||||
@@ -14,7 +13,6 @@ import (
|
||||
"github.com/kairos-io/kairos-sdk/bundles"
|
||||
"github.com/kairos-io/kairos-sdk/machine"
|
||||
"github.com/kairos-io/kairos-sdk/utils"
|
||||
kcrypt "github.com/kairos-io/kcrypt/pkg/lib"
|
||||
)
|
||||
|
||||
// BundlePostInstall install bundles just after installation
|
||||
@@ -41,29 +39,6 @@ func (b BundlePostInstall) Run(c config.Config, _ v1.Spec) error {
|
||||
_ = machine.Umount(constants.OEMPath)
|
||||
}()
|
||||
|
||||
// Path if we have encrypted persistent and we are not on UKI
|
||||
if len(c.Install.Encrypt) != 0 {
|
||||
err := kcrypt.UnlockAll(false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Close all the unencrypted partitions at the end!
|
||||
defer func() {
|
||||
for _, p := range c.Install.Encrypt {
|
||||
_, _ = utils.SH("udevadm trigger --type=all || udevadm trigger")
|
||||
syscall.Sync()
|
||||
c.Logger.Debugf("Closing unencrypted /dev/disk/by-label/%s", p)
|
||||
out, err := utils.SH(fmt.Sprintf("cryptsetup close /dev/disk/by-label/%s", p))
|
||||
// There is a known error with cryptsetup that it can't close the device because of a semaphore
|
||||
// doesnt seem to affect anything as the device is closed as expected so we ignore it if it matches the
|
||||
// output of the error
|
||||
if err != nil && !strings.Contains(out, "incorrect semaphore state") {
|
||||
c.Logger.Warnf("could not close /dev/disk/by-label/%s: %s", p, out)
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
_, _ = utils.SH("udevadm trigger --type=all || udevadm trigger")
|
||||
syscall.Sync()
|
||||
err := c.Syscall.Mount(filepath.Join("/dev/disk/by-label", constants.PersistentLabel), constants.UsrLocalPath, "ext4", 0, "")
|
||||
|
Reference in New Issue
Block a user