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