func Initialize(do *definitions.Do) error { logger.Printf("The marmots have connected to Docker successfully.\nThey will now will install a few default services and actions for your use.\n\n") if _, err := os.Stat(common.ErisRoot); os.IsNotExist(err) { logger.Printf("Eris Root Directory does not exist. The marmots will initialize this directory for you.\n") if err := common.InitErisDir(); err != nil { return fmt.Errorf("Error:\tcould not Initialize the Eris Root Directory.\n%s\n", err) } } else if do.Yes { logger.Debugf("Not requiring input. Proceeding.\n") } else { var input string logger.Printf("Eris Root Directory (%s) already exists.\nContinuing may overwrite files in:\n%s\n%s\nDo you wish to continue? (Y/n): ", common.ErisRoot, common.ServicesPath, common.ActionsPath) fmt.Scanln(&input) if input == "Y" || input == "y" || input == "YES" || input == "Yes" || input == "yes" { logger.Debugf("Confirmation verified. Proceeding.\n") } else { logger.Printf("\nThe marmots will not proceed without your permission to overwrite.\nPlease backup your files and try again.\n") return fmt.Errorf("Error:\tno permission given to overwrite services and actions.\n") } } //goes and does everything if err := InitDefaultServices(do); err != nil { return fmt.Errorf("Error:\tcould not Instantiate default services.\n%s\n", err) } return nil }
func Initialize(skipPull, verbose bool) error { // todo: remove the verbose here logger.Printf("The marmots have connected to Docker successfully.\nThey will now will install a few default services and actions for your use.\n\n") if _, err := os.Stat(common.ErisRoot); err != nil { if err := common.InitErisDir(); err != nil { return fmt.Errorf("Could not Initialize the Eris Root Directory.\n%s\n", err) } } else { logger.Infof("Root eris directory (%s) already exists. Please type `eris` to see the help.\n", common.ErisRoot) } // XXX: [csk] The below is redunant. DockerConnect() is a PersistentPreRun // command and if it cannot connect to the "default" or "eris" docker-machines // then it will call CheckDockerClient() to perform the functionality // envisioned by the below. Going to leave this in case we want to change // that functionality in the future. // logger.Debugf("Checking connection to Docker....\n") // if err := util.CheckDockerClient(); err != nil { // return err // } // logger.Infof("Docker Connection OK.\n") if err := InitDefaultServices(skipPull); err != nil { return fmt.Errorf("Could not instantiate default services.\n%s\n", err) } logger.Infof("Initialized eris root directory (%s) with default actions and service files.\n", common.ErisRoot) // todo: when called from cli provide option to go on tour, like `ipfs tour` logger.Printf("\nThe marmots have everything set up for you.\nIf you are just getting started please type [eris] to get an overview of the tool.\n") return nil }
func checkThenInitErisRoot(force bool) (bool, error) { var newDir bool if force { //for testing only log.Warn("Force initializing eris root directory") if err := common.InitErisDir(); err != nil { return true, fmt.Errorf("Error:\tcould not initialize the eris root directory.\n%s\n", err) } return true, nil } if !util.DoesDirExist(common.ErisRoot) { log.Warn("Eris root directory does not exist. The marmots will initialize this directory for you") if err := common.InitErisDir(); err != nil { return true, fmt.Errorf("Error:\tcould not initialize the eris root directory.\n%s\n", err) } newDir = true } else { // ErisRoot exists, prompt for overwrite newDir = false } return newDir, nil }
func Initialize(do *definitions.Do) error { if _, err := os.Stat(common.ErisRoot); err != nil { if os.IsNotExist(err) { logger.Infoln("Eris Root Directory does not exist. The marmots will initialize this directory for you.\n") if err := common.InitErisDir(); err != nil { return fmt.Errorf("Error:\tcould not Initialize the Eris Root Directory.\n%s\n", err) } } else { panic(err) } } if do.Yes { logger.Debugf("Not requiring input. Proceeding.\n") } else { var input string logger.Printf("Eris Root Directory (%s) already exists.\nContinuing may overwrite files in:\n%s\n%s\nDo you wish to continue? (y/n): ", common.ErisRoot, common.ServicesPath, common.ActionsPath) if _, err := fmt.Scanln(&input); err != nil { return fmt.Errorf("Error reading from stdin: %v\n", err) } if input == "Y" || input == "y" || input == "YES" || input == "Yes" || input == "yes" { logger.Debugf("Confirmation verified. Proceeding.\n") } else { logger.Printf("\nThe marmots will not proceed without your permission to overwrite.\nPlease backup your files and try again.\n") return fmt.Errorf("Error:\tno permission given to overwrite services and actions.\n") } } //goes and does everything if err := InitDefaultServices(do); err != nil { return fmt.Errorf("Error:\tcould not Instantiate default services.\n%s\n", err) } var prompt bool if do.Yes || os.Getenv("ERIS_MIGRATE_APPROVE") == "true" { prompt = false } else { prompt = true } if err := util.MigrateDeprecatedDirs(common.DirsToMigrate, prompt); err != nil { return fmt.Errorf("Error:\tcould not migrate directories.\n%s\n", err) } return nil }
func Initialize(skipPull, verbose bool) error { if _, err := os.Stat(common.ErisRoot); err != nil { if err := common.InitErisDir(); err != nil { return fmt.Errorf("Could not Initialize the Eris Root Directory.\n%s\n", err) } } else { if verbose { fmt.Printf("Root eris directory (%s) already exists. Please type `eris` to see the help.\n", common.ErisRoot) } } if err := util.CheckDockerClient(); err != nil { return err } if err := InitDefaultServices(skipPull, verbose); err != nil { return fmt.Errorf("Could not instantiate default services.\n%s\n", err) } if verbose { fmt.Printf("Initialized eris root directory (%s) with default actions and service files.\n", common.ErisRoot) } // lets not pull any by default. this will spread out the get started pain // if skipPull { // //pull images // argsAll := []string{} // argsDef := []string{"eris/keys", "eris/ipfs", "eris/erisdb", "eris/data"} // argsDev := []string{ // "erisindustries/evm_compilers", // "eris/compilers", // "erisindustries/node", // "erisindustries/python", // "erisindustries/gulp", // "erisindustries/embark_base", // "erisindustries/sunit_base", // "erisindustries/pyepm_base", // } // fmt.Println("Pulling base images...") // if !dev { // argsAll = argsDef // } else { // fmt.Println("...and development images") // argsAll = append(argsDef, argsDev...) // } // fmt.Println("This could take awhile, now is a good time to feed your marmot") // for _, img := range argsAll { // srv := definitions.BlankService() // srv.Image = img // ops := definitions.BlankOperation() // err := perform.DockerPull(srv, ops) // if err != nil { // fmt.Println("An error occured pulling the images: ", err) // return err // } // } // } // todo: when called from cli provide option to go on tour, like `ipfs tour` fmt.Printf("The marmots have everything set up for you.\n") return nil }
and simple to wrangle the dragons of smart contract blockchains. Made with <3 by Eris Industries. Complete documentation is available at https://docs.erisindustries.com ` + "\nVersion:\n " + VERSION, PersistentPreRun: func(cmd *cobra.Command, args []string) { var logLevel log.LogLevel if do.Verbose { logLevel = 2 } else if do.Debug { logLevel = 3 } log.SetLoggers(logLevel, config.GlobalConfig.Writer, config.GlobalConfig.ErrorWriter) common.InitErisDir() util.DockerConnect(do.Verbose, do.MachineName) do.ChainName, _ = util.GetHead() }, PersistentPostRun: func(cmd *cobra.Command, args []string) { err := config.SaveGlobalConfig(config.GlobalConfig.Config) if err != nil { logger.Errorln(err) } log.Flush() }, } func Execute() { InitializeConfig() AddGlobalFlags()