1
0
mirror of https://github.com/rancher/os.git synced 2025-04-29 03:44:28 +00:00
os/pkg/init/bootstrap/bootstrap.go
2018-09-19 17:18:49 +08:00

40 lines
954 B
Go

package bootstrap
import (
"github.com/rancher/os/config"
"github.com/rancher/os/pkg/compose"
"github.com/rancher/os/pkg/init/docker"
"github.com/rancher/os/pkg/log"
"github.com/rancher/os/pkg/sysinit"
"github.com/rancher/os/pkg/util"
)
func bootstrapServices(cfg *config.CloudConfig) (*config.CloudConfig, error) {
if util.ResolveDevice(cfg.Rancher.State.Dev) != "" && len(cfg.Bootcmd) == 0 {
log.Info("NOT Running Bootstrap")
return cfg, nil
}
log.Info("Running Bootstrap")
_, err := compose.RunServiceSet("bootstrap", cfg, cfg.Rancher.BootstrapContainers)
return cfg, err
}
func Bootstrap(cfg *config.CloudConfig) error {
log.Info("Launching Bootstrap Docker")
c, err := docker.Start(cfg)
if err != nil {
return err
}
defer docker.Stop(c)
_, err = config.ChainCfgFuncs(cfg,
[]config.CfgFuncData{
{"bootstrap loadImages", sysinit.LoadBootstrapImages},
{"bootstrap Services", bootstrapServices},
})
return err
}