示例#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
}