Ejemplo n.º 1
0
func runSetup(ctx *cli.Context) {
	var err error

	env := config.NewEnvironment()
	force := ctx.Bool("force")

	env.Tz = prompter.Prompt("Timezone", env.Tz)
	env.SitesDir, err = promptForDir("Sites directory", env.SitesDir)
	if err != nil {
		util.Fatal(err)
	}
	env.DataDir, err = promptForDir("Database storage directory", env.DataDir)
	if err != nil {
		util.Fatal(err)
	}

	err = env.Check()
	if err != nil {
		util.Fatal(err)
	}

	acts := []step.ConfigStep{
		step.VariablesStep,
	}

	if env.RequiresMachine() {
		acts = append(acts, step.MachineStep)
		acts = append(acts, step.NfsServerStep)
		acts = append(acts, step.NfsClientStep)
	}
	acts = append(acts, step.ServicesStep)
	acts = append(acts, step.NewDnsAction())

	for _, act := range acts {
		needs := act.NeedsRun(env)
		if needs || force {
			util.Successf("Running %s", act.GetName())
			err := act.Run(env)
			if err != nil {
				util.Fatal(err)
			}
		} else {
			util.Successf("Skipping %s", act.GetName())
		}
	}

	util.Success("Setup complete")
}
Ejemplo n.º 2
0
func runDiagnose(ctx *cli.Context) {
	fmt.Println("Running diagnostics...")

	env := config.NewEnvironment()
	if err := env.Check(); err != nil {
		util.Fatal(err)
	}
	if err := checkInstall(env); err != nil {
		util.Fatal(err)
	}
	if err := checkConnection(env); err != nil {
		util.Fatal(err)
	}
	if err := checkContainers(env); err != nil {
		util.Fatal(err)
	}
	if err := checkDns(env); err != nil {
		util.Fatal(err)
	}

	util.Success("OK - No issues found")
}
Ejemplo n.º 3
0
// Proxies a docker-compose ps command.
var CmdStatus = cli.Command{
	Name:    "status",
	Aliases: []string{"ps"},
	Usage:   "View the status of running containers",
	Action: func(ctx *cli.Context) {
		runAndNotifyCommand("docker-compose", append([]string{"ps"}, ctx.Args()...)...)
	},
}

// Proxies a docker-machine ip command.
var CmdIp = cli.Command{
	Name:  "ip",
	Usage: "View the IP Address of the docker machine",
	Action: func(ctx *cli.Context) {
		env := config.NewEnvironment()
		runAndNotifyCommand("docker-machine", "ip", env.MachineName)
	},
}

// Emulates vagrant ssh with docker exec
var CmdSsh = cli.Command{
	Name:    "ssh",
	Aliases: []string{"exec"},
	Usage:   "Shell into a running docker container",
	Action: func(ctx *cli.Context) {
		numArgs := len(ctx.Args())
		if numArgs > 1 {
			notifyError("You may only specify a single container")
			os.Exit(1)
		}
Ejemplo n.º 4
0
	"fmt"
	"github.com/LastCallMedia/vagabond/config"
	"github.com/LastCallMedia/vagabond/util"
)

var MachineStep = ConfigStep{
	Name: "docker machine",
	NeedsRun: func(envt *config.Environment) bool {
		machine := envt.GetMachine()
		return !(machine.IsCreated() && machine.IsBooted())
	},
	Run: func(envt *config.Environment) (err error) {
		machine := envt.GetMachine()
		if !machine.IsCreated() {
			err = machine.Create().Run()
			if err != nil {
				return
			}
		}
		if !machine.IsBooted() {
			err = machine.Boot().Run()
			fmt.Printf(util.FgYellow+"Run the following command once the setup is complete:\n\teval $(docker-machine env %s)\n"+util.Reset, envt.MachineName)
		}
		newEvt := config.NewEnvironment()
		// Copy over the IPs after the machine boots.
		envt.DockerDaemonIp = newEvt.DockerDaemonIp
		envt.DockerClientIp = newEvt.DockerClientIp
		return
	},
}