34 lines
968 B
Bash
Executable File
34 lines
968 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -o errexit
|
|
set -o nounset
|
|
set -o pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
# shellcheck source=00-platform-guard.inc
|
|
source "$SCRIPT_DIR/00-platform-guard.inc"
|
|
|
|
packages=(
|
|
qemu-system-x86 qemu-utils libvirt-daemon-system libvirt-clients
|
|
virtinst virt-manager bridge-utils ovmf swtpm swtpm-tools dnsmasq-base
|
|
)
|
|
|
|
if ((EUID != 0)); then
|
|
printf 'CRITICAL: libvirt setup must run as root\n' >&2
|
|
exit 2
|
|
fi
|
|
require_supported_ubuntu
|
|
if ! command -v apt-get >/dev/null 2>&1; then
|
|
printf 'CRITICAL: apt-get is required\n' >&2
|
|
exit 2
|
|
fi
|
|
|
|
apt-get update
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y "${packages[@]}"
|
|
systemctl enable --now libvirtd
|
|
|
|
printf '\n== Virtual machines ==\n'
|
|
virsh list --all || printf 'WARNING: unable to list virtual machines\n'
|
|
printf '\n== Virtual networks ==\n'
|
|
virsh net-list --all || printf 'WARNING: unable to list virtual networks\n'
|
|
printf 'OK: libvirt/KVM setup completed\n'
|