Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions baremetal_vm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ Variables can be stored in the script basedir as `.env` or in any file and use t
* `DISKSIZE` specifies the disk size to configure for the VM
* `IMG_TO_USE` specifies an image to locally cache and use for provisioning
* One option is `https://download.opensuse.org/pub/opensuse/distribution/leap/15.4/appliances/openSUSE-Leap-15.4-Minimal-VM.x86_64-OpenStack-Cloud.qcow2`
* `IMG_TO_USE_CHECKSUM` specifies the expected sha256 checksum for IMG_TO_USE

NOTE: Also see the [env.example](env.example) file for an example config with all options.

Expand Down
8 changes: 8 additions & 0 deletions baremetal_vm/create_vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ source ../slemicro/common.sh
source common.sh

IMG_TO_USE=${IMG_TO_USE:-}
IMG_TO_USE_CHECKSUM=${IMG_TO_USE_CHECKSUM:-}

while getopts 'f:n:h' OPTION; do
case "${OPTION}" in
Expand Down Expand Up @@ -80,6 +81,13 @@ mkdir -p bmh-image-cache
IMG_FILENAME=$(basename ${IMG_TO_USE})
if [ ! -f bmh-image-cache/${IMG_FILENAME} ]; then
curl -Lk ${IMG_TO_USE} > bmh-image-cache/${IMG_FILENAME}

# Require checksum validation to ensure image integrity
CHECKSUM_ACTUAL=$(sha256sum "bmh-image-cache/${IMG_FILENAME}" | awk '{print $1}')
if [ "${IMG_TO_USE_CHECKSUM}" != "${CHECKSUM_ACTUAL}" ]; then
die "download sha256 does not match ${IMG_TO_USE_CHECKSUM}, got ${CHECKSUM_ACTUAL}"
fi

pushd bmh-image-cache
md5sum ${IMG_FILENAME} | tee ${IMG_FILENAME}.md5sum
popd
Expand Down
Loading