1
0
mirror of https://github.com/rancher/os.git synced 2025-06-27 07:16:48 +00:00

Add 'ros console enable' command

This commit is contained in:
Josh Curl 2016-06-12 22:28:24 -07:00
parent 3153c28e86
commit c4c8ec402c
No known key found for this signature in database
GPG Key ID: 82B504B9BCCFA677

View File

@ -20,7 +20,7 @@ func consoleSubcommands() []cli.Command {
return []cli.Command{
{
Name: "switch",
Usage: "switch currently running console",
Usage: "switch console without a reboot",
Action: consoleSwitch,
Flags: []cli.Flag{
cli.BoolFlag{
@ -29,6 +29,11 @@ func consoleSubcommands() []cli.Command {
},
},
},
{
Name: "enable",
Usage: "set console to be switched on next reboot",
Action: consoleEnable,
},
{
Name: "list",
Usage: "list available consoles",
@ -39,7 +44,7 @@ func consoleSubcommands() []cli.Command {
func consoleSwitch(c *cli.Context) error {
if len(c.Args()) != 1 {
log.Fatal("Must specify exactly one existing container")
log.Fatal("Must specify exactly one console to switch to")
}
newConsole := c.Args()[0]
@ -85,6 +90,27 @@ func consoleSwitch(c *cli.Context) error {
return service.Log(context.Background(), true)
}
func consoleEnable(c *cli.Context) error {
if len(c.Args()) != 1 {
log.Fatal("Must specify exactly one console to enable")
}
newConsole := c.Args()[0]
cfg := config.LoadConfig()
if newConsole != "default" {
if err := compose.StageServices(cfg, newConsole); err != nil {
return err
}
}
if err := config.Set("rancher.console", newConsole); err != nil {
log.Errorf("Failed to update 'rancher.console': %v", err)
}
return nil
}
func consoleList(c *cli.Context) error {
cfg := config.LoadConfig()