mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-05-11 09:55:19 +00:00
sparkles: Add reset hook (#723)
Signed-off-by: mudler <mudler@c3os.io> Signed-off-by: mudler <mudler@c3os.io>
This commit is contained in:
parent
9b16896a1a
commit
746135eede
internal/agent
@ -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{},
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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...")
|
||||
|
Loading…
Reference in New Issue
Block a user