1 | #!/bin/bash␊ |
2 | ␊ |
3 | echo "==============================================="␊ |
4 | echo "Main Standard Post-Install Script"␊ |
5 | echo "*********************************"␊ |
6 | echo "-----------------------------------------------"␊ |
7 | echo ""␊ |
8 | ␊ |
9 | # Find location of this script in the package installer␊ |
10 | # so we know where all the other scripts are located.␊ |
11 | MYLOCATION="${PWD}/${BASH_ARGV[0]}"␊ |
12 | export MYLOCATION="${MYLOCATION%/*}"␊ |
13 | scriptDir=$MYLOCATION␊ |
14 | ␊ |
15 | ␊ |
16 | #echo "==============================================="␊ |
17 | #echo "Apple Installer Package Variables"␊ |
18 | #echo "*********************************"␊ |
19 | #echo "DEBUG: $ 1 = Full path to the installation package the installer app is processing: " $1␊ |
20 | #echo "DEBUG: $ 2 = Full path to the installation destination: " $2␊ |
21 | #echo "DEBUG: $ 3 = Installation volume (mountpoint) to receive the payload: " $3␊ |
22 | #echo "DEBUG: $ 4 = Root directory for the system: " $4␊ |
23 | #echo "DEBUG: Script Name: " $SCRIPT_NAME␊ |
24 | #echo "DEBUG: Package Path: " $PACKAGE_PATH␊ |
25 | #echo "DEBUG: Installer Temp: " $INSTALLER_TEMP␊ |
26 | #echo "DEBUG: Full path to the temp directory containing the operation executable: " $RECEIPT_PATH␊ |
27 | #echo "-----------------------------------------------"␊ |
28 | #echo ""␊ |
29 | ␊ |
30 | ␊ |
31 | ␊ |
32 | # Initialise Script Globals␊ |
33 | ␊ |
34 | stage0Loader="boot0" #diskloader␊ |
35 | stage0LoaderDualBoot="boot0hfs" #was stage0Loaderdualboot␊ |
36 | stage1LoaderHFS="boot1h" #was stage1LoaderHFS␊ |
37 | stage1LoaderFAT="boot1f32" #was partitionloaderfat␊ |
38 | stage2Loader="boot" #was filesystemloader␊ |
39 | ␊ |
40 | targetVolume=$3 #was bootvolume␊ |
41 | targetDevice=$( df "${targetVolume}" | sed -n '2p' | awk '{print $1}' ) #was bootdev␊ |
42 | targetDeviceRaw=${targetDevice/disk/rdisk} #was bootrdev␊ |
43 | targetDisk=${targetDevice%s*} #was bootdisk␊ |
44 | targetDiskRaw=${targetDisk/disk/rdisk} #was bootrdisk␊ |
45 | targetSlice=${targetDevice#*disk*s} #was bootslice␊ |
46 | targetResources="${targetVolume%/*}" #was bootresources - is this needed?␊ |
47 | ␊ |
48 | ␊ |
49 | ␊ |
50 | echo "==============================================="␊ |
51 | echo "DEBUG: display script variables"␊ |
52 | echo "***************************"␊ |
53 | ␊ |
54 | echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader}"␊ |
55 | echo "DEBUG: stage0LoaderDualBoot: Disk loader is ${stage0LoaderDualBoot}"␊ |
56 | echo "DEBUG: stage1LoaderHFS: Partition loader is ${stage1LoaderHFS}"␊ |
57 | echo "DEBUG: stage1LoaderFat: Partition loader is ${stage1LoaderFAT}"␊ |
58 | echo "DEBUG: stage2Loader: Filesystem loader is ${stage2Loader}"␊ |
59 | echo "DEBUG: targetVolume: Volume is ${targetVolume}"␊ |
60 | echo "DEBUG: targetDevice: Volume device is ${targetDevice}"␊ |
61 | echo "DEBUG: targetDeviceRaw: Volume raw device is ${targetDeviceRaw}"␊ |
62 | echo "DEBUG: targetDisk: Disk device is ${targetDisk}"␊ |
63 | echo "DEBUG: targetDiskRaw: Disk raw device is ${targetDiskRaw}"␊ |
64 | echo "DEBUG: targetSlice: Volume slice is ${targetSlice}"␊ |
65 | echo "DEBUG: targetResources: Boot Resources is ${targetResources}"␊ |
66 | echo "-----------------------------------------------"␊ |
67 | echo ""␊ |
68 | ␊ |
69 | ␊ |
70 | # Double check we can see the selected partition and it's of the right type␊ |
71 | # if not the following script returns to indicate failure.␊ |
72 | ␊ |
73 | "$scriptDir"CheckProceed.sh "${targetVolume}" "${targetDevice}"␊ |
74 | returnValue=$?␊ |
75 | if [ ${returnValue} = 0 ]; then␊ |
76 | ␉# OK to proceed␊ |
77 | ␊ |
78 | ␊ |
79 | ␉# Does a GRUB or Linux loader already exist in the disk's MBR?␊ |
80 | ␊ |
81 | ␉"$scriptDir"CheckDiskMicrocodeType.sh "${targetDisk}"␊ |
82 | ␉returnValue=$?␊ |
83 | ␉if [ ${returnValue} = 0 ]; then␊ |
84 | ␉␉# OK to proceed␊ |
85 | ␊ |
86 | ␊ |
87 | ␉␉# check for a 4-byte Windows disk signature in the disk's MBR.␊ |
88 | ␉␉# the following script returns 1 if a Windows disk signature exists, and 0 if not.␊ |
89 | ␊ |
90 | ␉␉"$scriptDir"CheckDiskSignature.sh "${targetDisk}"␊ |
91 | ␉␉diskSigCheck=$?␊ |
92 | ␊ |
93 | ␊ |
94 | ␉␉# check for existing bootloaders in the disk's MBR␊ |
95 | ␉␉# and find out if we can write the Chameleon boot files.␊ |
96 | ␉␉# the following script returns 1 if we can proceed␊ |
97 | ␉␉# with writing the boot files, and 0 for not.␊ |
98 | ␊ |
99 | ␉␉"$scriptDir"CheckDiskMicrocode.sh "${targetDisk}" "${diskSigCheck}" ␊ |
100 | ␉␉diskupdate=$?␊ |
101 | ␊ |
102 | ␊ |
103 | ␉␉# Cancelled this as all it does is read the GPTdiskProtectiveMBR␊ |
104 | ␉␉# and the GPTdiskGPTHeader and look to see if they're blank␊ |
105 | |
106 | ␉␉␊ |
107 | ␉␉#"$scriptDir"FindPartitionBootcode.sh "${targetDeviceRaw}"␊ |
108 | ␊ |
109 | ␊ |
110 | ␉␉# check the format of the selected partition.␊ |
111 | ␉␉# the following script returns 1 if HFS␊ |
112 | ␉␉# the following script returns 2 if MSDOS␊ |
113 | ␉␉# the following script returns 0 if nothing␊ |
114 | ␊ |
115 | ␉␉"$scriptDir"CheckFormat.sh "${targetDevice}"␊ |
116 | ␉␉espformat=$?␊ |
117 | ␊ |
118 | ␊ |
119 | |
120 | ␊ |
121 | ␉␉"$scriptDir"CheckPartitionScheme.sh "${targetDisk}"␊ |
122 | ␊ |
123 | ␊ |
124 | ␉␉# If diskupdate is flagged as 1 then the stage 0 loader can be written to the MBR␊ |
125 | ␉␉if [ ${diskupdate} = 1 ]; then␊ |
126 | ␉␉␉"$scriptDir"WriteChameleonStage0.sh "${diskupdate}" "${diskSigCheck}" "${stage0Loader}" "${stage0LoaderDualBoot}" "${targetDisk}" "${targetVolume}"␊ |
127 | ␉␉fi␊ |
128 | ␊ |
129 | ␉␉# Write the stage 1 loader to the partition boot sector␊ |
130 | ␉␉"$scriptDir"WriteChameleonStage1.sh "${espformat}" "${stage1LoaderHFS}" "${stage1LoaderFAT}" "${3}" "${targetDeviceRaw}" "${targetVolume}"␊ |
131 | ␊ |
132 | ␉␉# Write the stage 2 loader to the root of the selected partition␊ |
133 | ␉␉"$scriptDir"WriteChameleonStage2.sh "${espformat}" "${stage2Loader}" "${3}" "${targetDevice}" "${targetVolume}"␊ |
134 | ␊ |
135 | ␉␉# Set the active partition ONLY if Windows is not installed␊ |
136 | ␉␉"$scriptDir"SetActivePartition.sh "${espformat}" "${diskSigCheck}" "${targetDiskRaw}" "${targetSlice}" "${targetVolume}"␊ |
137 | ␊ |
138 | ␉fi␊ |
139 | fi␊ |
140 | ␊ |
141 | exit 0␊ |
142 | |