コード例 #1
0
ファイル: setup.go プロジェクト: LastCallMedia/vagabond
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")
}
コード例 #2
0
ファイル: selfupdate.go プロジェクト: LastCallMedia/vagabond
func runSelfUpdate(ctx *cli.Context) {
	version := "latest"
	if len(ctx.Args()) > 0 {
		version = ctx.Args()[0]
	}
	release, err := getRelease(version)
	if err != nil {
		util.Fatal("Unable to fetch release data")
	}
	filename := "vagabond_" + runtime.GOOS + "_" + runtime.GOARCH
	asset, found := assetSearch(release.Assets, filename)
	if !found {
		util.Fatal("Unable to find a release asset for this OS and architecture.  Expected to find " + filename)
	}
	srcfile, err := fetchAsset(asset)
	if err != nil {
		util.Fatalf("Failed fetching file: %s", err)
	}
	dstFile, err := osext.Executable()
	if err != nil {
		util.Fatalf("Failed determining current binary: %s", err)
	}
	err = copyFileOver(srcfile, dstFile)
	if err != nil {
		util.Fatalf("Failed replacing current binary.")
	}
	util.Successf("Updated to %s (%s)", *release.TagName, dstFile)
}