#!/bin/sh
# Attempt to install qubes using the recovery shell and the pre-built
# version of Xen

. /etc/functions

DEV="$1"
if [ -z "$DEV" ]; then
	DEV="/dev/sdb2"
fi

mount-usb "$DEV" \
	|| die "$DEV: Unable to mount?"

cd /media/efi/boot \
	|| die "$DEV: cd to /media/efi/boot failed?"

kexec -l \
  --module "./vmlinuz inst.stage2=hd:LABEL=Qubes-R3.2-x86_64" \
  --module "./initrd.img" \
  --command-line "no-real-mode reboot=no" \
  /bin/xen.gz \
|| die "$DEV: kexec -l failed?"

warn "Starting installer..."
sleep 1
kexec -e

die "$DEV: kexec -e failed?"
