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 | fi␊ |
23 | ␊ |
24 | if [ ${espformat} = "1" ]; then␊ |
25 | ␉# the selected partition is HFS formatted␊ |
26 | ␊ |
27 | ␉echo "Executing command: dd if=${selectedDestination}/.Chameleon/i386/${stage1LoaderHFS} of=${targetDeviceRaw}"␊ |
28 | ␉dd if="${selectedDestination}/.Chameleon/i386/${stage1LoaderHFS}" of=${targetDeviceRaw}␊ |
29 | fi␊ |
30 | ␊ |
31 | if [ ${espformat} = "2" ]; then␊ |
32 | ␉# the selected partition FAT formatted␊ |
33 | ␊ |
34 | ␉# check to see if install to EFI system partition was selected␊ |
35 | ␉# if chosen, the package installer will add a file named 'nullESP'␊ |
36 | ␉# in to the temporary directory /.Chameleon␊ |
37 | ␊ |
38 | ␉#if [ -f ${selectedDestination}/.Chameleon/nullESP ]; then␊ |
39 | ␉␉echo "Executing command: dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs"␊ |
40 | ␉␉dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs␊ |
41 | ␊ |
42 | ␉␉echo "Executing command: cp /.Chameleon/i386/${stage1LoaderFAT} /tmp/newbs"␊ |
43 | ␉␉cp ${selectedDestination}/.Chameleon/i386/${stage1LoaderFAT} /tmp/newbs␊ |
44 | ␊ |
45 | ␉␉echo "Executing command: dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc"␊ |
46 | ␉␉dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc␊ |
47 | ␊ |
48 | ␉␉echo "Executing command: dd of=${targetDeviceRaw} count=1 bs=512 if=/tmp/newbs"␊ |
49 | ␉␉dd if=/tmp/newbs of="${targetDeviceRaw}" count=1 bs=512␊ |
50 | ␉#else␊ |
51 | ␉#␉echo "Executing command: dd if=/.Chameleon/i386/${stage1LoaderFAT} of=${targetDeviceRaw}"␊ |
52 | ␉#␉dd if="${targetVolume}/.Chameleon/i386/${stage1LoaderFAT}" of=${targetDeviceRaw}␊ |
53 | ␉#fi␊ |
54 | fi␊ |
55 | ␊ |
56 | echo "-----------------------------------------------"␊ |
57 | echo ""␊ |
58 | ␊ |
59 | exit 0␊ |
60 | ␊ |
61 | ␊ |
62 | ␊ |
63 | |