1 | #!/bin/bash␊ |
2 | ␊ |
3 | echo "==============================================="␊ |
4 | echo "Set Active Partition ONLY if Windows is not installed"␊ |
5 | echo "*****************************************************"␊ |
6 | ␊ |
7 | # Sets partition active if Windows is not installed.␊ |
8 | ␊ |
9 | # Receives efiformat: code is 1 for HFS, 2 for MSDOS, 0 for unknown␊ |
10 | # Receives diskSigCheck: code is 1 for a Windows install, 0 for no Windows install␊ |
11 | # Receives targetDiskRaw: for example, /dev/rdisk1␊ |
12 | # Receives targetSlice: for example, 1␊ |
13 | # Receives targetVolume: Volume to install to.␊ |
14 | # Receives scriptDir: The location of the main script dir.␊ |
15 | ␊ |
16 | if [ "$#" -eq 6 ]; then␊ |
17 | ␉efiformat="$1"␊ |
18 | ␉diskSigCheck="$2"␊ |
19 | ␉targetDiskRaw="$3"␊ |
20 | ␉targetSlice="$4"␊ |
21 | ␉targetVolume="$5"␊ |
22 | ␉scriptDir="$6"␊ |
23 | ␊ |
24 | ␉echo "DEBUG: passed argument for efiformat = $efiformat"␊ |
25 | ␉echo "DEBUG: passed argument for diskSigCheck = $diskSigCheck"␊ |
26 | ␉echo "DEBUG: passed argument for targetDiskRaw = $targetDiskRaw"␊ |
27 | ␉echo "DEBUG: passed argument for targetSlice = $targetSlice"␊ |
28 | ␉echo "DEBUG: passed argument for targetVolume = $targetVolume"␊ |
29 | ␉echo "DEBUG: passed argument for scriptDir = $scriptDir"␊ |
30 | else␊ |
31 | ␉echo "Error - wrong number of values passed"␊ |
32 | ␉exit 9␊ |
33 | fi␊ |
34 | ␊ |
35 | # Append fdisk output to the installer log␊ |
36 | "$scriptDir"InstallLog.sh "${targetVolume}" "fdisk ${targetDiskRaw}"␊ |
37 | ␊ |
38 | if [ ${diskSigCheck} == "0" ]; then␊ |
39 | ␉#Windows is not installed so let's change the active partition"␊ |
40 | ␊ |
41 | ␉partitionactive=$( fdisk -d ${targetDiskRaw} | grep -n "*" | awk -F: '{print $1}')␊ |
42 | ␉if [ "${partitionactive}" ] && [ "${partitionactive}" = "${targetSlice}" ]; then␊ |
43 | ␉␉"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDiskRaw#/dev/r}, slice "${targetSlice}" is already set active. No need to change it."␊ |
44 | ␉else␊ |
45 | ␉␉"$scriptDir"InstallLog.sh "${targetVolume}" "Setting ${targetVolume} partition active."␊ |
46 | ␉␉# BadAxe requires EFI partition to be flagged active.␊ |
47 | ␉␉# but it doesn't' hurt to do it for any non-windows partition.␊ |
48 | ␊ |
49 | ␉␉fdisk -e ${targetDiskRaw} <<-MAKEACTIVE␊ |
50 | ␉␉print␊ |
51 | ␉␉flag ${targetSlice}␊ |
52 | ␉␉write␊ |
53 | ␉␉y␊ |
54 | ␉␉quit␊ |
55 | ␉␉MAKEACTIVE␊ |
56 | ␉fi␊ |
57 | else␊ |
58 | ␉# TO DO␊ |
59 | ␉# Add check to make sure that the active partition is actually the Windows partition␊ |
60 | ␉# before printing next statement.␊ |
61 | ␉#echo "DEBUG: Windows is installed so we let that remain the active partition"␊ |
62 | ␉"$scriptDir"InstallLog.sh "${targetVolume}" "Windows is installed so that can remain the active partition"␊ |
63 | fi␊ |
64 | ␊ |
65 | exit 0␊ |
66 | |