Ejemplo n.º 1
0
func init() {
	if err := rconfig.Parse(&config); err != nil {
		log.Printf("Unable to parse CLI parameters: %s\n", err)
		os.Exit(1)
	}

	if len(config.SealTokens) == 1 && config.SealTokens[0] == "" {
		if len(rconfig.Args()) <= 1 {
			log.Println("You must provide at least one token.")
			os.Exit(1)
		}
		config.SealTokens = rconfig.Args()[1:]
	}
}
Ejemplo n.º 2
0
func main() {
	body, err := ioutil.ReadFile(cfg.EnvFile)
	if err != nil {
		log.Fatalf("Could not read env-file: %s", err)
	}

	var childenv map[string]string
	if cfg.CleanEnv {
		childenv = map[string]string{}
	} else {
		childenv = envListToMap(os.Environ())
	}

	pairs := envListToMap(strings.Split(string(body), "\n"))
	for k, v := range pairs {
		childenv[k] = v
	}

	c := exec.Command(rconfig.Args()[1], rconfig.Args()[2:]...)
	c.Env = envMapToList(childenv)
	c.Stdout = os.Stdout
	c.Stderr = os.Stderr
	c.Stdin = os.Stdin

	err = c.Run()

	switch err.(type) {
	case nil:
		infoLog("Process exitted with code 0")
		os.Exit(0)
	case *exec.ExitError:
		infoLog("Unclean exit with exit-code != 0")
		os.Exit(1)
	default:
		log.Printf("An unknown error ocurred: %s", err)
		os.Exit(2)
	}
}