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