osi-tools/osi-run

19 lines
616 B
Bash
Executable File

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