Esempio n. 1
0
func handleDaemon(ctx *cli.Context) error {
	pwd := ctx.GlobalString("password")
	if pwd == "" {
		var err error
		pwd, err = readPassword()
		if err != nil {
			return ExitCode{
				BadPassword,
				fmt.Sprintf("Could not read password: %v", pwd),
			}
		}
	}

	repoFolder := guessRepoFolder()
	err := repo.CheckPassword(repoFolder, pwd)
	if err != nil {
		return ExitCode{
			BadPassword,
			"Wrong password",
		}
	}

	port := guessPort()
	baal, err := daemon.Summon(pwd, repoFolder, port)
	if err != nil {
		return ExitCode{
			UnknownError,
			fmt.Sprintf("Unable to start daemon: %v", err),
		}
	}

	baal.Serve()
	return nil
}
Esempio n. 2
0
func readPassword() (string, error) {
	repoFolder := guessRepoFolder()
	pwd, err := pwdutil.PromptPasswordMaxTries(4, func(pwd string) bool {
		err := repo.CheckPassword(repoFolder, pwd)
		return err == nil
	})

	return pwd, err
}