1 | #!/bin/bash␊ |
2 | ␊ |
3 | echo "==============================================="␊ |
4 | echo "Write Chameleon Stage 1 Loader:"␊ |
5 | echo "*******************************"␊ |
6 | ␊ |
7 | # espformat code is 1 for HFS, 2 for MSDOS, 0 for unknown␊ |
8 | ␊ |
9 | if [ "$#" -eq 6 ]; then␊ |
10 | ␉espformat="$1"␊ |
11 | ␉stage1LoaderHFS="$2"␊ |
12 | ␉stage1LoaderFAT="$3"␊ |
13 | ␉selectedDestination="$4"␊ |
14 | ␉targetDeviceRaw="$5"␊ |
15 | ␉targetVolume="$6"␊ |
16 | ␉echo "DEBUG: passed argument for espformat = $espformat"␊ |
17 | ␉echo "DEBUG: passed argument for stage1LoaderHFS = $stage1LoaderHFS"␊ |
18 | ␉echo "DEBUG: passed argument for stage1LoaderFAT = $stage1LoaderFAT"␊ |
19 | ␉echo "DEBUG: passed argument for selectedDestination = $selectedDestination"␊ |
20 | ␉echo "DEBUG: passed argument for targetDeviceRaw = $targetDeviceRaw"␊ |
21 | ␉echo "DEBUG: passed argument for targetVolume = $targetVolume"␊ |
22 | else␊ |
23 | ␉echo "Error - wrong number of values passed"␊ |
24 | ␉exit 9␊ |
25 | fi␊ |
26 | ␊ |
27 | if [ ${espformat} = "1" ]; then␊ |
28 | ␉# the selected partition is HFS formatted␊ |
29 | ␊ |
30 | ␉echo "Executing command: dd if=${selectedDestination}/.Chameleon/i386/${stage1LoaderHFS} of=${targetDeviceRaw}"␊ |
31 | ␉dd if="${selectedDestination}/.Chameleon/i386/${stage1LoaderHFS}" of=${targetDeviceRaw}␊ |
32 | fi␊ |
33 | ␊ |
34 | if [ ${espformat} = "2" ]; then␊ |
35 | ␉# the selected partition FAT formatted␊ |
36 | ␊ |
37 | ␉echo "Executing command: dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs"␊ |
38 | ␉dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs␊ |
39 | ␊ |
40 | ␉echo "Executing command: cp cp ${selectedDestination}/.Chameleon/i386/${stage1LoaderFAT} /tmp/newbs"␊ |
41 | ␉cp "${selectedDestination}"/.Chameleon/i386/${stage1LoaderFAT} /tmp/newbs␊ |
42 | ␊ |
43 | ␉echo "Executing command: dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc"␊ |
44 | ␉dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc␊ |
45 | ␊ |
46 | ␉echo "Executing command: dd of=${targetDeviceRaw} count=1 bs=512 if=/tmp/newbs"␊ |
47 | ␉dd if=/tmp/newbs of="${targetDeviceRaw}" count=1 bs=512␊ |
48 | ␊ |
49 | fi␊ |
50 | ␊ |
51 | echo "-----------------------------------------------"␊ |
52 | echo ""␊ |
53 | ␊ |
54 | exit 0␊ |
55 | ␊ |
56 | ␊ |
57 | ␊ |
58 | |