bootc-base-image-build-mirror/scripts/setupBuilder/downloadGenericCloudDisk.sh

32 lines
1.3 KiB
Bash
Raw Normal View History

2024-08-11 09:09:04 +00:00
#!/bin/bash
set -e
# Latest one can be found at https://dl.rockylinux.org/pub/rocky/9.4/images/x86_64/
# It is marked as https://dl.rockylinux.org/pub/rocky/9.4/images/x86_64/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2
# The specific deployment it corresponds to can be found by searching for the file size (number on the right) in the page
if [ ! -f $BASE_DISK_FILEPATH ]; then
vmDiskFileURL="https://dl.rockylinux.org/pub/rocky/$ROCKY_VERSION/images/x86_64/$VM_DISK_FILE_TO_DOWNLOAD"
2024-08-23 21:04:19 +00:00
checksumFile="$BASE_DISK_FILEPATH.CHECKSUM"
2024-08-11 09:09:04 +00:00
vmDiskFileChecksumURL="https://dl.rockylinux.org/pub/rocky/$ROCKY_VERSION/images/x86_64/$checksumFileName"
echo "--- Downloading $vmDiskFileURL ---"
curl $vmDiskFileURL -o $BASE_DISK_FILEPATH
echo "--- Downloading $vmDiskFileChecksumURL ---"
2024-08-23 21:04:19 +00:00
curl $vmDiskFileChecksumURL -o $checksumFile
2024-08-11 09:09:04 +00:00
echo "--- Checking checksum ---"
2024-08-23 21:04:19 +00:00
expectedChecksum=$(cat $checksumFile | awk 'NR==2 {print $4}')
2024-08-11 09:09:04 +00:00
if [ $(sha256sum $BASE_DISK_FILEPATH | awk '{print $1}') == "$expectedChecksum" ]; then
echo "--- CHECKSUM CONFIRMED ---"
else
echo "--- CHECKSUM DOES NOT MATCH! ---"
rm $BASE_DISK_FILEPATH
exit 1
fi
echo "--- Finished checking checksum ---"
else
echo "--- Using cached base file $BASE_DISK_FILEPATH ---"
fi