#!/bin/sh bit64=false redownload=false fsck=false daemon=false while getopts "6rfd" opt; do case "$opt" in 6) bit64=true;; r) redownload=true;; f) fsck=true;; d) daemon=true;; *) echo "Usage: ${0} [options]" echo 'Options include:' echo ' -6 = use the new 64bit build' echo ' -r = redownload instead of booting existing image' echo ' -f = run a filesystem check (requires losetup and fsck.ext2)' echo ' -d = daemonize, start qemu and return to the shell' # TODO: option for curses display (for non-GUI environments and/or to translate keyboard because Hurd console currently lacks keyboard layouts outside US qwerty) exit;; esac done if [ ! -e debian-hurd.img ] || "$redownload"; then rm -f debian-hurd.img.tar.gz if "$bit64"; then wget 'https://cdimage.debian.org/cdimage/ports/latest/hurd-amd64/debian-hurd.img.tar.gz' else wget 'https://cdimage.debian.org/cdimage/ports/latest/hurd-i386/debian-hurd.img.tar.gz' fi image="`tar -xvzf debian-hurd.img.tar.gz`" mv "$image" debian-hurd.img fi if "$fsck"; then # TODO: Dynamically figure out which way (if any, maybe user is root) to run these as root disk="`sudo losetup -fP --show debian-hurd.img`" if [ -z "$disk" ]; then echo 'Failed to losetup the disk image. Is losetup installed?'; exit 1; fi sudo fsck.ext2 "${disk}p5" sudo losetup -d "$disk" fi kvm="`grep -q ' \(svm\|vmx\)' /proc/cpuinfo && echo '--enable-kvm'`" runqemu() { # I think 32bit code should work even if we run x86_64 qemu? # For now 64bit Hurd seems to require -M q35 to run in qemu qemu-system-x86_64 ${kvm} -m 2G -M q35 -drive cache=writeback,file=debian-hurd.img -net user,hostfwd=tcp:127.0.0.1:2222-:22 -net nic,model=e1000 } if "$daemon"; then runqemu > /dev/null 2> /dev/null & else runqemu fi