mirror of
https://gitlab.com/monolithify/base-image-build.git
synced 2024-11-22 14:51:22 +00:00
32 lines
1.3 KiB
Bash
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"
|
|
vmDiskFileChecksumURL="https://dl.rockylinux.org/pub/rocky/$ROCKY_VERSION/images/x86_64/$VM_DISK_FILE_TO_DOWNLOAD.CHECKSUM"
|
|
checksumFile="$BASE_DISK_FILEPATH.CHECKSUM"
|
|
|
|
echo "--- Downloading $vmDiskFileURL ---"
|
|
curl $vmDiskFileURL -o $BASE_DISK_FILEPATH
|
|
echo "--- Downloading $vmDiskFileChecksumURL ---"
|
|
curl $vmDiskFileChecksumURL -o $checksumFile
|
|
|
|
echo "--- Checking checksum ---"
|
|
expectedChecksum=$(cat $checksumFile | 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
|