#!/bin/bash set -e export scriptLocation="$(dirname "$0")/" export utilsLocation="$scriptLocation/../utils" source $utilsLocation/onStart.sh source $utilsLocation/getLatestRockyDiskPath.sh currentDir=$(pwd) tempDiskVM="$currentDir/debug.qcow2" if [ -n "$1" ]; then tempDiskVM="$1" else if [ ! -f $tempDiskVM ]; then echo "Copying $latestRockyDiskPath into $tempDiskVM" cp $latestRockyDiskPath $tempDiskVM else echo "!!! Using cached $tempDiskVM - already exists !!!" echo "!!! If you want to copy the latest file from /rockyDisks/ delete $tempDiskVM" fi fi imagePath=$tempDiskVM echo "--- Current dir: $currentDir ---" echo "--- Using image: $imagePath ---" echo "--- Creating Rocky Cloud image KVM ---" virt-install --name=rocky --ram=4096 --vcpus=8 \ --disk $imagePath \ --boot hd --noautoconsole \ --os-variant rhel9.0 echo "--- Finished creating Rocky Cloud image KVM ---" echo "+++ All changes will be saved +++" echo "--- Getting the Rocky Cloud image KVM's IP ---" source $utilsLocation/setVMIP.sh # Done here, and not through virt-customize due to it making the end image several hundred magabytes bigger echo "--- Resizing filesystem to match virtual disk image size ---" ssh -o ConnectTimeout=300 -o StrictHostKeyChecking=no rocky@$vmIPaddress $utilsLocation/cleanup.sh echo "+++ All changes were saved +++" echo "Finished successfully, output file is same as input: $imagePath"