1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
#!/bin/sh
set -e
if [ -f /usr/lib/grub/grub-mkconfig_lib ]; then
. /usr/lib/grub/grub-mkconfig_lib
else
# no grub file, so we notify and exit gracefully
echo "Cannot find grub config file, exiting." >&2
exit 0
fi
if [ -f /etc/default/grub ]; then
GRUB_DISABLE_MEMTEST=`sed -n 's/^GRUB_DISABLE_MEMTEST=\(.*\)/\1/p' < /etc/default/grub`
GRUB_MEMTEST_DISABLE_SERIAL=`sed -n 's/^GRUB_MEMTEST_DISABLE_SERIAL=\(.*\)/\1/p' < /etc/default/grub`
GRUB_MEMTEST_SERIAL_PARAMS=`sed -n 's/^GRUB_MEMTEST_SERIAL_PARAMS=\(.*\)/\1/p' < /etc/default/grub`
fi
if [ "x${GRUB_MEMTEST_SERIAL_PARAMS}" = "x" ] ; then
GRUB_MEMTEST_SERIAL_PARAMS="ttyS0,115200"
fi
# With GRUB_DISABLE_MEMTEST=true don't add memtest entries
if [ "x${GRUB_DISABLE_MEMTEST}" = "xtrue" ] ; then
exit 0
fi
# We can't cope with loop-mounted devices here.
case ${GRUB_DEVICE_BOOT} in
/dev/loop/*|/dev/loop[0-9]) exit 0 ;;
esac
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
efi_vars_dir=/sys/firmware/efi/efivars
if test -e ${efi_vars_dir} ; then
if test -e /boot/memtest86+x64.efi && test -e /boot/grub/x86_64-efi ; then
MEMTESTPATH=$( make_system_path_relative_to_its_root "/boot/memtest86+x64.efi" )
echo "Found memtest86+ 64bit EFI image: $MEMTESTPATH" >&2
cat << EOF
menuentry "Memory test (memtest86+x64.efi)" {
EOF
printf '%s\n' "${prepare_boot_cache}"
cat << EOF
linuxefi $MEMTESTPATH
}
EOF
if [ "x${GRUB_MEMTEST_DISABLE_SERIAL}" != "xtrue" ]; then
cat << EOF
menuentry '$(gettext_printf "Memory test (memtest86+x64.efi, serial console)")' {
EOF
printf '%s\n' "${prepare_boot_cache}"
cat << EOF
linuxefi $MEMTESTPATH console=${GRUB_MEMTEST_SERIAL_PARAMS}
}
EOF
fi
elif test -e /boot/memtest86+ia32.efi && test -e /boot/grub/i386-efi ; then
MEMTESTPATH=$( make_system_path_relative_to_its_root "/boot/memtest86+ia32.efi" )
echo "Found memtest86+ 32bit EFI image: $MEMTESTPATH" >&2
cat << EOF
menuentry "Memory test (memtest86+ia32.efi)" {
EOF
printf '%s\n' "${prepare_boot_cache}"
cat << EOF
linuxefi $MEMTESTPATH
}
EOF
if [ "x${GRUB_MEMTEST_DISABLE_SERIAL}" != "xtrue" ]; then
cat << EOF
menuentry '$(gettext_printf "Memory test (memtest86+ia32.efi, serial console)")' {
EOF
printf '%s\n' "${prepare_boot_cache}"
cat << EOF
linuxefi $MEMTESTPATH console=${GRUB_MEMTEST_SERIAL_PARAMS}
}
EOF
fi
fi
elif [ `getconf LONG_BIT` = "64" ]; then
if test -e /boot/memtest86+x64.bin ; then
MEMTESTPATH=$( make_system_path_relative_to_its_root "/boot/memtest86+x64.bin" )
echo "Found memtest86+x64 image: $MEMTESTPATH" >&2
cat << EOF
menuentry "Memory test (memtest86+x64.bin)" {
EOF
printf '%s\n' "${prepare_boot_cache}"
cat << EOF
linux $MEMTESTPATH
}
EOF
if [ "x${GRUB_MEMTEST_DISABLE_SERIAL}" != "xtrue" ]; then
cat << EOF
menuentry '$(gettext_printf "Memory test (memtest86+x64.bin, serial console)")' {
EOF
printf '%s\n' "${prepare_boot_cache}"
cat << EOF
linux $MEMTESTPATH console=${GRUB_MEMTEST_SERIAL_PARAMS}
}
EOF
fi
fi
else
if test -e /boot/memtest86+ia32.bin ; then
MEMTESTPATH=$( make_system_path_relative_to_its_root "/boot/memtest86+ia32.bin" )
echo "Found memtest86+ image: $MEMTESTPATH" >&2
cat << EOF
menuentry "Memory test (memtest86+ia32.bin)" {
EOF
printf '%s\n' "${prepare_boot_cache}"
cat << EOF
linux $MEMTESTPATH
}
EOF
if [ "x${GRUB_MEMTEST_DISABLE_SERIAL}" != "xtrue" ]; then
cat << EOF
menuentry '$(gettext_printf "Memory test (memtest86+ia32.bin, serial console)")' {
EOF
printf '%s\n' "${prepare_boot_cache}"
cat << EOF
linux $MEMTESTPATH console=${GRUB_MEMTEST_SERIAL_PARAMS}
}
EOF
fi
fi
fi
|