From 994883c588f5054cc3bcc49aca213b4b9814a1fd Mon Sep 17 00:00:00 2001 From: Kevin Ruffin Date: Sat, 19 Feb 2022 22:20:35 -0500 Subject: [PATCH] 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. --- main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index a8ade4b..66a76fc 100644 --- a/main.go +++ b/main.go @@ -282,9 +282,13 @@ func writeBashScript(dl *DownloadLinks, folder string, scriptName string, produc dl.Filename = sanitizeName(pp[len(pp) - 1]) // 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 += "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 \"" + 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 + ".xml\" \"" + dl.Checksum + "\"\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 + ".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) if err != nil {