
set default=2
set timeout=-1

insmod bsd
insmod cpuid
insmod echo
insmod gzio
insmod minicmd
insmod normal
insmod chain

if loadfont /boot/grub/font.pf2 ; then
	set gfxmode=640x480
	set gfxpayload=keep
	insmod vbe
	insmod gfxterm
	terminal_output gfxterm
fi

insmod png
if background_image /boot/grub/splash.png ; then
	set color_normal=white/black
	set color_highlight=black/white
else
	set menu_color_normal=cyan/blue
	set menu_color_highlight=white/blue
fi

insmod play
play 480 440 1

menuentry "Debian GNU/kFreeBSD installer boot menu" {
	true
}

menuentry "" {
	true
}

function menuentry_set {
	set kernel_path="$1"
	set mfsroot_path="$2"
	set desc_suffix="$3"

	menuentry "Default install$desc_suffix" $kernel_path $mfsroot_path {
		echo "Loading ..."
		kfreebsd $2
		kfreebsd_module $3 type=mfs_root
	}

	menuentry "Automated install$desc_suffix" $kernel_path $mfsroot_path {
		echo "Loading ..."
		kfreebsd $2
		kfreebsd_module $3 type=mfs_root
		set kFreeBSD.auto=true
		set kFreeBSD.priority=critical
	}

	menuentry "Expert install$desc_suffix" $kernel_path $mfsroot_path {
		echo "Loading ..."
		kfreebsd $2
		kfreebsd_module $3 type=mfs_root
		set kFreeBSD.priority=low
	}
}

# Default kernel
if test -e /boot/kernel/kfreebsd-9.gz ; then
	menuentry_set /boot/kernel/kfreebsd-9.gz /boot/mfsroot.gz " (using kernel of FreeBSD 9)"

	if test -e /boot/gtk/mfsroot.gz ; then
		menuentry "" { true }
		menuentry_set /boot/kernel/kfreebsd-9.gz /boot/gtk/mfsroot.gz " (graphical mode with kernel of FreeBSD 9)"
	fi
fi

# Alternate kernel
if test -e /boot/kernel/kfreebsd-10.gz ; then
	# When both options are available, add an empty line in-between.
	if test -e /boot/kernel/kfreebsd-9.gz ; then
		menuentry "" { true }
	fi

	menuentry_set /boot/kernel/kfreebsd-10.gz /boot/mfsroot.gz " (using kernel of FreeBSD 10)"

	if test -e /boot/gtk/mfsroot.gz ; then
		menuentry "" { true }
		menuentry_set /boot/kernel/kfreebsd-10.gz /boot/gtk/mfsroot.gz " (graphical mode with kernel of FreeBSD 10)"
	fi
fi

menuentry "" {
	true
}

menuentry "Boot from first hard disk" {
	set root=hd0
	chainloader +1
}
