1
0
mirror of https://github.com/kairos-io/kairos-agent.git synced 2025-05-11 09:55:19 +00:00

sparkles: Add reset hook ()

Signed-off-by: mudler <mudler@c3os.io>

Signed-off-by: mudler <mudler@c3os.io>
This commit is contained in:
Ettore Di Giacinto 2023-01-25 13:38:56 +01:00 committed by Itxaka
parent 9b16896a1a
commit 746135eede
3 changed files with 11 additions and 2 deletions
internal/agent

View File

@ -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{},

View File

@ -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
}

View File

@ -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...")