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