Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Trunk/package/Scripts/Sub/WriteChameleonStage2.sh

  • Property svn:executable set to *
1#!/bin/bash
2
3echo "==============================================="
4echo "Write Chameleon Stage 2 Loader:"
5echo "*******************************"
6
7# Writes Chameleon stage 2 loader.
8
9# Receives espformat: 1 for HFS, 2 for MSDOS, 0 for unknown
10# Receives stage2Loader: Name of file - boot
11# Receives selectedDestination: for example, /Volumes/ChameleonBootUSB (or /Volumes/EFI if ESP install).
12# Receives targetDevice: for example, /dev/disk3s1
13# Receives targetVolume: for example, /Volumes/ChameleonBootUSB
14# Receives scriptDir: The location of the main script dir.
15
16
17if [ "$#" -eq 6 ]; then
18espformat="$1"
19stage2Loader="$2"
20selectedDestination="$3"
21targetDevice="$4"
22targetVolume="$5"
23scriptDir="$6"
24echo "DEBUG: passed argument for espformat = $espformat"
25echo "DEBUG: passed argument for stage2Loader = $stage2Loader"
26echo "DEBUG: passed argument for selectedDestination = $selectedDestination"
27echo "DEBUG: passed argument for targetDevice = $targetDevice"
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# check to see if install to EFI system partition was selected
36if [ "${selectedDestination}" = "/Volumes/EFI" ]; then
37#echo "DEBUG: EFI install chosen"
38
39if [ ! -d "${selectedDestination}" ]; then
40#echo "DEBUG: Executing Command: mkdir -p ${selectedDestination}"
41mkdir -p "${targetVolume}"
42#else
43#echo "DEBUG: folder /Volumes/EFI already exists"
44fi
45
46#if the EFI system partition was selected then
47# mount '/Volumes/EFI' with the correct format type
48
49if [ ${espformat} = 1 ]; then
50
51#echo "Executing command: mount_hfs ${targetDevice} ${targetVolume}"
52"$scriptDir"InstallLog.sh "${targetVolume}" "Mounting ${targetDevice} as ${selectedDestination}"
53mount_hfs "${targetDevice}" "${selectedDestination}"
54fi
55if [ ${espformat} = 2 ]; then
56[ -d "${selectedDestination}" ] || mkdir -p "${selectedDestination}"
57#echo "Executing command: mount_msdos -u 0 -g 0 ${targetDevice} ${selectedDestination}"
58"$scriptDir"InstallLog.sh "${targetVolume}" "Mounting ${targetDevice} as ${selectedDestination}"
59mount_msdos -u 0 -g 0 "${targetDevice}" "${selectedDestination}"
60fi
61
62#echo "DEBUG: Executing command: cp "${targetVolume}"/usr/standalone/i386/${stage2Loader} ${selectedDestination}"
63cp "${targetVolume}"/usr/standalone/i386/"${stage2Loader}" "${selectedDestination}"
64"$scriptDir"InstallLog.sh "${targetVolume}" "Written boot to ${selectedDestination}."
65else
66#echo "DEBUG: Executing command: cp "${targetVolume}"/usr/standalone/i386/${stage2Loader} ${targetVolume}"
67cp "${targetVolume}"/usr/standalone/i386/"${stage2Loader}" "${targetVolume}"
68"$scriptDir"InstallLog.sh "${targetVolume}" "Written boot to ${targetVolume} on ${targetDevice}."
69fi
70
71
72#if [ -f "${selectedDestination}"/.Chameleon/nullhideboot ]; then
73#echo "Executing command: SetFile -a V ${targetVolume}/${stage2Loader}"
74#"${selectedDestination}"/.Chameleon/Resources/SetFile -a V "${targetVolume}"/"${stage2Loader}"
75#fi
76
77exit 0
78

Archive Download this file

Revision: 1622