mirror of
https://github.com/rancher/os.git
synced 2025-09-03 15:54:24 +00:00
Add details to 'ros console list'
This commit is contained in:
@@ -3,7 +3,10 @@ package control
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
|
|
||||||
@@ -121,10 +124,25 @@ func consoleList(c *cli.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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 {
|
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
|
return nil
|
||||||
|
@@ -29,6 +29,10 @@ func Main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = config.Set("rancher.console", newConsole); err != nil {
|
||||||
|
log.Errorf("Failed to update 'rancher.console': %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
if err = project.Up(context.Background(), options.Up{
|
if err = project.Up(context.Background(), options.Up{
|
||||||
Log: true,
|
Log: true,
|
||||||
}, "console"); err != nil {
|
}, "console"); err != nil {
|
||||||
@@ -38,8 +42,4 @@ func Main() {
|
|||||||
if err = project.Restart(context.Background(), 10, "docker"); err != nil {
|
if err = project.Restart(context.Background(), 10, "docker"); err != nil {
|
||||||
log.Errorf("Failed to restart Docker: %v", err)
|
log.Errorf("Failed to restart Docker: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = config.Set("rancher.console", newConsole); err != nil {
|
|
||||||
log.Errorf("Failed to update 'rancher.console': %v", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -126,7 +126,7 @@ if [ -x /opt/rancher/bin/start.sh ]; then
|
|||||||
/opt/rancher/bin/start.sh || true
|
/opt/rancher/bin/start.sh || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
touch /run/console-done
|
echo `ros config get rancher.console` > /run/console-done
|
||||||
|
|
||||||
if [ -x /etc/rc.local ]; then
|
if [ -x /etc/rc.local ]; then
|
||||||
echo Executing rc.local
|
echo Executing rc.local
|
||||||
|
Reference in New Issue
Block a user