mirror of
https://github.com/outbackdingo/incus-os.git
synced 2026-01-27 10:19:24 +00:00
48 lines
1.1 KiB
Bash
Executable File
48 lines
1.1 KiB
Bash
Executable File
#!/bin/sh -eu
|
|
if [ -z "${1:-}" ]; then
|
|
echo "Usage: ${0} NAME"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if instance already exists
|
|
if incus info "${1}" >/dev/null 2>&1; then
|
|
echo "Instance ${1} already exists"
|
|
exit 1
|
|
fi
|
|
|
|
# Setup temporary directory
|
|
cleanup() {
|
|
rm -f IncusOS_*.iso
|
|
}
|
|
trap cleanup EXIT HUP INT TERM
|
|
|
|
# Grab and configure the image
|
|
INCUSOS_SEED_TAR=test/seed.install.tar INCUSOS_IMAGE_FORMAT=iso incus-osd/flasher-tool
|
|
# shellcheck disable=SC2010
|
|
IMG_NAME=$(ls IncusOS_*.iso | grep -v usr | grep -v esp | sort | tail -1)
|
|
|
|
# Create an instance
|
|
echo "=> Creating an IncusOS instance"
|
|
incus create --vm --empty "${1}" \
|
|
-c security.secureboot=false \
|
|
-c limits.cpu=4 \
|
|
-c limits.memory=8GiB \
|
|
-d root,size=50GiB
|
|
incus config device add "${1}" vtpm tpm
|
|
incus config device add "${1}" boot-media disk source="$(pwd)/${IMG_NAME}" boot.priority=10
|
|
|
|
echo "=> Starting IncusOS for installation"
|
|
incus start "${1}" --console
|
|
sleep 5
|
|
incus console "${1}"
|
|
sleep 5
|
|
clear
|
|
|
|
# Remove install media
|
|
incus stop -f "${1}"
|
|
incus config device remove "${1}" boot-media
|
|
|
|
# Start the installed system
|
|
echo "=> Starting installed IncusOS"
|
|
incus start "${1}" --console
|