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 | ␉␉␉rm -f -R "/Volumes/EFI/Extra"␊ |
48 | ␉␉fi␊ |
49 | ␊ |
50 | ␉␉echo "Executing command: ditto ${3}/.Chameleon/Extra /Volumes/EFI/Extra"␊ |
51 | ␉␉ditto ${3}/.Chameleon/Extra /Volumes/EFI/Extra␊ |
52 | ␊ |
53 | ␉␉echo "Executing command: umount -f Volumes/EFI"␊ |
54 | ␉␉"$scriptDir"UnMountEFIvolumes.sh␊ |
55 | ␉␉returnValue=$?␊ |
56 | ␉␉if [ ${returnValue} = 0 ]; then␊ |
57 | ␉␉␉rm -R -f /Volumes/EFI␊ |
58 | ␉␉fi␊ |
59 | ␉else␊ |
60 | ␉␉# Does an /Extra folder already exist at the target location?␊ |
61 | ␉␉# If yes, then make a backup of it␊ |
62 | ␊ |
63 | ␉␉if [ -d "${3}/Extra" ]; then␊ |
64 | ␉␉␉echo "DEBUG: Executing command: Backing up existing ${3}/Extra"␊ |
65 | ␉␉␉mkdir -p "${3}/ExtraBackup"␊ |
66 | ␉␉␉cp -f -R "${3}/Extra" "${3}/ExtraBackup"␊ |
67 | ␉␉␉rm -f -R "${3}/Extra"␊ |
68 | ␉␉fi␊ |
69 | ␊ |
70 | ␉␉echo "Executing command: ditto ${3}/.Chameleon/Extra ${3}/Extra"␊ |
71 | ␉␉ditto ${3}/.Chameleon/Extra ${3}/Extra␊ |
72 | ␉fi␊ |
73 | ␊ |
74 | fi␊ |
75 | ␊ |
76 | ␊ |
77 | echo "==============================================="␊ |
78 | echo "Clean Up"␊ |
79 | echo "********"␊ |
80 | ␊ |
81 | # remove the temporary /.Chameleon directory␊ |
82 | echo "Executing command: rm -r ${3}/.Chameleon/"␊ |
83 | rm -r "${3}"/.Chameleon/␊ |
84 | ␊ |
85 | # remove the temporary boot sector files if they exist␊ |
86 | if [ -d /tmp/newbs ]; then␊ |
87 | ␉echo "Executing command: rm /tmp/newbs"␊ |
88 | ␉rm /tmp/newbs␊ |
89 | fi␊ |
90 | if [ -d /tmp/origbs ]; then␊ |
91 | ␉echo "Executing command: rm /tmp/origbs"␊ |
92 | ␉rm /tmp/origbs␊ |
93 | fi␊ |
94 | ␊ |
95 | ␊ |
96 | exit 0␊ |
97 | |