mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-05-12 10:24:23 +00:00
sparkles: Auto-detect device with 'auto'
This commit is contained in:
parent
d7e6e9efa4
commit
0763c820f2
internal/agent
@ -197,6 +197,10 @@ func RunInstall(options map[string]string) error {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if device == "auto" {
|
||||
device = detectDevice()
|
||||
}
|
||||
|
||||
cloudInit, ok := options["cc"]
|
||||
if !ok {
|
||||
fmt.Println("cloudInit must be specified among options")
|
||||
|
@ -110,6 +110,23 @@ func promptToUnstructured(p events.YAMLPrompt, unstructuredYAML map[string]inter
|
||||
return unstructuredYAML, nil
|
||||
}
|
||||
|
||||
func detectDevice() string {
|
||||
preferedDevice := "/dev/sda"
|
||||
maxSize := float64(0)
|
||||
|
||||
block, err := ghw.Block()
|
||||
if err == nil {
|
||||
for _, disk := range block.Disks {
|
||||
size := float64(disk.SizeBytes) / float64(GiB)
|
||||
if size > maxSize {
|
||||
maxSize = size
|
||||
preferedDevice = "/dev/" + disk.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
return preferedDevice
|
||||
}
|
||||
|
||||
func InteractiveInstall(spawnShell bool) error {
|
||||
bus.Manager.Initialize()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user