boot-iso.sh 800 B

1234567891011121314151617181920212223
  1. #!/bin/bash
  2. ISOS_DIR=$(dirname $0)/out
  3. HD_IMG=
  4. SSH_FWD_HOST_PORT=
  5. ISO="$(ls -t $ISOS_DIR/*.iso | head -n 1)"
  6. VIRTIO_NET_DEV="-netdev user,id=vmnic,hostfwd=tcp::$SSH_FWD_HOST_PORT-:22 \
  7. -device virtio-net,netdev=vmnic"
  8. QEMU="qemu-system-x86_64 -enable-kvm"
  9. MEM="-m 1G"
  10. VIDEO="-vga std"
  11. AUDIO="-soundhw hda "
  12. WM_HIMTS="-display sdl -no-frame" # -show-cursor"
  13. [ "$ISO" ] && CD="-cdrom $ISO -boot d" || CD=''
  14. [ "$HD_IMG" ] && HD="-drive file=$HD_IMG,format=raw,cache=writeback" || HD=''
  15. [ "$SSH_FWD_HOST_PORT" ] && NET_DEV="$VIRTIO_NET_DEV" || NET_DEV=''
  16. [ ! "$ISO" ] && echo "no ISO found in ISOS_DIR: '$ISOS_DIR'" && exit
  17. CMD="$QEMU $MEM $HD $CD $NET_DEV $VIDEO $AUDIO $WM_HIMTS $*"
  18. echo "$CMD" ; $CMD ;