mirror of
https://github.com/kairos-io/immucore.git
synced 2025-09-16 06:58:58 +00:00
Use SDK to get machine state
This commit is contained in:
@@ -1,20 +1,15 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
|
||||
"github.com/kairos-io/kairos/sdk/state"
|
||||
"github.com/twpayne/go-vfs"
|
||||
)
|
||||
|
||||
func BootedFromCD(fs vfs.FS) bool {
|
||||
cdlabel := regexp.MustCompile("root=live:CDLABEL=")
|
||||
cmdLine, err := fs.ReadFile("/proc/cmdline")
|
||||
func BootedFromCD(fs vfs.FS) (bool, error) {
|
||||
runtime, err := state.NewRuntime()
|
||||
if err != nil {
|
||||
return false
|
||||
return false, err
|
||||
}
|
||||
|
||||
if cdlabel.MatchString(string(cmdLine)) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return runtime.BootState == state.LiveCD, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user