Adds creating a checksum file and verifying the download with it to the

bash script. Right now it removes the file if it doesn't match the
checksum, but should probably do something like rename it or just output
that it doesn't pass.
This commit is contained in:
Kevin Ruffin 2022-02-19 22:20:35 -05:00
parent b2a34ab235
commit 994883c588

View File

@ -282,9 +282,13 @@ func writeBashScript(dl *DownloadLinks, folder string, scriptName string, produc
dl.Filename = sanitizeName(pp[len(pp) - 1]) dl.Filename = sanitizeName(pp[len(pp) - 1])
// Add the lines to the script // Add the lines to the script
path := folder + "/" + sanitizeName(dl.InstallerName) + "/" + sanitizeName(dl.Os) + "/" + sanitizeName(dl.Language) + "/"
file := path + dl.Filename
line := "echo \"[" + strconv.Itoa(productNumber) + " of " + strconv.Itoa(totalProducts) + "]{" + strconv.Itoa(fileNumber) + "/" + strconv.Itoa(totalFiles) + "}Getting installers for (" + dl.InstallerName + ")" + "\"\n" line := "echo \"[" + strconv.Itoa(productNumber) + " of " + strconv.Itoa(totalProducts) + "]{" + strconv.Itoa(fileNumber) + "/" + strconv.Itoa(totalFiles) + "}Getting installers for (" + dl.InstallerName + ")" + "\"\n"
line += "wget --no-clobber --continue --quiet --show-progress -O \"" + folder + "/" + sanitizeName(dl.InstallerName) + "/" + sanitizeName(dl.Os) + "/" + sanitizeName(dl.Language) + "/" + dl.Filename + ".xml\" \"" + dl.Checksum + "\"\n" line += "wget --no-clobber --continue --quiet --show-progress -O \"" + file + ".xml\" \"" + dl.Checksum + "\"\n"
line += "wget --no-clobber --continue --quiet --show-progress -O \"" + folder + "/" + sanitizeName(dl.InstallerName) + "/" + sanitizeName(dl.Os) + "/" + sanitizeName(dl.Language) + "/" + dl.Filename + "\" \"" + dl.Downlink + "\"\n" line += "wget --no-clobber --continue --quiet --show-progress -O \"" + file + "\" \"" + dl.Downlink + "\"\n"
line += "[ ! -f \"" + file + ".md5\" ] && cat \"" + file + ".xml\" | tr '\\n' '\\r' | sed -E 's|<file name=\"([^\"]+)\".*md5=\"([^\"]+).*|\\2 " + file + "\\n|' > " + file + ".md5\n"
line += "! md5sum -c \"" + file + ".md5\" && rm \"" + file + "\" && echo \"Removed unmatched file: " + file + "\"\n"
f, err := os.OpenFile("./" + scriptName, os.O_APPEND|os.O_WRONLY, 0664) f, err := os.OpenFile("./" + scriptName, os.O_APPEND|os.O_WRONLY, 0664)
if err != nil { if err != nil {