Chameleon

Chameleon Svn Source Tree

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

  • Property svn:executable set to *
1#!/bin/bash
2
3echo "==============================================="
4echo "Write Chameleon Stage 1 Loader:"
5echo "*******************************"
6
7# Writes Chameleon stage 1 loader.
8
9# Receives espformat: 1 for HFS, 2 for MSDOS, 0 for unknown
10# Receives stage1LoaderHFS: Name of file - boot1h
11# Receives stage1LoaderFAT: Name of file - boot1f32
12# Receives selectedDestination: for example, /Volumes/USB
13# Receives targetDeviceRaw: for example, /dev/disk3s1
14# Receives targetVolume: for example, /Volumes/USB
15# Receives scriptDir: The location of the main script dir.
16
17if [ "$#" -eq 7 ]; then
18espformat="$1"
19stage1LoaderHFS="$2"
20stage1LoaderFAT="$3"
21selectedDestination="$4"
22targetDeviceRaw="$5"
23targetVolume="$6"
24scriptDir="$7"
25echo "DEBUG: passed argument for espformat = $espformat"
26echo "DEBUG: passed argument for stage1LoaderHFS = $stage1LoaderHFS"
27echo "DEBUG: passed argument for stage1LoaderFAT = $stage1LoaderFAT"
28echo "DEBUG: passed argument for selectedDestination = $selectedDestination"
29echo "DEBUG: passed argument for targetDeviceRaw = $targetDeviceRaw"
30echo "DEBUG: passed argument for targetVolume = $targetVolume"
31echo "DEBUG: passed argument for scriptDir = $scriptDir"
32else
33echo "Error - wrong number of values passed"
34exit 9
35fi
36
37if [ ${espformat} = "1" ]; then
38# the selected partition is HFS formatted
39
40echo "Executing command: dd if=${selectedDestination}/usr/standalone/i386/${stage1LoaderHFS} of=${targetDeviceRaw}"
41dd if="${selectedDestination}"/usr/standalone/i386/${stage1LoaderHFS} of=${targetDeviceRaw}
42
43"$scriptDir"InstallLog.sh "${targetVolume}" "Written ${stage1LoaderHFS} to ${targetDeviceRaw}."
44fi
45
46if [ ${espformat} = "2" ]; then
47# the selected partition FAT formatted
48
49echo "Executing command: dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs"
50dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs
51
52echo "Executing command: cp "${selectedDestination}"/usr/standalone/i386/${stage1LoaderFAT} /tmp/newbs"
53cp "${selectedDestination}"/usr/standalone/i386/${stage1LoaderFAT} /tmp/newbs
54
55echo "Executing command: dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc"
56dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc
57
58echo "Executing command: dd of=${targetDeviceRaw} count=1 bs=512 if=/tmp/newbs"
59dd if=/tmp/newbs of="${targetDeviceRaw}" count=1 bs=512
60
61"$scriptDir"InstallLog.sh "${targetVolume}" "Written ${stage1LoaderFAT} to ${targetDeviceRaw}."
62fi
63
64echo "-----------------------------------------------"
65echo ""
66
67exit 0

Archive Download this file

Revision: 1545