Beispiel #1
0
func InsureNewVersionFiles(da *model.DesiredAgent) error {
	if FilesReady(da) {
		return nil
	}
	content, err := ioutil.ReadFile("./password")
	password := strings.Trim(string(content), "\n")
	if err != nil {
		panic(err)
	}
	downloadTarballCmd := exec.Command("wget", "--no-check-certificate", "--auth-no-challenge", "--user=owl", "--password="******"-O", da.TarballFilename)
	downloadTarballCmd.Dir = da.AgentVersionDir
	err = downloadTarballCmd.Run()
	if err != nil {
		log.Println("wget -q --no-check-certificate --auth-no-challenge --user=owl --password="******"-O", da.TarballFilename, "fail", err)
		return err
	}

	downloadMd5Cmd := exec.Command("wget", "--no-check-certificate", "--auth-no-challenge", "--user=owl", "--password="******"-O", da.Md5Filename)
	downloadMd5Cmd.Dir = da.AgentVersionDir
	err = downloadMd5Cmd.Run()
	if err != nil {
		log.Println("wget -q --no-check-certificate --auth-no-challenge --user=owl --password="******"-O", da.Md5Filename, "fail", err)
		return err
	}

	if utils.Md5sumCheck(da.AgentVersionDir, da.Md5Filename) {
		return nil
	} else {
		return fmt.Errorf("md5sum -c fail")
	}
}
Beispiel #2
0
func FilesReady(da *model.DesiredAgent) bool {
	if !file.IsExist(da.Md5Filepath) {
		return false
	}

	if !file.IsExist(da.TarballFilepath) {
		return false
	}

	if !file.IsExist(da.ControlFilepath) {
		return false
	}

	return utils.Md5sumCheck(da.AgentVersionDir, da.Md5Filename)
}