#!/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 - setvar TGZ = "$(find . -name '*.tgz' -or -name '*.tar.gz')" test -n $TGZ && bsdtar xzf $TGZ setvar EFI_ISO = "$(find . -name '*efi.iso')" setvar ISO = "$(find . -name '*.iso')" setvar RAW = "$(find . -name '*.raw')" setvar INITRD = "$(find . -name '*.img')" setvar KERNEL = "$(find . -name vmlinuz64 -or -name '*bzImage')" setvar CMDLINE = "$(find . -name '*-cmdline')" if test -n $EFI_ISO { setvar ARGS = ""-pflash /usr/share/ovmf/bios.bin -usbdevice tablet -cdrom $EFI_ISO -boot d -drive file=systemdisk.img,format=raw"" } elif test -n $ISO { setvar ARGS = ""-cdrom $ISO -drive file=systemdisk.img,format=raw"" } elif test -n $RAW { # should test with more drives setvar ARGS = ""-drive file=$RAW,format=raw"" } elif test -n $KERNEL { setvar ARGS = ""-kernel $KERNEL"" if test -n $INITRD { setvar ARGS = ""$ARGS -initrd $INITRD"" } setvar 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} { setvar APPEND = "$(cat $CMDLINE)" } else { setvar APPEND = ""$ifsjoin(ARGV)"" } if test -z ${APPEND} { setvar APPEND = ""console=ttyS0"" } if test -z $EFI_ISO && test -z $ISO { setvar ARGS = ""-append \"${APPEND}\" ${ARGS}"" } eval qemu-system-x86_64 -machine q35,accel=kvm:tcg -device virtio-rng-pci -nographic -vnc none -m 1024 $ARGS