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 | ␊ |
25 | fi␊ |
26 | ␊ |
27 | if [ ${diskSigCheck} == "0" ]; then␊ |
28 | ␉echo "DEBUG: Windows is not installed so let's change the active partition"␊ |
29 | ␊ |
30 | ␉partitionactive=$( "${targetVolume}"/.Chameleon/i386/fdisk440 -d ${targetDiskRaw} | grep -n "*" | awk -F: '{print $1}')␊ |
31 | ␉echo "Current Active Partition: ${partitionactive}"␊ |
32 | ␊ |
33 | ␉if [ "${partitionactive}" = "${targetSlice}" ]; then␊ |
34 | ␉␉echo "${targetVolume} is already flagged as active"␊ |
35 | ␉else␊ |
36 | ␉␉echo "${targetVolume} is not flagged as active, so let's do it."␊ |
37 | ␉␉# BadAxe requires EFI partition to be flagged active.␊ |
38 | ␉␉# but it doesn't' hurt to do it for any non-windows partition.␊ |
39 | ␉␉␊ |
40 | ␉␉"${targetVolume}"/.Chameleon/i386/fdisk440 -e ${targetDiskRaw} <<-MAKEACTIVE␊ |
41 | ␉␉print␊ |
42 | ␉␉flag ${targetSlice}␊ |
43 | ␉␉write␊ |
44 | ␉␉y␊ |
45 | ␉␉quit␊ |
46 | ␉␉MAKEACTIVE␊ |
47 | ␉fi␊ |
48 | else␊ |
49 | ␉echo "Windows is installed so we let that remain the active partition"␊ |
50 | fi␊ |
51 | ␊ |
52 | echo "-----------------------------------------------"␊ |
53 | echo ""␊ |
54 | echo ""␊ |
55 | ␊ |
56 | exit 0␊ |
57 | ␊ |
58 | ␊ |
59 | ␊ |
60 | |