Skip to content

Commit

Permalink
Merge pull request #242 from kairos-io/upgrade_livemedia_nope
Browse files Browse the repository at this point in the history
Add a check for livemedia when running upgrade
  • Loading branch information
mudler authored Mar 14, 2024
2 parents 39d5ccf + 009c7a6 commit 8b6dde8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ See https://kairos.io/docs/upgrade/manual/ for documentation.
if err := validateSource(c.String("source")); err != nil {
return err
}
if bootFromLiveMedia() {
return fmt.Errorf("cannot upgrade from live media/unknown boot state")
}

return checkRoot()
},
Expand Down Expand Up @@ -836,6 +839,20 @@ func validateSource(source string) error {
return nil
}

// Check
func bootFromLiveMedia() bool {
// Check if the system is booted from a LIVE media by checking if the file /run/cos/livecd is present
r, err := state.NewRuntime()
if err != nil {
return false
}
if r.BootState == state.LiveCD || r.BootState == state.Unknown {
return true
}

return false
}

func getReleasesFromProvider(includePrereleases bool) ([]string, error) {
var tags []string
bus.Manager.Response(events.EventAvailableReleases, func(p *pluggable.Plugin, r *pluggable.EventResponse) {
Expand Down

0 comments on commit 8b6dde8

Please sign in to comment.