package cmd import ( "fmt" "github.com/portainer/kubesolo-os/update/pkg/grubenv" ) // Status displays the current A/B slot configuration and boot state. func Status(args []string) error { opts := parseOpts(args) env := grubenv.New(opts.GrubenvPath) vars, err := env.ReadAll() if err != nil { return fmt.Errorf("reading GRUB environment: %w", err) } activeSlot := vars["active_slot"] bootCounter := vars["boot_counter"] bootSuccess := vars["boot_success"] passiveSlot := "B" if activeSlot == "B" { passiveSlot = "A" } fmt.Println("KubeSolo OS — A/B Partition Status") fmt.Println("───────────────────────────────────") fmt.Printf(" Active slot: %s\n", activeSlot) fmt.Printf(" Passive slot: %s\n", passiveSlot) fmt.Printf(" Boot counter: %s\n", bootCounter) fmt.Printf(" Boot success: %s\n", bootSuccess) if bootSuccess == "1" { fmt.Println("\n ✓ System is healthy (boot confirmed)") } else if bootCounter == "0" { fmt.Println("\n ✗ Boot counter exhausted — rollback will occur on next reboot") } else { fmt.Printf("\n ⚠ Boot pending verification (%s attempts remaining)\n", bootCounter) } return nil }