diff --git a/oracle-linux-image-tools/README.md b/oracle-linux-image-tools/README.md index 7f57514..0ef95b4 100755 --- a/oracle-linux-image-tools/README.md +++ b/oracle-linux-image-tools/README.md @@ -12,9 +12,9 @@ The tool currently supports: - Distributions: - Oracle Linux 7 update 9 -- Slim (x86_64) - Oracle Linux 8 update 6 -- Slim (x86_64 and aarch64) - __Note__: for aarch64, only Generic and OCI clouds are supported + __Note__: for aarch64, only Generic, OCI and UTM clouds are supported - Oracle Linux 9 update 0 -- Slim (x86_64 and aarch64) - __Note__: for aarch64, only Generic and OCI clouds are supported + __Note__: for aarch64, only Generic, OCI and UTM clouds are supported - Clouds: - Microsoft Azure cloud Target packages: WALinuxAgent @@ -35,6 +35,10 @@ The tool currently supports: - Vagrant (libvirt provider) Target packages: nfs-utils Image format: box + - UTM ([UTM for macOS](https://mac.getutm.app/)) + Target packages: none + Image format: utm + __Note__: only for aarch64 distributions - Generic (No cloud setup) Target packages: none Image format: VirtualBox OVA or QCOW2 (depending on the builder used) diff --git a/oracle-linux-image-tools/cloud/utm/Penguin.png b/oracle-linux-image-tools/cloud/utm/Penguin.png new file mode 100644 index 0000000..36af9b4 Binary files /dev/null and b/oracle-linux-image-tools/cloud/utm/Penguin.png differ diff --git a/oracle-linux-image-tools/cloud/utm/config.plist b/oracle-linux-image-tools/cloud/utm/config.plist new file mode 100644 index 0000000..936baee --- /dev/null +++ b/oracle-linux-image-tools/cloud/utm/config.plist @@ -0,0 +1,110 @@ + + + + + ConfigurationVersion + 2 + Debug + + DebugLog + + + Display + + ConsoleFont + Menlo + ConsoleFontSize + 12 + ConsoleOnly + + ConsoleTheme + Default + DisplayDownscaler + linear + DisplayFitScreen + + DisplayUpscaler + linear + + Drives + + + ImagePath + image.qcow2 + ImageType + disk + InterfaceType + virtio + + + ImageType + cd + InterfaceType + usb + Removable + + + + Info + + Icon + Penguin.png + IconCustom + + Notes + Default user/initial password: opc/opc +Root password: locked + + Input + + InputLegacy + + + Networking + + NetworkCard + virtio-net-device + NetworkEnabled + + + Printing + + Sharing + + ClipboardSharing + + DirectoryName + + DirectorySharing + + + Sound + + SoundCard + hda + SoundEnabled + + + System + + Architecture + aarch64 + BootDevice + hdd + CPUCount + 0 + ForceMulticore + + JITCacheSize + 0 + MachineProperties + highmem=off + Memory + 2048 + SystemUUID + 00000000-0000-0000-0000-000000000000 + Target + virt + + + diff --git a/oracle-linux-image-tools/cloud/utm/image-scripts.sh b/oracle-linux-image-tools/cloud/utm/image-scripts.sh new file mode 100755 index 0000000..767940f --- /dev/null +++ b/oracle-linux-image-tools/cloud/utm/image-scripts.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# +# Cleanup and package image for the "None" image +# +# Copyright (c) 2022 Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at +# https://oss.oracle.com/licenses/upl +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# + +####################################### +# Image packaging: +# For VistualBox we convert back to VMDK and re-create the OVA file +# For qemu we convert to a qcow2 file +# Globals: +# CLOUD_DIR CLOUD +# VM_NAME +# Arguments: +# None +# Returns: +# None +####################################### +cloud::image_package() { + local utm_dir uuid + utm_dir="${VM_NAME}.utm" + mkdir -p "${utm_dir}/Images" + common::convert_to_qcow2 "${utm_dir}/Images/${VM_NAME}.qcow2" + cp "${CLOUD_DIR}/${CLOUD}/Penguin.png" "${utm_dir}" + uuid=$(python3 -c "import uuid; print(str(uuid.uuid4()).upper())") + sed \ + -e "s/image.qcow2/${VM_NAME}.qcow2/" \ + -e "s!opc/opc!opc/${SSH_PASSWORD}!" \ + -e "s/00000000-0000-0000-0000-000000000000/${uuid}/" \ + "${CLOUD_DIR}/${CLOUD}/config.plist" > "${utm_dir}/config.plist" + zip -r "${utm_dir}.zip" "${utm_dir}" + rm -rf "${utm_dir}" +} diff --git a/oracle-linux-image-tools/cloud/utm/provision.sh b/oracle-linux-image-tools/cloud/utm/provision.sh new file mode 100755 index 0000000..dc720d7 --- /dev/null +++ b/oracle-linux-image-tools/cloud/utm/provision.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# +# Packer provisioning script for UTM +# +# Copyright (c) 2022 Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at +# https://oss.oracle.com/licenses/upl +# +# Description: UTM specific provisioning.n +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# + +####################################### +# Provisioning module +# Globals: +# None +# Arguments: +# None +# Returns: +# None +####################################### +cloud::provision() +{ + hash=$(/usr/libexec/platform-python -c "import crypt; print(crypt.crypt('${SSH_PASSWORD}', crypt.METHOD_SHA512))") + useradd opc -c "Oracle Public Cloud User" -G wheel -m -p "${hash}" + passwd -e opc + echo "%opc ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/opc + chmod 0440 /etc/sudoers.d/opc + restorecon /etc/sudoers.d/opc +}