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: To write install log to.␊ |
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 | ␉"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "Volume named 'EFI' is mounted..."␊ |
27 | ␉"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "Unmounting $( df | grep EFI | awk '{print $1}' )"␊ |
28 | ␉umount -f $( df | grep EFI | awk '{print $1}' )␊ |
29 | ␉(( attempts++ ))␊ |
30 | done␊ |
31 | if [ $attempts = 5 ]; then␊ |
32 | ␉"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "Failed to unmount 'EFI' System Partition."␊ |
33 | ␉exit 1␊ |
34 | fi␊ |
35 | ␊ |
36 | exit 0␊ |
37 | ␊ |
38 | ␊ |
39 | ␊ |
40 | |