#!/usr/bin/env bash # 2018 Luke Shumaker { set -euE source "${BASH_SOURCE[0]%/*}/lib/osi.sh" become_sudo "$@" arg_image="$1" qemu=( qemu-system-x86_64 -machine accel=kvm -m 512 ) mountpoint=$(mktemp -dt -- "${0##*/}.XXXXXXXXXX") trap "rmdir -- ${mountpoint@Q}" EXIT with_mount "$arg_image" "$mountpoint" install -Dm755 /dev/stdin "$mountpoint/etc/osi-run" sudo -u "#${SUDO_UID}" -- "${qemu[@]}" -drive media=disk,format=raw,if=virtio,file="$arg_image" with_mount "$arg_image" "$mountpoint" sh -c "cat ${mountpoint@Q}/var/log/osi-run.out; exit \$(cat ${mountpoint@Q}/var/log/osi-run.status)" }