humble-homelab/scripts/verify-download.sh
2024-01-18 21:29:44 +01:00

32 lines
805 B
Bash
Executable file

#!/bin/env bash
set -e
# Helper script to download binaries and check signatures and checksums.
# It assumes a very rigid file structure
# Example
# URL="https://codeberg.org/forgejo/forgejo/releases/download/v1.20.6-1/forgejo-1.20.6-1-linux-amd64"
URL=$1
if [ -z "$1" ]
then
echo "No argument supplied. Please provide a download URL."
exit 1
fi
FILENAME=$(echo $URL | grep --only-matching --extended-regexp "([^\/]+$)")
DIR="/tmp/verify-binaries"
mkdir -p $DIR
wget -nv --timestamping --directory-prefix $DIR $URL
wget -nv --timestamping --directory-prefix $DIR "$URL.asc"
wget -nv --timestamping --directory-prefix $DIR "$URL.sha256"
(cd $DIR && gpg --verify "$FILENAME.asc" $FILENAME)
(cd $DIR && cat "$FILENAME.sha256")
(cd $DIR && sha256sum --check "$FILENAME.sha256")