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