Skip to content

Instantly share code, notes, and snippets.

@thamognya
Created April 2, 2022 00:53
Show Gist options
  • Save thamognya/4e21400ea856c2aba8f449cd58e74d64 to your computer and use it in GitHub Desktop.
Save thamognya/4e21400ea856c2aba8f449cd58e74d64 to your computer and use it in GitHub Desktop.
Debian GNU/Hurd Installler: Gets Debian GNU/Hurd working with kvm.
#!/bin/sh
# -i to specifiy iso directory
# -c to install iso cd, if you do not have it already (if you have specify with -i option)
# -d to install iso dvd, if you do not have it already (if you have specify with -i option)
base_current_link="https://cdimage.debian.org/cdimage/ports/hurd-i386/current/iso-dvd/"
while getopts ":hi:cd:" opt; do
case $opt in
i) dir_for_iso=${OPTARG};;
c) base_current_link="https://cdimage.debian.org/cdimage/ports/hurd-i386/current/iso-cd/" ;;
d) base_current_link="https://cdimage.debian.org/cdimage/ports/hurd-i386/current/iso-dvd/" ;;
h) printf "%s\n%s\n%s\n" "-c option: uses iso-cd, much more lightweight, requires internet" "-d option: uses iso-dvd, everything installed so no need wifi" "-i option to specify location of iso or iso download" && exit 1;;
\?)
printf "%s\n%s\n" "Invalid option: -$OPTARG" "do -h for help" >&2
;;
esac
done
#dir_for_iso="./iso/"
latest_iso_link="$base_current_link$(curl -s "$base_current_link" | grep -Eo "debian-hurd[a-zA-Z0-9\.\-]*" | head -n 1)"
current_dir=$(pwd)
if [ ! -f "$dir_for_iso" ] ; then
printf "%s\n%s\n" "iso not found" "installing it now"
mkdir -p $dir_for_iso
$(cd $dir_for_iso && curl -LO $latest_iso_link && cd $current_dir)
printf "%s\n%s\n" "iso installed" "redo the script to continue"
exit 1
elif [ command -v qemu-system-i386 >/dev/null 2>&1 ] ; then
echo "qemu-system-i386 is not installed. Please install it first. If you are using gentoo, refer to my make.conf in the repo https://github.com/ThamognyaKodi/portage-config around where there is qemu."
exit 1
else
if [ -f "hurd-install.qemu" ] ; then
printf "%s\n%s\n" "hurd-install.qemu exists" "Running it now ..."
$(qemu-system-i386 ./hurd-install.qemu)
exit 1
else
printf "%s\n%s\n" "hurd-install.qemu does not exist" "Creating it now ..."
qemu-img create -f raw "$current_dir/hurd-install.qemu" 10G
printf "%s\n%s\n" "hurd-install.qemu created" "Running it now ..."
$(qemu-system-i386 -enable-kvm -m 1G -drive file=./hurd-install.qemu,format=raw,cache=writeback -cdrom "$dir_for_iso" -boot d)
exit 1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment