nilmbuntu/run.sh
2020-08-07 17:26:59 -04:00

77 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# try to boot the ISO in qemu
. config || exit 0
usage() {
cat <<EOF
usage: $0 [-i iso] <-c | -d>
-c Make an empty disk image and boot from CD
-d Boot the disk image
-i Path to iso
EOF
exit 0
}
boot=""
iso="${OUTPUT}"
while getopts cdi: flag; do
case $flag in
c)
boot="c$boot"
;;
d)
boot="d$boot"
;;
i)
iso="$OPTARG"
;;
?)
usage
;;
esac
done
case $boot in
?)
;;
*)
usage
;;
esac
set -e
set -x
cfg=""
cfg+=" -nodefaults"
cfg+=" -drive file=${DISK},media=disk,format=raw,if=virtio"
cfg+=" -enable-kvm"
cfg+=" -m 2048"
cfg+=" -usb"
cfg+=" -device usb-tablet"
cfg+=" -nic user"
cfg+=" -vga virtio"
cfg+=" -k en-us"
#cfg+=" -vnc :0"
case $boot in
c)
echo "booting CD with empty disk"
rm -f ${DISK}
dd if=/dev/zero "of=${DISK}" bs=1M count=0 seek=24576
cfg+=" -drive file=${iso},media=cdrom,if=none,id=cd"
cfg+=" -device virtio-scsi-pci -device scsi-cd,drive=cd"
cfg+=" -boot d"
;;
d)
echo "booting disk with no CD"
cfg+=" -boot c"
;;
esac
qemu-system-x86_64 $cfg