Add --now flags to disable and remove

That will make it try to remove it if it currently running and refresh
the current running sysext merged

Signed-off-by: Itxaka <itxaka@kairos.io>
This commit is contained in:
Itxaka
2025-04-09 11:50:32 +02:00
parent 7daa1f8a5b
commit d323073dbb
3 changed files with 68 additions and 11 deletions

14
main.go
View File

@@ -936,6 +936,10 @@ The validate command expects a configuration file as its only argument. Local fi
Name: "passive",
Usage: "Disable the system extension for the passive boot entry",
},
&cli.BoolFlag{
Name: "now",
Usage: "Disable the system extension now and reload systemd-sysext",
},
},
Before: func(c *cli.Context) error {
if c.Bool("active") && c.Bool("passive") {
@@ -965,7 +969,7 @@ The validate command expects a configuration file as its only argument. Local fi
bootState = "passive"
}
ext := c.Args().First()
if err := action.DisableSystemExtension(cfg, ext, bootState); err != nil {
if err := action.DisableSystemExtension(cfg, ext, bootState, c.Bool("now")); err != nil {
cfg.Logger.Logger.Error().Err(err).Msg("failed disabling system extension")
return err
}
@@ -1002,6 +1006,12 @@ The validate command expects a configuration file as its only argument. Local fi
Usage: "Remove a system extension",
UsageText: "remove EXTENSION",
Description: "Remove a installed system extension",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "now",
Usage: "Remove the system extension now and reload systemd-sysext",
},
},
Action: func(c *cli.Context) error {
if c.Args().Len() != 1 {
return fmt.Errorf("extension required")
@@ -1011,7 +1021,7 @@ The validate command expects a configuration file as its only argument. Local fi
if err != nil {
return err
}
if err := action.RemoveSystemExtension(cfg, extension); err != nil {
if err := action.RemoveSystemExtension(cfg, extension, c.Bool("now")); err != nil {
cfg.Logger.Logger.Error().Err(err).Msg("failed removing system extension")
return err
}