1 | #!/bin/bash␊ |
2 | ␊ |
3 | echo "==============================================="␊ |
4 | echo "Write Chameleon Stage 1 Loader:"␊ |
5 | echo "*******************************"␊ |
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 | ␊ |
17 | if [ "$#" -eq 7 ]; then␊ |
18 | ␉targetFormat="$1"␊ |
19 | ␉stage1LoaderHFS="$2"␊ |
20 | ␉stage1LoaderFAT="$3"␊ |
21 | ␉selectedDestination="$4"␊ |
22 | ␉targetDeviceRaw="$5"␊ |
23 | ␉targetVolume="$6"␊ |
24 | ␉scriptDir="$7"␊ |
25 | ␉echo "DEBUG: passed argument for targetFormat = $targetFormat"␊ |
26 | ␉echo "DEBUG: passed argument for stage1LoaderHFS = $stage1LoaderHFS"␊ |
27 | ␉echo "DEBUG: passed argument for stage1LoaderFAT = $stage1LoaderFAT"␊ |
28 | ␉echo "DEBUG: passed argument for selectedDestination = $selectedDestination"␊ |
29 | ␉echo "DEBUG: passed argument for targetDeviceRaw = $targetDeviceRaw"␊ |
30 | ␉echo "DEBUG: passed argument for targetVolume = $targetVolume"␊ |
31 | ␉echo "DEBUG: passed argument for scriptDir = $scriptDir"␊ |
32 | else␊ |
33 | ␉echo "Error - wrong number of values passed"␊ |
34 | ␉exit 9␊ |
35 | fi␊ |
36 | ␊ |
37 | if [ ${targetFormat} = "hfs" ]; then␊ |
38 | ␊ |
39 | ␉#echo "DEBUG: Executing command: dd if=${selectedDestination}/usr/standalone/i386/${stage1LoaderHFS} of=${targetDeviceRaw}"␊ |
40 | ␉dd if="${selectedDestination}"/usr/standalone/i386/${stage1LoaderHFS} of=${targetDeviceRaw}␊ |
41 | ␊ |
42 | ␉"$scriptDir"InstallLog.sh "${targetVolume}" "Written ${stage1LoaderHFS} to ${targetDeviceRaw}."␊ |
43 | fi␊ |
44 | ␊ |
45 | if [ ${targetFormat} = "msdos" ]; then␊ |
46 | ␊ |
47 | ␉#echo "DEBUG: Executing command: dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs"␊ |
48 | ␉dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs␊ |
49 | ␊ |
50 | ␉#echo "DEBUG: Executing command: cp "${selectedDestination}"/usr/standalone/i386/${stage1LoaderFAT} /tmp/newbs"␊ |
51 | ␉cp "${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"␊ |
54 | ␉dd 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"␊ |
57 | ␉dd if=/tmp/newbs of="${targetDeviceRaw}" count=1 bs=512␊ |
58 | ␊ |
59 | ␉"$scriptDir"InstallLog.sh "${targetVolume}" "Written ${stage1LoaderFAT} to ${targetDeviceRaw}."␊ |
60 | fi␊ |
61 | ␊ |
62 | exit 0 |