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 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 | ␊ |
17 | if [ "$#" -eq 7 ]; then␊ |
18 | ␉espformat="$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 espformat = $espformat"␊ |
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 [ ${espformat} = "1" ]; then␊ |
38 | ␉# the selected partition is HFS formatted␊ |
39 | ␊ |
40 | ␉echo "Executing command: dd if=${selectedDestination}/usr/standalone/i386/${stage1LoaderHFS} of=${targetDeviceRaw}"␊ |
41 | ␉dd if="${selectedDestination}"/usr/standalone/i386/${stage1LoaderHFS} of=${targetDeviceRaw}␊ |
42 | ␊ |
43 | ␉"$scriptDir"InstallLog.sh "${targetVolume}" "Written ${stage1LoaderHFS} to ${targetDeviceRaw}."␊ |
44 | fi␊ |
45 | ␊ |
46 | if [ ${espformat} = "2" ]; then␊ |
47 | ␉# the selected partition FAT formatted␊ |
48 | ␊ |
49 | ␉echo "Executing command: dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs"␊ |
50 | ␉dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs␊ |
51 | ␊ |
52 | ␉echo "Executing command: cp "${selectedDestination}"/usr/standalone/i386/${stage1LoaderFAT} /tmp/newbs"␊ |
53 | ␉cp "${selectedDestination}"/usr/standalone/i386/${stage1LoaderFAT} /tmp/newbs␊ |
54 | ␊ |
55 | ␉echo "Executing command: dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc"␊ |
56 | ␉dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc␊ |
57 | ␊ |
58 | ␉echo "Executing command: dd of=${targetDeviceRaw} count=1 bs=512 if=/tmp/newbs"␊ |
59 | ␉dd if=/tmp/newbs of="${targetDeviceRaw}" count=1 bs=512␊ |
60 | ␊ |
61 | ␉"$scriptDir"InstallLog.sh "${targetVolume}" "Written ${stage1LoaderFAT} to ${targetDeviceRaw}."␊ |
62 | fi␊ |
63 | ␊ |
64 | echo "-----------------------------------------------"␊ |
65 | echo ""␊ |
66 | ␊ |
67 | exit 0 |