if [ -s $prefix/grubenv ] ; then
    set have_grubenv=true
    load_env
fi

if [ "${next_entry}" ] ; then
    set default="${next_entry}"
    set next_entry=
    save_env next_entry
    set boot_once=true
else
    set default="0"
fi

if [ x"${feature_menuentry_id}" = xy ] ; then
    menuentry_id_option="--id"
else
    menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ] ; then
    set saved_entry="${prev_saved_entry}"
    save_env saved_entry
    set prev_saved_entry=
    save_env prev_saved_entry
    set boot_once=true
fi

function savedefault {
    if [ -z "${boot_once}" ] ; then
        saved_entry="${chosen}"
        save_env saved_entry
    fi
}

function recordfail {
    set recordfail=1
    if [ -n "${have_grubenv}" ] ; then
        if [ -z "${boot_once}" ] ; then
            save_env recordfail
        fi;
    fi
}

function load_video {
    if [ x$feature_all_video_module = xy ] ; then
        insmod all_video
    else
        insmod efi_gop
        insmod efi_uga
        insmod ieee1275_fb
        insmod vbe
        insmod vga
        insmod video_bochs
        insmod video_cirrus
    fi
}

if [ x$feature_default_font_path = xy ] ; then
    font=unicode
fi

if loadfont $font ; then
    set gfxmode=auto
    load_video
    insmod gfxterm
    set locale_dir=$prefix/locale
    set lang=en_IN
    insmod gettext
fi

terminal_output gfxterm
insmod part_msdos
insmod ext2
insmod gfxmenu
insmod regexp

function loadtheme {
    theme_name=$1
    
    insmod jpeg
    insmod png

    for font in (${root})/boot/grub/themes/${theme_name}/*.pf2 ; do
        loadfont ${font}
    done

    set theme=(${root})/boot/grub/themes/${theme_name}/theme.txt
    export theme

    set menu_color_normal="white/black"
    set menu_color_highlight="black/light-gray"
}

loadtheme "default"

if [ "${recordfail}" = 1 ] ; then
    set timeout=30
else
    if [ x$feature_timeout_style = xy ] ; then
        set timeout_style=menu
        set timeout=10
    else
        set timeout=10
    fi
fi

if [ "${grub_platform}" = "efi" ] ; then
    rmmod tpm
fi

# Подключение конфигурационных файлов

for cfg in (${root})/boot/grub/menuentries/*.cfg ; do
    source $cfg
done

menuentry 'Перезагрузить компьютер' --class restart {
    reboot
}

menuentry 'Выключить компьютер' --class shutdown {
    halt
}
