Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update #1559

Merged
merged 20 commits into from
Mar 20, 2024
Prev Previous commit
Next Next commit
testing
Stromweld committed Mar 19, 2024
commit e68ea3b39d5f9850889707bb582fd78cc3599ab3
23 changes: 12 additions & 11 deletions amazon_linux_2023_build.sh
Original file line number Diff line number Diff line change
@@ -12,13 +12,13 @@ IMG="$(wget -q https://cdn.amazonlinux.com/al2023/os-images/latest/kvm/ -O - | g

# Download image
echo "Downloading $IMG"
wget -q -O "$AMZDIR"/amazon22023.qcow2 -c https://cdn.amazonlinux.com/al2023/os-images/latest/kvm/"$IMG"
wget -q -O "$AMZDIR"/amazon2023.qcow2 -c https://cdn.amazonlinux.com/al2023/os-images/latest/kvm/"$IMG"

echo "Convert qcow2 to vdi"
qemu-img convert -f qcow2 "$AMZDIR"/amazon22023.qcow2 -O vdi "$AMZDIR"/amazon22023.vdi
qemu-img convert -f qcow2 "$AMZDIR"/amazon2023.qcow2 -O vdi "$AMZDIR"/amazon2023.vdi

if [ ! -f "$AMZDIR"/amazon22023.vdi ]; then
echo There must be a file named amazon22023.vdi in "$AMZDIR"!
if [ ! -f "$AMZDIR"/amazon2023.vdi ]; then
echo There must be a file named amazon2023.vdi in "$AMZDIR"!
echo You can download the files at https://cdn.amazonlinux.com/al2023/os-images/latest/
exit 1
fi
@@ -39,8 +39,9 @@ echo "Creating the VM"
# from https://www.perkin.org.uk/posts/create-virtualbox-vm-from-the-command-line.html
VBoxManage createvm --name $VM --ostype "Fedora_64" --register
VBoxManage storagectl $VM --name "SATA Controller" --add sata --controller IntelAHCI
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "$AMZDIR"/amazon22023.vdi
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 1 --type dvddrive --medium "$AMZDIR"/seed.iso
VBoxManage storagectl $VM --name "SATA CDROM" --add sata --controller IntelAHCI
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "$AMZDIR"/amazon2023.vdi
VBoxManage storageattach $VM --storagectl "SATA CDROM" --port 0 --device 0 --type dvddrive --medium "$AMZDIR"/seed.iso
VBoxManage modifyvm $VM --memory 2048
VBoxManage modifyvm $VM --cpus 2
VBoxManage modifyvm $VM --audio-driver none
@@ -51,18 +52,18 @@ echo "Sleeping for 120 seconds to let the system boot and cloud-init to run"
VBoxManage startvm $VM --type headless
sleep 120
VBoxManage controlvm $VM poweroff --type headless
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 1 --type dvddrive --medium none
VBoxManage storageattach $VM --storagectl "SATA CDROM" --port 0 --device 0 --type dvddrive --medium none
sleep 5

echo "Exporting the VM to an OVF file""
vboxmanage export $VM -o "$AMZDIR"/amazon22023.ovf
echo "Exporting the VM to an OVF file"
vboxmanage export $VM -o "$AMZDIR"/amazon2023.ovf
sleep 5

echo "Deleting the VM""
echo "Deleting the VM"
vboxmanage unregistervm $VM --delete

echo "starting packer build of amazonlinux"
if packer build -timestamp-ui -only=virtualbox-ovf.vm -var "vbox_source_path=$AMZDIR/amazon22023.ovf" -var "vbox_checksum=null" -var-file="$AMZDIR"/../../os_pkrvars/amazonlinux/amazonlinux-2023-x86_64-virtualbox.pkrvars.hcl "$AMZDIR"/../../packer_templates; then
if packer build -timestamp-ui -only=virtualbox-ovf.vm -var "vbox_source_path=$AMZDIR/amazon2023.ovf" -var "vbox_checksum=null" -var-file="$AMZDIR"/../../os_pkrvars/amazonlinux/amazonlinux-2023-x86_64-virtualbox.pkrvars.hcl "$AMZDIR"/../../packer_templates; then
echo "Cleaning up files"
rm -f "$AMZDIR"/*.ovf "$AMZDIR"/*.vmdk "$AMZDIR"/*.iso "$AMZDIR"/*.vdi "$AMZDIR"/*.qcow2
else