Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- set -e
- if [ -f /usr/lib/grub/grub-mkconfig_lib ]; then
- . /usr/lib/grub/grub-mkconfig_lib
- LX=linux16
- elif [ -f /usr/lib/grub/update-grub_lib ]; then
- . /usr/lib/grub/update-grub_lib
- LX=linux
- else
- # no grub file, so we notify and exit gracefully
- echo "Cannot find grub config file, exiting." >&2
- exit 0
- fi
- # We need 16-bit boot, which isn't available on EFI.
- if [ -d /sys/firmware/efi ]; then
- echo "Memtest86+ needs a 16-bit boot, that is not available on EFI, 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_ENABLE_MULTIBOOT=`sed -n 's/^GRUB_MEMTEST_ENABLE_MULTIBOOT=\(.*\)/\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,115200n8"
- 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
- export TEXTDOMAIN=memtest86+
- prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
- if test -e /boot/memtest86+.elf ; then
- MEMTESTPATH=$( make_system_path_relative_to_its_root "/boot/memtest86+.elf" )
- echo "Found memtest86+ image: $MEMTESTPATH" >&2
- cat << EOF
- menuentry '$(gettext_printf "Memory test (memtest86+.elf)")' {
- EOF
- printf '%s\n' "${prepare_boot_cache}"
- cat << EOF
- knetbsd $MEMTESTPATH
- }
- EOF
- fi
- if [ "x${GRUB_MEMTEST_DISABLE_SERIAL}" != "xtrue" -a -e /boot/memtest86+.bin ]; then
- MEMTESTPATH=$( make_system_path_relative_to_its_root "/boot/memtest86+.bin" )
- echo "Found memtest86+ image: $MEMTESTPATH" >&2
- cat << EOF
- menuentry '$(gettext_printf "Memory test (memtest86+.bin, serial console)")' {
- EOF
- printf '%s\n' "${prepare_boot_cache}"
- cat << EOF
- $LX $MEMTESTPATH console=${GRUB_MEMTEST_SERIAL_PARAMS}
- }
- EOF
- fi
- if [ "x${GRUB_MEMTEST_ENABLE_MULTIBOOT}" = "xtrue" -a -e /boot/memtest86+_multiboot.bin ]; then
- MEMTESTPATH=$( make_system_path_relative_to_its_root "/boot/memtest86+_multiboot.bin" )
- echo "Found memtest86+ multiboot image: $MEMTESTPATH" >&2
- cat << EOF
- menuentry '$(gettext_printf "Memory test (memtest86+, experimental multiboot)")' {
- EOF
- printf '%s\n' "${prepare_boot_cache}"
- cat << EOF
- multiboot $MEMTESTPATH
- }
- EOF
- if [ "x${GRUB_MEMTEST_DISABLE_SERIAL}" != "xtrue" ]; then
- cat << EOF
- menuentry '$(gettext_printf "Memory test (memtest86+, serial console, experimental multiboot)")' {
- EOF
- printf '%s\n' "${prepare_boot_cache}"
- cat << EOF
- multiboot $MEMTESTPATH console=${GRUB_MEMTEST_SERIAL_PARAMS}
- }
- EOF
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment