mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-09-01 17:16:40 +00:00
sparkles: Auto-detect device with 'auto'
This commit is contained in:
committed by
Itxaka
parent
d7e6e9efa4
commit
0763c820f2
@@ -197,6 +197,10 @@ func RunInstall(options map[string]string) error {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if device == "auto" {
|
||||||
|
device = detectDevice()
|
||||||
|
}
|
||||||
|
|
||||||
cloudInit, ok := options["cc"]
|
cloudInit, ok := options["cc"]
|
||||||
if !ok {
|
if !ok {
|
||||||
fmt.Println("cloudInit must be specified among options")
|
fmt.Println("cloudInit must be specified among options")
|
||||||
|
@@ -110,6 +110,23 @@ func promptToUnstructured(p events.YAMLPrompt, unstructuredYAML map[string]inter
|
|||||||
return unstructuredYAML, nil
|
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 {
|
func InteractiveInstall(spawnShell bool) error {
|
||||||
bus.Manager.Initialize()
|
bus.Manager.Initialize()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user