Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Enoch_Modules/package/Scripts/Sub/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 targetFormat: either hfs or msdos
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
18targetFormat="$1"
19stage1LoaderHFS="$2"
20stage1LoaderFAT="$3"
21selectedDestination="$4"
22targetDeviceRaw="$5"
23targetVolume="$6"
24scriptDir="$7"
25echo "DEBUG: passed argument for targetFormat = $targetFormat"
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 [ ${targetFormat} = "hfs" ]; then
38
39#echo "DEBUG: Executing command: dd if=${selectedDestination}/usr/standalone/i386/${stage1LoaderHFS} of=${targetDeviceRaw}"
40dd if="${selectedDestination}"/usr/standalone/i386/${stage1LoaderHFS} of=${targetDeviceRaw}
41
42"$scriptDir"InstallLog.sh "${targetVolume}" "Written ${stage1LoaderHFS} to ${targetDeviceRaw}."
43fi
44
45if [ ${targetFormat} = "msdos" ]; then
46
47#echo "DEBUG: Executing command: dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs"
48dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs
49
50#echo "DEBUG: Executing command: cp "${selectedDestination}"/usr/standalone/i386/${stage1LoaderFAT} /tmp/newbs"
51cp "${selectedDestination}"/usr/standalone/i386/${stage1LoaderFAT} /tmp/newbs
52
53#echo "DEBUG: Executing command: dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc"
54dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc
55
56#echo "DEBUG: Executing command: dd of=${targetDeviceRaw} count=1 bs=512 if=/tmp/newbs"
57dd if=/tmp/newbs of="${targetDeviceRaw}" count=1 bs=512
58
59"$scriptDir"InstallLog.sh "${targetVolume}" "Written ${stage1LoaderFAT} to ${targetDeviceRaw}."
60fi
61
62exit 0

Archive Download this file

Revision: 2238