Do not do anything if rd.cos.disable its on the cmdline

That means we dont want to run any immutable stuff, for netboot and
cdrom

Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
This commit is contained in:
Itxaka
2023-02-15 10:53:48 +01:00
parent 220641df60
commit 28e6cfbff8
2 changed files with 12 additions and 6 deletions

View File

@@ -39,7 +39,13 @@ Sends a generic event payload with the configuration found in the scanned direct
zerolog.SetGlobalLevel(zerolog.DebugLevel) zerolog.SetGlobalLevel(zerolog.DebugLevel)
} }
// First set the sentinel file // You can pass rd.cos.disable in the cmdline to disable the whole immutable stuff
if len(utils.ReadCMDLineArg("rd.cos.disable")) > 0 {
log.Logger.Info().Msg("Stanza rd.cos.disable on the cmdline. Doing nothing.")
return nil
}
// First set the sentinel file.
if !c.Bool("dry-run") { if !c.Bool("dry-run") {
err = utils.SetSentinelFile() err = utils.SetSentinelFile()
if err != nil { if err != nil {
@@ -48,8 +54,7 @@ Sends a generic event payload with the configuration found in the scanned direct
} }
} }
// If we boot from CD, we do nothing cdBoot, err := utils.BootedFromLiveMedia()
cdBoot, err := utils.BootedFromCD()
if err != nil { if err != nil {
log.Logger.Err(err).Send() log.Logger.Err(err).Send()
return err return err
@@ -57,6 +62,7 @@ Sends a generic event payload with the configuration found in the scanned direct
img := utils.ReadCMDLineArg("cos-img/filename=") img := utils.ReadCMDLineArg("cos-img/filename=")
if len(img) == 0 { if len(img) == 0 {
// If we boot from LIVE media or are using dry-run, we use a fake img as we still want to do things
if c.Bool("dry-run") || cdBoot { if c.Bool("dry-run") || cdBoot {
img = []string{"fake"} img = []string{"fake"}
} else { } else {

View File

@@ -8,8 +8,8 @@ import (
"strings" "strings"
) )
// BootedFromCD tells us if we are currently runnig of the LiveCD // BootedFromLiveMedia tells us if we are currently running off LIVE media like cd/usb or netboot
func BootedFromCD() (bool, error) { func BootedFromLiveMedia() (bool, error) {
runtime, err := state.NewRuntime() runtime, err := state.NewRuntime()
if err != nil { if err != nil {
return false, err return false, err
@@ -151,4 +151,4 @@ func SetSentinelFile() error {
return err return err
} }
return nil return nil
} }