2018-08-06 01:49:45 +00:00
|
|
|
#!/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
|
|
|
|
|
2018-08-06 01:56:44 +00:00
|
|
|
sudo unshare --mount sh -c "mount --make-rslave / && mount ${image@Q} ${mountpoint@Q} && install -Dm755 /dev/stdin /etc/osi-run"
|
2018-08-06 01:49:45 +00:00
|
|
|
"${qemu[@]}" -drive media=disk,format=raw,if=virtio,file="$1"
|
2018-08-06 01:56:44 +00:00
|
|
|
sudo unshare --mount sh -c "mount --make-rslave / && mount ${image@Q} ${mountpoint@Q} && cat /var/log/osi-run.out; exit \$(cat /var/log/osi-run.status)"
|
2018-08-06 01:49:45 +00:00
|
|
|
}
|