#!/bin/sh set -e cd /tmp # extract. BSD tar auto recognises compression, unlike GNU tar # only if stdin is a tty, if so need files volume mounted... test -t 0 || bsdtar xzf - setglobal TGZ = $[find . -name '*.tgz' -or -name '*.tar.gz] test -n $TGZ && bsdtar xzf $TGZ setglobal EFI_ISO = $[find . -name '*efi.iso] setglobal ISO = $[find . -name '*.iso] setglobal RAW = $[find . -name '*.raw] setglobal INITRD = $[find . -name '*.img] setglobal KERNEL = $[find . -name vmlinuz64 -or -name '*bzImage] setglobal CMDLINE = $[find . -name '*-cmdline] if test -n $EFI_ISO { setglobal ARGS = ""-pflash /usr/share/ovmf/bios.bin -usbdevice tablet -cdrom $EFI_ISO -boot d -drive file=systemdisk.img,format=raw"" } elif test -n $ISO { setglobal ARGS = ""-cdrom $ISO -drive file=systemdisk.img,format=raw"" } elif test -n $RAW { # should test with more drives setglobal ARGS = ""-drive file=$RAW,format=raw"" } elif test -n $KERNEL { setglobal ARGS = ""-kernel $KERNEL"" if test -n $INITRD { setglobal ARGS = ""$ARGS -initrd $INITRD"" } setglobal ARGS = ""$ARGS -drive file=systemdisk.img,format=raw"" } else { echo "no recognised boot media" >2 exit 1 } echo $ARGS | grep -q systemdisk && qemu-img create -f raw systemdisk.img 256M if test -n $(CMDLINE) { setglobal APPEND = $[cat $CMDLINE] } else { setglobal APPEND = "$ifsjoin(Argv)" } if test -z $(APPEND) { setglobal APPEND = '"console=ttyS0'" } if test -z $EFI_ISO && test -z $ISO { setglobal ARGS = ""-append \"$(APPEND)\" $(ARGS)"" } eval qemu-system-x86_64 -machine q35,accel=kvm:tcg -device virtio-rng-pci -nographic -vnc none -m 1024 $ARGS