Пример #1
0
func (pe *ProtoEngine) prepare(c *cli.Context) error {
	pe.accdHost = c.GlobalString("acchost")
	pe.accdPort = c.GlobalString("accport")
	pe.homedir = c.GlobalString("homedir")

	// create the necessary directories if they don't already exist
	err := util.CreateDirs(c.GlobalString("homedir"), c.GlobalString("logdir"))
	if err != nil {
		return err
	}

	// initialize logging framework
	err = log.Init(c.GlobalString("loglevel"), "proto",
		c.GlobalString("logdir"), c.GlobalBool("logconsole"))
	if err != nil {
		return err
	}

	// initialize file descriptors
	pe.fileTable, err = descriptors.NewTable(c)
	if err != nil {
		return err
	}

	// configure
	if err := def.InitMuteFromFile(pe.homedir); err != nil {
		return err
	}

	return nil
}
Пример #2
0
func (ce *CryptEngine) prepare(c *cli.Context, openKeyDB bool) error {
	if !ce.prepared {
		ce.keydHost = c.GlobalString("keyhost")
		ce.keydPort = c.GlobalString("keyport")
		ce.homedir = c.GlobalString("homedir")

		// create the necessary directories if they don't already exist
		err := util.CreateDirs(c.GlobalString("homedir"), c.GlobalString("logdir"))
		if err != nil {
			return err
		}

		// initialize logging framework
		err = log.Init(c.GlobalString("loglevel"), "crypt",
			c.GlobalString("logdir"), c.GlobalBool("logconsole"))
		if err != nil {
			return err
		}

		// initialize file descriptors
		ce.fileTable, err = descriptors.NewTable(c)
		if err != nil {
			return err
		}

		// configure
		if !c.GlobalBool("keyserver") {
			if err := def.InitMuteFromFile(ce.homedir); err != nil {
				return err
			}
		}

		ce.prepared = true
	}

	// open KeyDB, if necessary
	if openKeyDB {
		if ce.keyDB == nil && !c.GlobalBool("keyserver") {
			if err := ce.openKeyDB(); err != nil {
				return err
			}
		}
	}

	return nil
}
Пример #3
0
func (ce *CtrlEngine) prepare(
	c *cli.Context,
	openMsgDB, checkUpdates bool,
) error {
	if !ce.prepared {
		// create the necessary directories if they don't already exist
		err := util.CreateDirs(c.GlobalString("homedir"), c.GlobalString("logdir"))
		if err != nil {
			return err
		}

		// initialize logging framework
		err = log.Init(c.GlobalString("loglevel"), "ctrl ",
			c.GlobalString("logdir"), c.GlobalBool("logconsole"))
		if err != nil {
			return err
		}

		// initialize file descriptors
		ce.fileTable, err = descriptors.NewTable(c)
		if err != nil {
			return err
		}

		ce.prepared = true
	}

	log.Infof("prepare(openMsgDB=%s)", strconv.FormatBool(openMsgDB))

	// open MsgDB, if necessary
	if openMsgDB {
		homedir := c.GlobalString("homedir")
		offline := c.GlobalBool("offline")

		// open messsage DB, if necessary
		if ce.msgDB == nil {
			err := ce.openMsgDB(homedir)
			if err != nil {
				return err
			}
		}

		// get config
		if err := ce.getConfig(homedir, offline); err != nil {
			return err
		}

		// check for updates, if necessary
		if checkUpdates {
			if err := ce.checkUpdates(); err != nil {
				return err
			}
		}

		// start wallet
		var err error
		ce.client, err = startWallet(ce.msgDB, offline)
		if err != nil {
			return err
		}
	}

	return nil
}