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