mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-08-23 10:33:20 +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
@ -8,7 +8,7 @@ type Interface interface {
|
|||||||
Run(c config.Config) error
|
Run(c config.Config) error
|
||||||
}
|
}
|
||||||
|
|
||||||
var All = []Interface{
|
var AfterInstall = []Interface{
|
||||||
&RunStage{}, // Shells out to stages defined from the container image
|
&RunStage{}, // Shells out to stages defined from the container image
|
||||||
&GrubOptions{}, // Set custom GRUB options
|
&GrubOptions{}, // Set custom GRUB options
|
||||||
&BundleOption{},
|
&BundleOption{},
|
||||||
@ -16,6 +16,10 @@ var All = []Interface{
|
|||||||
&Lifecycle{}, // Handles poweroff/reboot by config options
|
&Lifecycle{}, // Handles poweroff/reboot by config options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var AfterReset = []Interface{
|
||||||
|
&Kcrypt{},
|
||||||
|
}
|
||||||
|
|
||||||
var FirstBoot = []Interface{
|
var FirstBoot = []Interface{
|
||||||
&BundlePostInstall{},
|
&BundlePostInstall{},
|
||||||
&GrubPostInstallOptions{},
|
&GrubPostInstallOptions{},
|
||||||
|
@ -286,7 +286,7 @@ func RunInstall(options map[string]string) error {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := hook.Run(*c, hook.All...); err != nil {
|
if err := hook.Run(*c, hook.AfterInstall...); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
hook "github.com/kairos-io/kairos/internal/agent/hooks"
|
||||||
"github.com/kairos-io/kairos/internal/bus"
|
"github.com/kairos-io/kairos/internal/bus"
|
||||||
"github.com/kairos-io/kairos/internal/cmd"
|
"github.com/kairos-io/kairos/internal/cmd"
|
||||||
"github.com/kairos-io/kairos/pkg/config"
|
"github.com/kairos-io/kairos/pkg/config"
|
||||||
@ -88,6 +89,10 @@ func Reset(dir ...string) error {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := hook.Run(*c, hook.AfterReset...); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
bus.Manager.Publish(sdk.EventAfterReset, sdk.EventPayload{}) //nolint:errcheck
|
bus.Manager.Publish(sdk.EventAfterReset, sdk.EventPayload{}) //nolint:errcheck
|
||||||
|
|
||||||
pterm.Info.Println("Rebooting in 60 seconds, press Enter to abort...")
|
pterm.Info.Println("Rebooting in 60 seconds, press Enter to abort...")
|
||||||
|
Loading…
Reference in New Issue
Block a user