Chameleon

Chameleon Svn Source Tree

Root/branches/blackosx/package/Scripts/Install/SetActivePartition.sh

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

Archive Download this file

Revision: 1558