mirror of
https://github.com/rancher/os.git
synced 2025-08-15 21:43:42 +00:00
- Use burmilla GitHub repos - Release under burmilla Docker Hub - GitHub action for create releases - Updated boot image and login banner - Use Debian as default console - Updated system-cron to v0.5.0 - Updated services to latest versions - Bump up kernel to 4.14.206 - Include burmilla/os-debianconsole:v1.9.0 to initrd
58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
package control
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/burmilla/os/config"
|
|
"github.com/burmilla/os/pkg/compose"
|
|
"github.com/burmilla/os/pkg/log"
|
|
|
|
"github.com/codegangsta/cli"
|
|
"github.com/docker/libcompose/project/options"
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
func switchConsoleAction(c *cli.Context) error {
|
|
if len(c.Args()) != 1 {
|
|
return errors.New("Must specify exactly one existing container")
|
|
}
|
|
newConsole := c.Args()[0]
|
|
|
|
cfg := config.LoadConfig()
|
|
|
|
project, err := compose.GetProject(cfg, true, false)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// stop docker and console to avoid zombie process
|
|
if err = project.Stop(context.Background(), 10, "docker"); err != nil {
|
|
log.Errorf("Failed to stop Docker: %v", err)
|
|
}
|
|
if err = project.Stop(context.Background(), 10, "console"); err != nil {
|
|
log.Errorf("Failed to stop console: %v", err)
|
|
}
|
|
|
|
if newConsole != "default" {
|
|
if err = compose.LoadSpecialService(project, cfg, "console", newConsole); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
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{
|
|
Log: true,
|
|
}, "console"); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err = project.Start(context.Background(), "docker"); err != nil {
|
|
log.Errorf("Failed to start Docker: %v", err)
|
|
}
|
|
|
|
return nil
|
|
}
|