检测 GRUB2 菜单上的不同键

检测 GRUB2 菜单上的不同键

我有一个如下所示的 GRUB 配置,我想检测不同的键输入,以便我可以采取相应的行动,但这默认情况下不起作用:

echo ""
echo -n "server: "
echo -n $net_default_server
echo -n " client: "
net_ls_addr
echo ""
echo "--------------------------------------------------------------------------"
echo "                      Boot from disk in 5 seconds."
echo "Press [ENTER] for network boot. Press [TAB] for text mode network boot."
echo "--------------------------------------------------------------------------"

# this is modified sleep returning:
# 0 - timeout
# 1 - ESC
# 2 - TAB
# 3 - ENTER
sleep -i 5

set retcode=$?

clear

if [ $retcode == 1 ]; then
    exit
fi

if [ $retcode == 0 ]; then
    exit
fi

if [ $retcode == 3 ]; then
    terminal_output gfxterm
    set gfxmode="800x600;640x480;auto"
    set theme=theme.txt
fi


set color_normal=white/black
set color_highlight=black/white
set menu_color_normal=white/black
set menu_color_highlight=black/white
set timeout=15
set default='Exit to EFI Shell'
set fallback='Exit to EFI Shell'
set pager=1

menuentry 'Install CentOS 8 Linux x86_64 (C8)' {
 blah
}

这来自我不再拥有的本地 grub 补丁,因此我的问题是:这有可能吗?即使更改密钥也可以解决问题。

相关内容