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