1
0
mirror of https://github.com/rancher/os.git synced 2025-09-01 23:04:41 +00:00

Add details to 'ros console list'

This commit is contained in:
Josh Curl
2016-06-28 11:18:26 -07:00
parent b22c075b95
commit 8f8dec51ea
3 changed files with 25 additions and 7 deletions

View File

@@ -3,7 +3,10 @@ package control
import (
"bufio"
"fmt"
"io/ioutil"
"os"
"sort"
"strings"
"golang.org/x/net/context"
@@ -121,10 +124,25 @@ func consoleList(c *cli.Context) error {
if err != nil {
return err
}
consoles = append(consoles, "default")
sort.Strings(consoles)
var currentConsole string
currentConsoleBytes, err := ioutil.ReadFile("/run/console-done")
if err == nil {
currentConsole = strings.TrimSpace(string(currentConsoleBytes))
} else {
log.Warnf("Failed to detect current console: %v", err)
}
fmt.Println("default")
for _, console := range consoles {
fmt.Println(console)
if console == currentConsole {
fmt.Printf("current %s\n", console)
} else if console == cfg.Rancher.Console {
fmt.Printf("enabled %s\n", console)
} else {
fmt.Printf("disabled %s\n", console)
}
}
return nil