1 | #!/bin/bash␊ |
2 | ␊ |
3 | echo "==============================================="␊ |
4 | echo "Write Chameleon Stage 2 Loader:"␊ |
5 | echo "*******************************"␊ |
6 | ␊ |
7 | |
8 | # for example: ␊ |
9 | # espformat code is 1 for HFS, 2 for MSDOS, 0 for unknown␊ |
10 | ␊ |
11 | ␊ |
12 | if [ "$#" -eq 5 ]; then␊ |
13 | ␉espformat="$1"␊ |
14 | ␉stage2Loader="$2"␊ |
15 | ␉selectedDestination="$3"␊ |
16 | ␉targetDevice="$4"␊ |
17 | ␉targetVolume="$5"␊ |
18 | ␉echo "DEBUG: passed argument for espformat = $espformat"␊ |
19 | ␉echo "DEBUG: passed argument for stage2Loader = $stage2Loader"␊ |
20 | ␉echo "DEBUG: passed argument for selectedDestination = $selectedDestination"␊ |
21 | ␉echo "DEBUG: passed argument for targetDevice = $targetDevice"␊ |
22 | ␉echo "DEBUG: passed argument for targetVolume = $targetVolume"␊ |
23 | else␊ |
24 | ␉echo "Error - wrong number of values passed"␊ |
25 | ␉exit 9␊ |
26 | fi␊ |
27 | ␊ |
28 | # check to see if install to EFI system partition was selected␊ |
29 | # if chosen, the package installer will add a file named 'nullESP'␊ |
30 | # in to the temporary directory /.Chameleon␊ |
31 | ␊ |
32 | if [ -f "${selectedDestination}"/.Chameleon/nullESP ]; then␊ |
33 | ␊ |
34 | echo "DEBUG: nullESP exists"␊ |
35 | ␊ |
36 | ␉if [ ! -d "${targetVolume}" ]; then␊ |
37 | ␉␉echo "Executing Command: mkdir -p ${targetVolume}"␊ |
38 | ␉␉mkdir -p "${targetVolume}"␊ |
39 | ␉else␊ |
40 | ␉␉echo "DEBUG: folder /Volumes/EFI already exists"␊ |
41 | ␉fi␊ |
42 | ␊ |
43 | ␉#if the EFI system partition was selected then␊ |
44 | ␉# mount '/Volumes/EFI' with the correct format type␊ |
45 | ␊ |
46 | ␉if [ ${espformat} = 1 ]; then␊ |
47 | ␊ |
48 | ␉␉echo "Executing command: mount_hfs ${targetDevice} ${targetVolume}"␊ |
49 | ␉␉mount_hfs "${targetDevice}" "${targetVolume}"␊ |
50 | ␉fi␊ |
51 | ␉if [ ${espformat} = 2 ]; then␊ |
52 | ␉␉[ -d "${targetVolume}" ] || mkdir -p "${targetVolume}"␊ |
53 | ␉␉echo "Executing command: mount_msdos -u 0 -g 0 ${targetDevice} ${targetVolume}"␊ |
54 | ␉␉mount_msdos -u 0 -g 0 "${targetDevice}" "${targetVolume}"␊ |
55 | ␉fi␊ |
56 | fi␊ |
57 | ␊ |
58 | echo "Executing command: cp ${selectedDestination}/.Chameleon/i386/${stage2Loader} ${targetVolume}"␊ |
59 | cp "${selectedDestination}"/.Chameleon/i386/"${stage2Loader}" "${targetVolume}"␊ |
60 | ␊ |
61 | ␊ |
62 | |
63 | ␊ |
64 | if [ -f "${selectedDestination}"/.Chameleon/nullhideboot ]; then␊ |
65 | ␊ |
66 | ␉echo "Executing command: SetFile -a V ${targetVolume}/${stage2Loader}"␊ |
67 | ␉"${selectedDestination}"/.Chameleon//Tools/SetFile -a V "${targetVolume}"/"${stage2Loader}"␊ |
68 | fi␊ |
69 | ␊ |
70 | echo "-----------------------------------------------"␊ |
71 | echo ""␊ |
72 | echo ""␊ |
73 | ␊ |
74 | exit 0 |