#!/bin/bash -e

source /usr/lib/grub/grub-mkconfig_lib

cat << EOF
menuentry "#RECOVERY_TEXT#" {
        search --no-floppy --hint '(hd0,#PARTITION#)' --set --fs-uuid #UUID#
        set uuid_options="uuid=#UUID#"
        if [ -s /factory/common.cfg ]; then
            source /factory/common.cfg
        else
            set options="boot=casper automatic-ubiquity noprompt quiet splash nomodeset"
        fi
        #Support starting from a loopback mount (Only support ubuntu.iso for filename)
        if [ -f /ubuntu.iso ]; then
            loopback loop /ubuntu.iso
            set root=(loop)
            set options="\$options iso-scan/filename=/ubuntu.iso"
        fi
        if [ -n "\${lang}" ]; then
            set options="\$options locale=\$lang"
        fi
        if [ -s /factory/dual_enable ]; then
            set options="\$options dell-recovery/dual_boot=true"
        fi 

        linux   /casper/vmlinuz.efi dell-recovery/recovery_type=hdd \$uuid_options \$options
	initrd	/casper/initrd.lz
}
EOF

