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
35# Append fdisk output to the installer log
36"$scriptDir"InstallLog.sh "${targetVolume}" "fdisk ${targetDiskRaw}"
37
38if [ ${diskSigCheck} == "0" ]; then
39#Windows is not installed so let's change the active partition"
40
41partitionactive=$( fdisk -d ${targetDiskRaw} | grep -n "*" | awk -F: '{print $1}')
42if [ "${partitionactive}" ] && [ "${partitionactive}" = "${targetSlice}" ]; then
43"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDiskRaw#/dev/r}, slice "${targetSlice}" is already set active. No need to change it."
44else
45"$scriptDir"InstallLog.sh "${targetVolume}" "Setting ${targetVolume} partition active."
46# BadAxe requires EFI partition to be flagged active.
47# but it doesn't' hurt to do it for any non-windows partition.
48
49fdisk -e ${targetDiskRaw} <<-MAKEACTIVE
50print
51flag ${targetSlice}
52write
53y
54quit
55MAKEACTIVE
56fi
57else
58# TO DO
59# Add check to make sure that the active partition is actually the Windows partition
60# before printing next statement.
61#echo "Windows is installed so we let that remain the active partition"
62"$scriptDir"InstallLog.sh "${targetVolume}" "Windows is installed so that can remain the active partition"
63fi
64
65echo "-----------------------------------------------"
66echo ""
67echo ""
68
69exit 0

Archive Download this file

Revision: 1563