1 | #!/bin/bash␊ |
2 | ␊ |
3 | # loop through and un-mount ALL mounted 'EFI' system partitions - Thanks kizwan␊ |
4 | ␊ |
5 | # Receives targetVolumeChosenByUser: To write install log to.␊ |
6 | # Receives scriptDir: The location of the main script dir.␊ |
7 | ␊ |
8 | if [ "$#" -eq 2 ]; then␊ |
9 | ␉targetVolumeChosenByUser="$1"␊ |
10 | ␉scriptDir="$2"␊ |
11 | ␉# echo "DEBUG: passed argument for targetVolumeChosenByUser = $targetVolumeChosenByUser"␊ |
12 | ␉# echo "DEBUG: passed argument for scriptDir = $scriptDir"␊ |
13 | else␊ |
14 | ␉echo "Error - wrong number of values passed" >&2␊ |
15 | ␉exit 9␊ |
16 | fi␊ |
17 | ␊ |
18 | logName="@LOG_FILENAME@"␊ |
19 | logFile="${targetVolumeChosenByUser}/$logName"␊ |
20 | ␊ |
21 | exec >>"${logFile}" 2>&1␊ |
22 | ␊ |
23 | echo "Check for and unmount all volumes named EFI..."␊ |
24 | ␊ |
25 | # Count of 5 exists incase for some reason /Volumes/EFI fails␊ |
26 | # to be unmounted in which case the loop would run forever.␊ |
27 | attempts=1␊ |
28 | while [ "$( df | grep EFI )" ] && [ $attempts -lt 5 ]; do␊ |
29 | ␉#"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "Volume named 'EFI' is mounted..."␊ |
30 | ␉#"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "Unmounting $( df | grep EFI | awk '{print $1}' )"␊ |
31 | ␉echo "Volume named 'EFI' is mounted."␊ |
32 | ␉echo "Unmounting $( df | grep EFI | awk '{print $1}' )"␊ |
33 | ␉umount -f $( df | grep EFI | awk '{print $1}' )␊ |
34 | ␉(( attempts++ ))␊ |
35 | done␊ |
36 | if [ $attempts = 5 ]; then␊ |
37 | ␉"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "Failed to unmount 'EFI' System Partition."␊ |
38 | ␉exit 1␊ |
39 | fi␊ |
40 | ␊ |
41 | exit 0␊ |
42 | |