1 | #!/bin/bash␊ |
2 | ␊ |
3 | echo "==============================================="␊ |
4 | echo "Check Proceed: Can the script continue?"␊ |
5 | echo "***************************************"␊ |
6 | ␊ |
7 | # Checks the selected volume is present and the disk is partitioned.␊ |
8 | ␊ |
9 | # Receives targetVolume: Volume to install to (Will be '/Volumes/EFI' if EFI install)␊ |
10 | # Receives targetDevice: Stores device number, for example /dev/disk2s1.␊ |
11 | # Receives installerVolume: Volume to write the installer log to.␊ |
12 | # Receives scriptDir: The location of the main script dir.␊ |
13 | ␊ |
14 | if [ "$#" -eq 4 ]; then␊ |
15 | ␉targetVolume="$1"␊ |
16 | ␉targetDevice="$2"␊ |
17 | ␉installerVolume="$3"␊ |
18 | ␉scriptDir="$4"␊ |
19 | ␉echo "DEBUG: passed argument for targetVolume = $targetVolume"␊ |
20 | ␉echo "DEBUG: passed argument for targetDevice = $targetDevice"␊ |
21 | ␉echo "DEBUG: passed argument for installerVolume = $installerVolume"␊ |
22 | ␉echo "DEBUG: passed argument for scriptDir = $scriptDir"␊ |
23 | else␊ |
24 | ␉echo "Error - wrong number of values passed"␊ |
25 | ␉exit 9␊ |
26 | fi␊ |
27 | ␊ |
28 | if [ -z "$targetVolume" ]; then␊ |
29 | ␉echo "*** Cannot find the volume. Exiting."␊ |
30 | ␉"$scriptDir"InstallLog.sh "${installerVolume}" "FAIL: Cannot file the volume: $targetVolume."␊ |
31 | ␉exit 1␊ |
32 | else␊ |
33 | ␉echo "Confirming target volume exists"␊ |
34 | fi␊ |
35 | ␊ |
36 | if [ "$targetDevice" = "$targetDevice#*disk*s" ]; then␊ |
37 | ␉echo "*** ERROR Volume does not use slices. Exiting."␊ |
38 | ␉"$scriptDir"InstallLog.sh "${installerVolume}" "FAIL: $targetVolume doesn't use slices."␊ |
39 | ␉exit 1␉␉␊ |
40 | else␊ |
41 | ␉echo "Confirming target device uses slices"␊ |
42 | fi␊ |
43 | ␊ |
44 | # Add check for installing to a 'small' HFS device like a␊ |
45 | # 1GB USB flash drive which won't have an EFI System Partition.␊ |
46 | ␊ |
47 | if [ "$targetVolume" = "/Volumes/EFI" ]; then␊ |
48 | ␉# Take target device and check slice 1 matches partition named "EFI"␊ |
49 | ␉stripped=$( echo ${targetDevice#/dev/} )␊ |
50 | ␉if [ ! $(echo ${stripped#*disk*s}) = 1 ]; then␊ |
51 | ␉␉stripped=$( echo ${stripped%s*})"s1"␊ |
52 | ␉fi␊ |
53 | ␉if [ ! $( diskutil list | grep ${stripped} | awk {'print $2'} ) = "EFI" ]; then␊ |
54 | ␉␉echo "*** The selected volume doesn't have an EFI System Partition. Exiting."␊ |
55 | ␉␉"$scriptDir"InstallLog.sh "${installerVolume}" "FAIL: Selected disk does not have an EFI System Partition."␊ |
56 | ␉␉exit 1␊ |
57 | ␉fi␊ |
58 | fi␊ |
59 | ␊ |
60 | echo "-----------------------------------------------"␊ |
61 | echo ""␊ |
62 | ␊ |
63 | #"$scriptDir"InstallLog.sh "${installerVolume}" "CheckProceed: PASS"␊ |
64 | ␊ |
65 | exit 0 |