bootstrap.go 954 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package bootstrap
  2. import (
  3. "github.com/rancher/os/config"
  4. "github.com/rancher/os/pkg/compose"
  5. "github.com/rancher/os/pkg/init/docker"
  6. "github.com/rancher/os/pkg/log"
  7. "github.com/rancher/os/pkg/sysinit"
  8. "github.com/rancher/os/pkg/util"
  9. )
  10. func bootstrapServices(cfg *config.CloudConfig) (*config.CloudConfig, error) {
  11. if util.ResolveDevice(cfg.Rancher.State.Dev) != "" && len(cfg.Bootcmd) == 0 {
  12. log.Info("NOT Running Bootstrap")
  13. return cfg, nil
  14. }
  15. log.Info("Running Bootstrap")
  16. _, err := compose.RunServiceSet("bootstrap", cfg, cfg.Rancher.BootstrapContainers)
  17. return cfg, err
  18. }
  19. func Bootstrap(cfg *config.CloudConfig) error {
  20. log.Info("Launching Bootstrap Docker")
  21. c, err := docker.Start(cfg)
  22. if err != nil {
  23. return err
  24. }
  25. defer docker.Stop(c)
  26. _, err = config.ChainCfgFuncs(cfg,
  27. []config.CfgFuncData{
  28. {"bootstrap loadImages", sysinit.LoadBootstrapImages},
  29. {"bootstrap Services", bootstrapServices},
  30. })
  31. return err
  32. }