-
Notifications
You must be signed in to change notification settings - Fork 0
/
installMemtest.sh
79 lines (62 loc) · 2.05 KB
/
installMemtest.sh
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
#!/bin/sh
installPath=$1
memtest86url='https://www.memtest86.com/downloads/memtest86-usb.zip'
if [ $# -lt 1 ]; then
echo -e "Error! Usage:\n $(basename $0) /install/path"
exit 1
fi
# Check if memtest already installed
uefiBinFile=$installPath/uefi/BOOTX64.efi
biosBinFile=$installPath/bios/memtest86.bin
createDirs() {
echo "Download and unpack Memtest86 for BIOS and UEFI"
echo -e "\nMemetest path - $installPath\n"
echo "Create memtest directory"
mkdir -p $installPath/uefi $installPath/bios
}
installMemtestUefi() {
# memtest for UEFI
echo -e "\nCreate temp directory"
mkdir -p $installPath/temp/img
echo -e "\nDownload Memtest86 for UEFI"
wget $memtest86url -O $installPath/temp/memtest86-usb.zip
echo -e "\nUnpack Memtest86 for UEFI"
unzip $installPath/temp/memtest86-usb.zip memtest86-usb.img -d $installPath/temp/
echo -e "\n\nMount Memtest86 for UEFI image"
START_SECTOR=$(fdisk -lu $installPath/temp/memtest86-usb.img | grep "MemTest86" | awk '{print $2}')
SIZE_SECTOR=$(fdisk -lu $installPath/temp/memtest86-usb.img | grep "Logical sector size:" | awk '{print $4}')
mount -o loop,offset=$(($START_SECTOR * $SIZE_SECTOR)) $installPath/temp/memtest86-usb.img $installPath/temp/img
echo -e "\nCopy Memtest86 for UEFI EFI files"
cp -v $installPath/temp/img/EFI/BOOT/BOOTX64.efi $installPath/uefi/BOOTX64.efi
# cp -v $installPath/temp/img/EFI/BOOT/blacklist.cfg $installPath/uefi/blacklist.cfg
echo -e "\nUnmount Memtest86 for UEFI image"
umount $installPath/temp/img
}
installMemtestBios() {
# memtest for BIOS
echo "Copy Memtest86 for BIOS BIN file"
cp -v /sourceDir/memtest86+.bin $installPath/bios/memtest86.bin
}
cleanUp() {
echo -e "\nDelete temp directory"
rm -rv $installPath/temp/
}
report() {
echo -e "\nMemtest86 files:"
find $installPath/ -type f
}
# ---
createDirs
if [ ! -f $uefiBinFile ] ; then
installMemtestUefi
cleanUp
else
echo -e "\nMemtest86 UEFI Already installed\n"
fi
if [ ! -f $biosBinFile ] ; then
installMemtestBios
else
echo -e "\nMemtest86 BIOS Already installed\n"
fi
report
exit 0