Пример #1
0
func initializeHaveBundle() (ret []mig.BundleDictionaryEntry, err error) {
	defer func() {
		if e := recover(); e != nil {
			err = fmt.Errorf("initializeHaveBundle() -> %v", e)
		}
	}()

	ret, err = mig.GetHostBundle()
	if err != nil {
		panic(err)
	}
	ret, err = mig.HashBundle(ret)
	if err != nil {
		panic(err)
	}
	logInfo("initialized local bundle information")
	for _, x := range ret {
		hv := x.SHA256
		if hv == "" {
			hv = "not found"
		}
		logInfo("%v %v -> %v", x.Name, x.Path, hv)
	}
	return
}
Пример #2
0
// Terminate any running agent on the system.
func terminateAgent() (err error) {
	defer func() {
		if e := recover(); e != nil {
			err = fmt.Errorf("terminateAgent() -> %v", e)
		}
	}()
	hb, err := mig.GetHostBundle()
	if err != nil {
		panic(err)
	}
	var abe mig.BundleDictionaryEntry
	found := false
	for _, x := range hb {
		if x.Name == "mig-agent" {
			abe = x
			found = true
			break
		}
	}
	if !found {
		panic("no agent entry in host bundle")
	}

	migcomm := exec.Command(abe.Path, "-q", "shutdown")
	err = migcomm.Run()
	if err != nil {
		panic(err)
	}

	return
}