memtest86Plus/memtest86+-grub-efi

38 lines
1.4 KiB
Bash

#!/usr/bin/env bash
########################################################
# This script generates a memtest86+ entry on grub.cfg #
# if memtest is installed on the system. #
########################################################
prefix="/usr"
exec_prefix="${prefix}"
datarootdir="/usr/share"
datadir="${datarootdir}"
. "${datadir}/grub/grub-mkconfig_lib"
MEMTEST86_IMAGE="/boot/memtest86+.efi"
CLASS="--class memtest86 --class gnu --class tool"
if [ -e "${MEMTEST86_IMAGE}" ] && is_path_readable_by_grub "${MEMTEST86_IMAGE}" ; then
## image exists, create menu entry
echo "Found memtest86+ EFI image: ${MEMTEST86_IMAGE}" >&2
_GRUB_MEMTEST_HINTS_STRING="$(${grub_probe} --target=hints_string ${MEMTEST86_IMAGE})"
_GRUB_MEMTEST_FS_UUID="$(${grub_probe} --target=fs_uuid ${MEMTEST86_IMAGE})"
_GRUB_MEMTEST_REL_PATH="$(make_system_path_relative_to_its_root ${MEMTEST86_IMAGE})"
cat << EOF
if [ "\${grub_platform}" == "efi" ]; then
menuentry "Memory Tester (memtest86+)" ${CLASS} {
if loadfont unicode ; then
set gfxmode=1024x768,800x600,auto
set gfxpayload=800x600,1024x768
terminal_output gfxterm
fi
search --fs-uuid --no-floppy --set=root ${_GRUB_MEMTEST_HINTS_STRING} ${_GRUB_MEMTEST_FS_UUID}
linux ${_GRUB_MEMTEST_REL_PATH} ${GRUB_CMDLINE_MEMTEST86}
}
fi
EOF
fi