1 | #!/bin/bash␊ |
2 | ␊ |
3 | echo "==============================================="␊ |
4 | echo "Set Active Partition ONLY if Windows is not installed"␊ |
5 | echo "*****************************************************"␊ |
6 | ␊ |
7 | |
8 | # for example: ␊ |
9 | # efiformat code is 1 for HFS, 2 for MSDOS, 0 for unknown␊ |
10 | # diskSigCheck code is 1 for a Windows install, 0 for no Windows install␊ |
11 | ␊ |
12 | if [ "$#" -eq 5 ]; then␊ |
13 | ␉efiformat="$1"␊ |
14 | ␉diskSigCheck="$2"␊ |
15 | ␉targetDiskRaw="$3"␊ |
16 | ␉targetSlice="$4"␊ |
17 | ␉targetVolume="$5"␊ |
18 | ␊ |
19 | ␉echo "DEBUG: passed argument for efiformat = $efiformat"␊ |
20 | ␉echo "DEBUG: passed argument for diskSigCheck = $diskSigCheck"␊ |
21 | ␉echo "DEBUG: passed argument for targetDiskRaw = $targetDiskRaw"␊ |
22 | ␉echo "DEBUG: passed argument for targetSlice = $targetSlice"␊ |
23 | ␉echo "DEBUG: passed argument for targetVolume = $targetVolume"␊ |
24 | else␊ |
25 | ␉echo "Error - wrong number of values passed"␊ |
26 | ␉exit 9␊ |
27 | fi␊ |
28 | ␊ |
29 | if [ ${diskSigCheck} == "0" ]; then␊ |
30 | ␉echo "DEBUG: Windows is not installed so let's change the active partition"␊ |
31 | ␊ |
32 | ␉partitionactive=$( "${targetVolume}"/.Chameleon/i386/fdisk440 -d ${targetDiskRaw} | grep -n "*" | awk -F: '{print $1}')␊ |
33 | ␉echo "Current Active Partition: ${partitionactive}"␊ |
34 | ␊ |
35 | ␉if [ "${partitionactive}" = "${targetSlice}" ]; then␊ |
36 | ␉␉echo "${targetVolume} is already flagged as active"␊ |
37 | ␉else␊ |
38 | ␉␉echo "${targetVolume} is not flagged as active, so let's do it."␊ |
39 | ␉␉# BadAxe requires EFI partition to be flagged active.␊ |
40 | ␉␉# but it doesn't' hurt to do it for any non-windows partition.␊ |
41 | ␉␉␊ |
42 | ␉␉"${targetVolume}"/.Chameleon/i386/fdisk440 -e ${targetDiskRaw} <<-MAKEACTIVE␊ |
43 | ␉␉print␊ |
44 | ␉␉flag ${targetSlice}␊ |
45 | ␉␉write␊ |
46 | ␉␉y␊ |
47 | ␉␉quit␊ |
48 | ␉␉MAKEACTIVE␊ |
49 | ␉fi␊ |
50 | else␊ |
51 | ␉echo "Windows is installed so we let that remain the active partition"␊ |
52 | fi␊ |
53 | ␊ |
54 | echo "-----------------------------------------------"␊ |
55 | echo ""␊ |
56 | echo ""␊ |
57 | ␊ |
58 | exit 0␊ |
59 | ␊ |
60 | ␊ |
61 | ␊ |
62 | |