Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Enoch_Modules/package/Scripts/Sub/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 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
15if [ "$#" -eq 5 ]; then
16diskSigCheck="$1"
17targetDiskRaw="$2"
18targetSlice="$3"
19targetVolume="$4"
20scriptDir="$5"
21
22echo "DEBUG: passed argument for diskSigCheck = $diskSigCheck"
23echo "DEBUG: passed argument for targetDiskRaw = $targetDiskRaw"
24echo "DEBUG: passed argument for targetSlice = $targetSlice"
25echo "DEBUG: passed argument for targetVolume = $targetVolume"
26echo "DEBUG: passed argument for scriptDir = $scriptDir"
27else
28echo "Error - wrong number of values passed"
29exit 9
30fi
31
32# Append fdisk output to the installer log
33"$scriptDir"InstallLog.sh "${targetVolume}" "fdisk ${targetDiskRaw}"
34
35if [ ${diskSigCheck} == "0" ]; then
36#Windows is not installed so let's change the active partition"
37
38partitionactive=$( fdisk -d ${targetDiskRaw} | grep -n "*" | awk -F: '{print $1}')
39if [ "${partitionactive}" ] && [ "${partitionactive}" = "${targetSlice}" ]; then
40"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDiskRaw#/dev/r}, slice "${targetSlice}" is already set active. No need to change it."
41else
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
46fdisk -e ${targetDiskRaw} <<-MAKEACTIVE
47print
48flag ${targetSlice}
49write
50y
51quit
52MAKEACTIVE
53fi
54else
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"
60fi
61
62exit 0

Archive Download this file

Revision: 2238