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 | fi␊ |
24 | ␊ |
25 | # check to see if install to EFI system partition was selected␊ |
26 | # if chosen, the package installer will add a file named 'nullESP'␊ |
27 | # in to the temporary directory /.Chameleon␊ |
28 | ␊ |
29 | if [ -f ${selectedDestination}/.Chameleon/nullESP ]; then␊ |
30 | ␊ |
31 | echo "DEBUG: nullESP exists"␊ |
32 | ␊ |
33 | ␉#[ -d "${targetVolume}" ] || mkdir -p "${targetVolume}"␊ |
34 | ␉if [ ! -d "${targetVolume}" ]; then␊ |
35 | ␉␉echo "Executing Command: mkdir -p ${targetVolume}"␊ |
36 | ␉␉mkdir -p "${targetVolume}"␊ |
37 | ␉else␊ |
38 | ␉␉echo "DEBUG: folder /Volumes/EFI already exists"␊ |
39 | ␉fi␊ |
40 | ␊ |
41 | ␉#if the EFI system partition was selected then␊ |
42 | ␉# mount '/Volumes/EFI' with the correct format type␊ |
43 | ␊ |
44 | ␉if [ ${espformat} = 1 ]; then␊ |
45 | ␊ |
46 | ␉␉echo "Executing command: mount_hfs ${targetDevice} ${targetVolume}"␊ |
47 | ␉␉mount_hfs "${targetDevice}" "${targetVolume}"␊ |
48 | ␉fi␊ |
49 | ␉if [ ${espformat} = 2 ]; then␊ |
50 | ␉␉[ -d "${targetVolume}" ] || mkdir -p "${targetVolume}"␊ |
51 | ␉␉echo "Executing command: mount_msdos -u 0 -g 0 ${targetDevice} ${targetVolume}"␊ |
52 | ␉␉mount_msdos -u 0 -g 0 "${targetDevice}" "${targetVolume}"␊ |
53 | ␉fi␊ |
54 | fi␊ |
55 | ␊ |
56 | echo "Executing command: cp ${selectedDestination}/.Chameleon/i386/${stage2Loader} ${targetVolume}"␊ |
57 | cp "${selectedDestination}/.Chameleon/i386/${stage2Loader}" "${targetVolume}"␊ |
58 | ␊ |
59 | #echo "Executing command: ${targetResources}/Tools/SetFile -a V ${targetVolume}/${stage2Loader}"␊ |
60 | #"${targetResources}/Tools/SetFile" -a V "${targetVolume}/${stage2Loader}"␊ |
61 | ␊ |
62 | ␊ |
63 | echo "-----------------------------------------------"␊ |
64 | echo ""␊ |
65 | echo ""␊ |
66 | ␊ |
67 | exit 0 |