#! /bin/sh -e

. /lib/kickseed/cmdline.sh

# Run a debconf-using program, possibly inside bterm.
# Cloned-and-hacked from /lib/debian-installer.d/S70menu-linux.
bterm_run () {
	bterm=/usr/bin/bterm
	font=/unifont.bgf

	if [ -x "$bterm" ] && [ -e "$font" ] && \
	   [ "$TERM_UTF8" ] && [ "$TERM_FRAMEBUFFER" ]; then
		TERM=bterm MENU="$1" \
			$bterm -f $font -l $LANG /lib/debian-installer/menu
	else
		MENU="$1" /lib/debian-installer/menu
	fi
}

KS="$(kickseed_cmdline /proc/cmdline ks)"

case $KS in
	cdrom:/*)
		bterm_run /lib/kickseed/setup/cdrom || true
		;;
	ftp://*/*|http://*/*|https://*/*)
		bterm_run /lib/kickseed/setup/net || true
		;;
	hd:*:/*)
		bterm_run /lib/kickseed/setup/hd || true
		;;
	nfs:*:/*)
		bterm_run /lib/kickseed/setup/nfs || true
		;;
esac
