diff --git a/internal/agent/hooks/hook.go b/internal/agent/hooks/hook.go index 63ee79a..8b18e06 100644 --- a/internal/agent/hooks/hook.go +++ b/internal/agent/hooks/hook.go @@ -8,7 +8,7 @@ type Interface interface { Run(c config.Config) error } -var All = []Interface{ +var AfterInstall = []Interface{ &RunStage{}, // Shells out to stages defined from the container image &GrubOptions{}, // Set custom GRUB options &BundleOption{}, @@ -16,6 +16,10 @@ var All = []Interface{ &Lifecycle{}, // Handles poweroff/reboot by config options } +var AfterReset = []Interface{ + &Kcrypt{}, +} + var FirstBoot = []Interface{ &BundlePostInstall{}, &GrubPostInstallOptions{}, diff --git a/internal/agent/install.go b/internal/agent/install.go index aed2348..6050693 100644 --- a/internal/agent/install.go +++ b/internal/agent/install.go @@ -286,7 +286,7 @@ func RunInstall(options map[string]string) error { os.Exit(1) } - if err := hook.Run(*c, hook.All...); err != nil { + if err := hook.Run(*c, hook.AfterInstall...); err != nil { return err } diff --git a/internal/agent/reset.go b/internal/agent/reset.go index c689045..1a96402 100644 --- a/internal/agent/reset.go +++ b/internal/agent/reset.go @@ -8,6 +8,7 @@ import ( "sync" "time" + hook "github.com/kairos-io/kairos/internal/agent/hooks" "github.com/kairos-io/kairos/internal/bus" "github.com/kairos-io/kairos/internal/cmd" "github.com/kairos-io/kairos/pkg/config" @@ -88,6 +89,10 @@ func Reset(dir ...string) error { os.Exit(1) } + if err := hook.Run(*c, hook.AfterReset...); err != nil { + return err + } + bus.Manager.Publish(sdk.EventAfterReset, sdk.EventPayload{}) //nolint:errcheck pterm.Info.Println("Rebooting in 60 seconds, press Enter to abort...")