From 98ccb577990f8d4f90373586f98b5ca4dfba1d36 Mon Sep 17 00:00:00 2001 From: Itxaka Date: Fri, 15 Sep 2023 14:33:41 +0200 Subject: [PATCH] debug extension Signed-off-by: Itxaka --- internal/agent/hooks/bundles.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/internal/agent/hooks/bundles.go b/internal/agent/hooks/bundles.go index 194314e1..38974e31 100644 --- a/internal/agent/hooks/bundles.go +++ b/internal/agent/hooks/bundles.go @@ -1,10 +1,14 @@ package hook import ( + "fmt" config "github.com/kairos-io/kairos-agent/v2/pkg/config" v1 "github.com/kairos-io/kairos-agent/v2/pkg/types/v1" "github.com/kairos-io/kairos-sdk/bundles" "github.com/kairos-io/kairos-sdk/machine" + "os" + "os/exec" + "syscall" ) type BundleOption struct{} @@ -16,13 +20,27 @@ func (b BundleOption) Run(c config.Config, _ v1.Spec) error { machine.Umount("/usr/local") //nolint:errcheck }() + _ = os.MkdirAll("/usr/local/var-lib-extensions.bind", os.ModeDir|os.ModePerm) + cmd := exec.Command("rsync -aqAX /var/lib/extensions /usr/local/var-lib-extensions.bind") + _, err := cmd.CombinedOutput() + if err != nil { + fmt.Println(err) + } + err = syscall.Mount("/usr/local/var-lib-extensions.bind", "/var/lib/extensions", "", syscall.MS_BIND, "") + if err != nil { + fmt.Println(err) + } + defer func() { + _ = syscall.Unmount("/var/lib/extensions", 0) + }() + machine.Mount("COS_OEM", "/oem") //nolint:errcheck defer func() { machine.Umount("/oem") //nolint:errcheck }() opts := c.Install.Bundles.Options() - err := bundles.RunBundles(opts...) + err = bundles.RunBundles(opts...) if c.FailOnBundleErrors && err != nil { return err }