aboutsummaryrefslogtreecommitdiff
path: root/common/scripts/virt/checksum.sh
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2025-09-24 05:45:26 +0200
committersrdusr <trevorgray@srdusr.com>2025-09-24 05:45:26 +0200
commitd96a422496fe3a6b80659a720e63c6abc41b7de9 (patch)
tree20f90abb5ce91875a40027333efbb52877902132 /common/scripts/virt/checksum.sh
parent521215add7da7fef6722c7b5adec839b84d72db0 (diff)
parenta1627ac743289e768b138f1a60753a62e0869cc4 (diff)
downloaddotfiles-d96a422496fe3a6b80659a720e63c6abc41b7de9.tar.gz
dotfiles-d96a422496fe3a6b80659a720e63c6abc41b7de9.zip
Add 'common/scripts/' from commit 'a1627ac743289e768b138f1a60753a62e0869cc4'
git-subtree-dir: common/scripts git-subtree-mainline: 521215add7da7fef6722c7b5adec839b84d72db0 git-subtree-split: a1627ac743289e768b138f1a60753a62e0869cc4
Diffstat (limited to 'common/scripts/virt/checksum.sh')
-rwxr-xr-xcommon/scripts/virt/checksum.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/common/scripts/virt/checksum.sh b/common/scripts/virt/checksum.sh
new file mode 100755
index 0000000..adb6a24
--- /dev/null
+++ b/common/scripts/virt/checksum.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+# Check if the correct number of arguments are provided
+if [[ $# -ne 2 ]]; then
+ echo "Usage: checksum <file> <website>"
+ exit 1
+fi
+
+FILE=$1
+CHECKSUM_PAGE=$2
+
+# Fetch the HTML content of the page
+HTML_CONTENT=$(curl -s "$CHECKSUM_PAGE")
+
+# Try searching for checksums with a more targeted approach, like matching a checksum pattern or look for files with checksum labels
+CHECKSUM=$(echo "$HTML_CONTENT" | grep -oP '([a-f0-9]{64})' | head -n 1) # Try specifically looking for SHA256 checksum patterns
+
+# Check if any checksum was found
+if [[ -z "$CHECKSUM" ]]; then
+ echo "Checksum not found on the page."
+ exit 1
+fi
+
+# Calculate the checksum of the file locally
+LOCAL_CHECKSUM=$(sha256sum "$FILE" | awk '{print $1}')
+
+echo "Local checksum: $LOCAL_CHECKSUM"
+echo "Remote checksum: $CHECKSUM"
+
+# Compare the local checksum with the one from the website
+if [[ "$LOCAL_CHECKSUM" == "$CHECKSUM" ]]; then
+ echo "The checksums match! The file is verified."
+
+else
+ echo "The checksums do not match. The file may be corrupted or tampered with."
+fi