base-image-build/scripts/setupBuilder/downloadGenericCloudDisk.sh
2024-08-11 09:09:04 +00:00

32 lines
1.3 KiB
Bash

#!/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"
checksumFileName="$VM_DISK_FILE_TO_DOWNLOAD.CHECKSUM"
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 ---"
curl $vmDiskFileChecksumURL -o $OUTPUT_DIR$checksumFileName
echo "--- Checking checksum ---"
expectedChecksum=$(cat $OUTPUT_DIR/$checksumFileName | awk 'NR==2 {print $4}')
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