summarylogtreecommitdiffstats
path: root/memtest86-efi
diff options
context:
space:
mode:
authorXorg2022-02-01 20:27:46 +0100
committerXorg2022-02-01 20:27:46 +0100
commitc82a3e48c20184e0d8856163a0c81af6d04141f3 (patch)
tree1172ea71e9ff57b6845f8f75e36888beaf19a36d /memtest86-efi
parent600ab3bcaead591e7f27e833789a27ab3c5d2803 (diff)
downloadaur-c82a3e48c20184e0d8856163a0c81af6d04141f3.tar.gz
Script: always try to mount ESP during update or remove
Diffstat (limited to 'memtest86-efi')
-rw-r--r--memtest86-efi43
1 files changed, 24 insertions, 19 deletions
diff --git a/memtest86-efi b/memtest86-efi
index 31233da3061a..b9ea6bfdfd2b 100644
--- a/memtest86-efi
+++ b/memtest86-efi
@@ -52,9 +52,22 @@ promptuser() {
[[ -n "$newvalue" ]] && echo "$newvalue" || echo "$defaultvalue"
}
+_mount_esp() {
+ local partition="$1"
+ local esp="$2"
+
+ if ! mount | grep "$partition" | grep -q "$esp"; then
+ echo -e "ESP ${CB}$partition${CR} is not mounted, mounting..."
+ if ! mount "$partition" "$esp"; then
+ echo -e "${CE}Fail to mount $partition on $esp. Aborted.${CR}" > /dev/stderr
+ exit $CODE_FATAL
+ fi
+ fi
+}
+
_common_install() {
- efidir="$1"
- efifile="$2"
+ local efidir="$1"
+ local efifile="$2"
echo -e "MemTest86 is installed into ${CB}$efidir/${CR} directory."
mkdir -pv "$efidir"
@@ -63,7 +76,7 @@ _common_install() {
}
_write_grub_cfg() {
- uuid="$1"
+ local uuid="$1"
cat > "/etc/grub.d/86_memtest" <<FOE
#!/bin/sh
@@ -125,14 +138,8 @@ install() {
fi
esp=$(promptuser "$esp")
- # Check if ESP is mounted
- if ! mount | grep "$partition" | grep -q "$esp"; then
- echo -e "ESP ${CB}$partition${CR} is not mounted, mounting..."
- if ! mount "$partition" "$esp"; then
- echo -e "${CE}Fail to mount $partition on $esp. Aborted.${CR}" > /dev/stderr
- exit $CODE_FATAL
- fi
- fi
+ # Check if ESP is mounted or mount it otherwise
+ _mount_esp "$partition" "$esp"
echo -e "The target is: ${CB}$partition${CR} (mounted on ${CB}$esp${CR}).\n"
# Get user choice
@@ -205,20 +212,15 @@ update() {
exit $CODE_USAGE
fi
+ # Check if ESP is mounted or mount it otherwise
+ _mount_esp "$partition" "$esp"
+
case $choice in
1) # Update files in $esp/
_common_install "$esp" "shell$ARCH.efi"
;;
2|3|4) # Update files in $esp/EFI/memtest86/
- ## Check if efi partition is mounted, if not mount it
- if ! mount | grep "$partition" | grep -q "$esp"; then
- echo -e "ESP ${CB}$partition${CR} is not mounted, mounting..."
- if ! mount "$partition" "$esp"; then
- echo -e "${CE}Fail to mount $partition on $esp. Aborted.${CR}" > /dev/stderr
- exit $CODE_FATAL
- fi
- fi
_common_install "$esp/EFI/memtest86" "memtest$ARCH.efi"
;;
esac
@@ -232,6 +234,9 @@ remove() {
exit $CODE_USAGE
fi
+ # Check if ESP is mounted or mount it otherwise
+ _mount_esp "$partition" "$esp"
+
case $choice in
1) # Remove files in $esp/
echo -e "MemTest86 will be removed from ${CB}$esp/${CR}."