1 | #!/bin/bash␊ |
2 | ␊ |
3 | echo "==============================================="␊ |
4 | echo "Entered Postflight Script"␊ |
5 | echo "*************************"␊ |
6 | ␊ |
7 | # Find location of this script in the package installer␊ |
8 | # so we know where all the other scripts are located.␊ |
9 | ␊ |
10 | MYLOCATION="${PWD}/${BASH_ARGV[0]}"␊ |
11 | export MYLOCATION="${MYLOCATION%/*}"␊ |
12 | scriptDir=$MYLOCATION␊ |
13 | ␊ |
14 | ␊ |
15 | # Run script to create com.apple.Boot.plist␊ |
16 | # and pass it the installer destination.␊ |
17 | ␊ |
18 | "$scriptDir"BuildBootOptions.sh "${3}"␊ |
19 | ␊ |
20 | ␊ |
21 | # Has the temporary directory /.Chameleon/Extra been created?␊ |
22 | # If yes then check first for an existing /Extra folder on the␊ |
23 | # destination and if exists then back it up and delete existing.␊ |
24 | # Then transfer temporary Extra folder to destination.␊ |
25 | ␊ |
26 | if [ -d "${3}"/.Chameleon/Extra ]; then␊ |
27 | ␊ |
28 | ␉# Check to see if install to EFI system partition was selected␊ |
29 | ␉# if chosen, the package installer would have added a file named␊ |
30 | ␉# 'nullESP' in to the temporary directory /.Chameleon␊ |
31 | ␊ |
32 | ␉# We also need to check to see if the user selected both the␊ |
33 | ␉# standard install and EFI system partition options.␊ |
34 | ␉# If they did then the EFI system partition script would␊ |
35 | ␉# have been cancelled, meaning the Extra folder needs to ␊ |
36 | ␉# be copied the selected destination.␊ |
37 | ␊ |
38 | ␉if [ -f "${3}"/.Chameleon/nullESP ] && ! [ -f "${3}"/.Chameleon/nullstandard ]; then␊ |
39 | ␊ |
40 | ␉␉# Does an /Extra folder already exist at the target location?␊ |
41 | ␉␉# If yes, then make a backup of it␊ |
42 | ␊ |
43 | ␉␉if [ -d "/Volumes/EFI/Extra" ]; then␊ |
44 | ␉␉␉echo "DEBUG: Executing command: Backing up existing /Volumes/EFI/Extra"␊ |
45 | ␉␉␉mkdir -p "/Volumes/EFI/ExtraBackup"␊ |
46 | ␉␉␉cp -f -R "/Volumes/EFI/Extra" "/Volumes/EFI/ExtraBackup"␊ |
47 | ␉␉␉echo "Executing command: rm -f -R /Volumes/EFI/Extra"␊ |
48 | ␉␉␉rm -f -R "/Volumes/EFI/Extra"␊ |
49 | ␉␉fi␊ |
50 | ␊ |
51 | ␉␉echo "Executing command: ditto ${3}/.Chameleon/Extra /Volumes/EFI/Extra"␊ |
52 | ␉␉ditto "${3}"/.Chameleon/Extra /Volumes/EFI/Extra␊ |
53 | ␊ |
54 | ␉␉echo "Executing command: umount -f Volumes/EFI"␊ |
55 | ␉␉"$scriptDir"UnMountEFIvolumes.sh␊ |
56 | ␉␉returnValue=$?␊ |
57 | ␉␉if [ ${returnValue} = 0 ]; then␊ |
58 | ␉␉␉echo "Executing command: rm -f -R /Volumes/EFI/"␊ |
59 | ␉␉␉rm -R -f /Volumes/EFI␊ |
60 | ␉␉fi␊ |
61 | ␉else␊ |
62 | ␉␉# Does an /Extra folder already exist at the target location?␊ |
63 | ␉␉# If yes, then make a backup of it␊ |
64 | ␊ |
65 | ␉␉if [ -d "${3}"/Extra ]; then␊ |
66 | ␉␉␉echo "DEBUG: Backing up existing ${3}/Extra"␊ |
67 | ␉␉␉mkdir -p "${3}"/ExtraBackup␊ |
68 | ␉␉␉cp -f -R "${3}"/Extra "${3}"/ExtraBackup␊ |
69 | ␉␉␉echo "Executing command: rm -f -R ${3}/Extra"␊ |
70 | ␉␉␉rm -f -R "${3}"/Extra␊ |
71 | ␉␉fi␊ |
72 | ␊ |
73 | ␉␉echo "Executing command: ditto ${3}/.Chameleon/Extra ${3}/Extra"␊ |
74 | ␉␉ditto "${3}"/.Chameleon/Extra "${3}"/Extra␊ |
75 | ␉fi␊ |
76 | ␊ |
77 | fi␊ |
78 | ␊ |
79 | ␊ |
80 | echo "==============================================="␊ |
81 | echo "Clean Up"␊ |
82 | echo "********"␊ |
83 | ␊ |
84 | # check the /.Chameleon temporary directory exists␊ |
85 | # if yes, remove the temporary /.Chameleon directory␊ |
86 | ␊ |
87 | if [ -d "${3}"/.Chameleon ]; then␊ |
88 | ␉echo "Executing command: rm -r ${3}/.Chameleon/"␊ |
89 | ␉rm -r "${3}"/.Chameleon␊ |
90 | fi␊ |
91 | ␊ |
92 | # remove the temporary boot sector files if they exist␊ |
93 | if [ -d /tmp/newbs ]; then␊ |
94 | ␉echo "Executing command: rm /tmp/newbs"␊ |
95 | ␉rm /tmp/newbs␊ |
96 | fi␊ |
97 | if [ -d /tmp/origbs ]; then␊ |
98 | ␉echo "Executing command: rm /tmp/origbs"␊ |
99 | ␉rm /tmp/origbs␊ |
100 | fi␊ |
101 | ␊ |
102 | ␊ |
103 | exit 0␊ |
104 | |