func RunInit() error { var cfg config.CloudConfig os.Setenv("PATH", "/sbin:/usr/sbin:/usr/bin") // Magic setting to tell Docker to do switch_root and not pivot_root os.Setenv("DOCKER_RAMDISK", "true") initFuncs := []config.InitFunc{ func(cfg *config.CloudConfig) error { return dockerlaunch.PrepareFs(&mountConfig) }, func(cfg *config.CloudConfig) error { newCfg, err := config.LoadConfig() if err == nil { newCfg, err = config.LoadConfig() } if err == nil { *cfg = *newCfg } if cfg.Rancher.Debug { cfgString, err := config.Dump(false, true) if err != nil { log.WithFields(log.Fields{"err": err}).Error("Error serializing config") } else { log.Debugf("Config: %s", cfgString) } } return err }, loadModules, tryMountAndBootstrap, func(cfg *config.CloudConfig) error { return cfg.Reload() }, loadModules, sysInit, } if err := config.RunInitFuncs(&cfg, initFuncs); err != nil { return err } launchConfig, args := getLaunchConfig(&cfg, &cfg.Rancher.SystemDocker) log.Info("Launching System Docker") _, err := dockerlaunch.LaunchDocker(launchConfig, config.DOCKER_BIN, args...) return err }
func export(c *cli.Context) { content, err := config.Dump(c.Bool("private"), c.Bool("full")) if err != nil { log.Fatal(err) } output := c.String("output") if output == "" { fmt.Println(content) } else { err := ioutil.WriteFile(output, []byte(content), 0400) if err != nil { log.Fatal(err) } } }
func RunInit() error { var cfg config.Config os.Setenv("PATH", "/sbin:/usr/sbin:/usr/bin") os.Setenv("DOCKER_RAMDISK", "true") initFuncs := []config.InitFunc{ func(cfg *config.Config) error { return createDirs(dirs...) }, func(cfg *config.Config) error { log.Info("Setting up mounts") return createMounts(mounts...) }, func(cfg *config.Config) error { newCfg, err := config.LoadConfig() if err == nil { newCfg, err = config.LoadConfig() } if err == nil { *cfg = *newCfg } if cfg.Debug { cfgString, _ := config.Dump(false, true) if cfgString != "" { log.Debugf("Config: %s", cfgString) } } return err }, mountCgroups, func(cfg *config.Config) error { return createSymlinks(cfg, symlinks) }, createGroups, extractModules, loadModules, setResolvConf, setupSystemBridge, bootstrap, mountState, func(cfg *config.Config) error { return cfg.Reload() }, loadModules, setResolvConf, func(cfg *config.Config) error { return createDirs(postDirs...) }, func(cfg *config.Config) error { return createMounts(postMounts...) }, touchSocket, // Disable R/O root write now to support updating modules //remountRo, sysInit, } if err := config.RunInitFuncs(&cfg, initFuncs); err != nil { return err } return execDocker(&cfg) }