Exemple #1
0
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)
}
Exemple #2
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")
}
Exemple #3
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")
}
Exemple #4
0
	"github.com/LastCallMedia/vagabond/config"
	"github.com/LastCallMedia/vagabond/util"
	"github.com/mitchellh/go-homedir"
	"os/exec"
)

var profileTemplate = `export DOCKER_TZ={{.Tz}}
export VAGABOND_SITES_DIR={{.SitesDir}}
export VAGABOND_DATA_DIR={{.DataDir}}`

var VariablesStep = ConfigStep{
	Name: "environment variables",
	NeedsRun: func(envt *config.Environment) bool {
		profileFilename, err := homedir.Expand("~/.bash_profile")
		if err != nil {
			util.Fatal("Unable to find home directory")
		}
		profile, err := doTemplateAppend(profileTemplate, envt, profileFilename)
		if err != nil {
			return true
		}
		matches, err := checkIfFileMatches(profileFilename, profile)
		if err != nil || !matches {
			return true
		}
		return false
	},
	Run: func(envt *config.Environment) (err error) {
		profileFilename, err := homedir.Expand("~/.bash_profile")
		if err != nil {
			util.Fatal("Unable to find home directory")