osi-tools/osi-run

22 lines
613 B
Plaintext
Raw Normal View History

2018-08-06 01:49:45 +00:00
#!/usr/bin/env bash
# 2018 Luke Shumaker
{
set -euE
2018-08-11 21:15:13 +00:00
source "${BASH_SOURCE[0]%/*}/lib/osi.sh"
become_sudo "$@"
arg_image="$1"
2018-08-06 01:49:45 +00:00
qemu=(
qemu-system-x86_64
-machine accel=kvm
-m 512
)
mountpoint=$(mktemp -dt -- "${0##*/}.XXXXXXXXXX")
trap "rmdir -- ${mountpoint@Q}" EXIT
2018-08-11 21:15:13 +00:00
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)"
2018-08-06 01:49:45 +00:00
}