19 lines
573 B
Plaintext
19 lines
573 B
Plaintext
|
#!/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 /etc/runscript"
|
||
|
"${qemu[@]}" -drive media=disk,format=raw,if=virtio,file="$1"
|
||
|
sudo unshare --mount sh -c "mount --make-rslave / && mount ${image@Q} ${mountpoint@Q} && cat /var/log/runscript.out; exit \$(cat /var/log/runscript.status)"
|
||
|
}
|