90 lines
3.1 KiB
Bash
90 lines
3.1 KiB
Bash
#!/bin/sh
|
|
|
|
# pcmemtest-install - Script to install PCMemTest
|
|
#
|
|
# Written in 2022 by Márcio Silva <coadde@hyperbola.info>
|
|
#
|
|
# To the extent possible under law, the author(s) have dedicated all copyright
|
|
# and related and neighboring rights to this software to the public domain
|
|
# worldwide. This software is distributed without any warranty.
|
|
#
|
|
# You should have received a copy of the CC0 Public Domain Dedication along
|
|
# with this software. If not, see
|
|
# <https://creativecommons.org/publicdomain/zero/1.0/>.
|
|
|
|
if [ "${UID}" != '0' ] || [ "${USER}" != 'root' ]; then
|
|
printf 'Only "root" user can install PCMemTest.\n'
|
|
return 1
|
|
fi
|
|
|
|
case "${1}" in
|
|
'bios')
|
|
install -Dm '644' '/usr/share/pcmemtest/memtest.bin' -t \
|
|
'/boot/pcmemtest'
|
|
;;
|
|
'uefi')
|
|
_SOURCE="$(findmnt -n -o 'source' '/boot/efi')"
|
|
if [ -f '/usr/share/pcmemtest/bootia32.efi' ]; then
|
|
install -Dm '644' '/usr/share/pcmemtest/bootia32.efi' -t \
|
|
'/boot/efi/efi/PCMemTest'
|
|
efibootmgr -c -d "${_SOURCE}" \
|
|
-l '\\efi\PCMemTest\bootia32.efi' -L 'PCMemTest (IA32)' -v
|
|
fi
|
|
if [ -f '/usr/share/pcmemtest/bootx64.efi' ]; then
|
|
install -Dm '644' '/usr/share/pcmemtest/bootx64.efi' -t \
|
|
'/boot/efi/efi/PCMemTest'
|
|
efibootmgr -c -d "${_SOURCE}" \
|
|
-l '\\efi\PCMemTest\bootx64.efi' -L 'PCMemTest' -v
|
|
fi
|
|
;;
|
|
'uefi-in-boot')
|
|
_SOURCE="$(findmnt -n -o 'source' '/boot/efi')"
|
|
if [ -f '/usr/share/pcmemtest/bootia32.efi' ]; then
|
|
install -Dm '644' '/usr/share/pcmemtest/bootia32.efi' -t \
|
|
'/boot/efi/PCMemTest'
|
|
efibootmgr -c -d "${_SOURCE}" \
|
|
-l '\\efi\PCMemTest\bootia32.efi' -L 'PCMemTest (IA32)' -v
|
|
fi
|
|
if [ -f '/usr/share/pcmemtest/bootx64.efi' ]; then
|
|
install -Dm '644' '/usr/share/pcmemtest/bootx64.efi' -t \
|
|
'/boot/efi/PCMemTest'
|
|
efibootmgr -c -d "${_SOURCE}" \
|
|
-l '\\efi\PCMemTest\bootx64.efi' -L 'PCMemTest' -v
|
|
fi
|
|
;;
|
|
'both-in-boot')
|
|
install -Dm '644' '/usr/share/pcmemtest/memtest.bin' -t \
|
|
'/boot/pcmemtest'
|
|
_SOURCE="$(findmnt -n -o 'source' '/boot/efi')"
|
|
if [ -f '/usr/share/pcmemtest/bootia32.efi' ]; then
|
|
install -Dm '644' '/usr/share/pcmemtest/bootia32.efi' -t \
|
|
'/boot/efi/PCMemTest'
|
|
efibootmgr -c -d "${_SOURCE}" \
|
|
-l '\\efi\PCMemTest\bootia32.efi' -L 'PCMemTest (IA32)' -v
|
|
fi
|
|
if [ -f '/usr/share/pcmemtest/bootx64.efi' ]; then
|
|
install -Dm '644' '/usr/share/pcmemtest/bootx64.efi' -t \
|
|
'/boot/efi/PCMemTest'
|
|
efibootmgr -c -d "${_SOURCE}" \
|
|
-l '\\efi\PCMemTest\bootx64.efi' -L 'PCMemTest' -v
|
|
fi
|
|
;;
|
|
*|'both')
|
|
install -Dm '644' '/usr/share/pcmemtest/memtest.bin' -t \
|
|
'/boot/pcmemtest'
|
|
_SOURCE="$(findmnt -n -o 'source' '/boot/efi')"
|
|
if [ -f '/usr/share/pcmemtest/bootia32.efi' ]; then
|
|
install -Dm '644' '/usr/share/pcmemtest/bootia32.efi' -t \
|
|
'/boot/efi/efi/PCMemTest'
|
|
efibootmgr -c -d "${_SOURCE}" \
|
|
-l '\\efi\PCMemTest\bootia32.efi' -L 'PCMemTest (IA32)' -v
|
|
fi
|
|
if [ -f '/usr/share/pcmemtest/bootx64.efi' ]; then
|
|
install -Dm '644' '/usr/share/pcmemtest/bootx64.efi' -t \
|
|
'/boot/efi/efi/PCMemTest'
|
|
efibootmgr -c -d "${_SOURCE}" \
|
|
-l '\\efi\PCMemTest\bootx64.efi' -L 'PCMemTest' -v
|
|
fi
|
|
;;
|
|
esac
|