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 | ␉# TO DO - Set permissions of temporary /Extra folder␊ |
29 | |
30 | ␊ |
31 | ␊ |
32 | ␉# If user selected to the standard installation␊ |
33 | ␉# then the package installer would have added a file named␊ |
34 | ␉# 'nullstandard' in to the temporary directory /.Chameleon␊ |
35 | ␊ |
36 | ␉# If user selected to install to EFI system partition␊ |
37 | ␉# then the package installer would have added a file named␊ |
38 | ␉# 'nullESP' in to the temporary directory /.Chameleon␊ |
39 | ␊ |
40 | ␉# We also need to check to see if the user selected both the␊ |
41 | ␉# standard install and EFI system partition options.␊ |
42 | ␉# If they did then the EFI system partition script would␊ |
43 | ␉# have been cancelled, meaning the Extra folder needs to ␊ |
44 | ␉# be copied the selected destination.␊ |
45 | ␊ |
46 | ␉if [ -f "${3}"/.Chameleon/nullESP ] && ! [ -f "${3}"/.Chameleon/nullstandard ]; then␊ |
47 | ␊ |
48 | ␉␉# Does an /Extra folder already exist on the target EFI system partition?␊ |
49 | ␉␉# If yes, then make a backup of it␊ |
50 | ␊ |
51 | ␉␉if [ -d "/Volumes/EFI/Extra" ]; then␊ |
52 | ␉␉␉echo "DEBUG: Executing command: Backing up existing /Volumes/EFI/Extra"␊ |
53 | ␉␉␉mkdir -p "/Volumes/EFI/ExtraBackup"␊ |
54 | ␉␉␉cp -f -R "/Volumes/EFI/Extra" "/Volumes/EFI/ExtraBackup"␊ |
55 | ␉␉␉echo "Executing command: rm -f -R /Volumes/EFI/Extra"␊ |
56 | ␉␉␉rm -f -R "/Volumes/EFI/Extra"␊ |
57 | ␉␉fi␊ |
58 | ␊ |
59 | ␉␉# copy temporary /Extra folder to the selected destination.␊ |
60 | ␉␉echo "Executing command: cp ${3}/.Chameleon/Extra /Volumes/EFI/Extra"␊ |
61 | ␉␉cp -R "${3}"/.Chameleon/Extra /Volumes/EFI/Extra␊ |
62 | ␊ |
63 | ␉␉echo "Executing command: umount -f Volumes/EFI"␊ |
64 | ␉␉"$scriptDir"UnMountEFIvolumes.sh␊ |
65 | ␉␉returnValue=$?␊ |
66 | ␉␉if [ ${returnValue} = 0 ]; then␊ |
67 | ␉␉␉echo "Executing command: rm -f -R /Volumes/EFI/"␊ |
68 | ␉␉␉rm -R -f /Volumes/EFI␊ |
69 | ␉␉fi␊ |
70 | ␉else␊ |
71 | ␉␉# Does an /Extra folder already exist at the target location?␊ |
72 | ␉␉# If yes, then make a backup of it␊ |
73 | ␊ |
74 | ␉␉if [ -d "${3}"/Extra ]; then␊ |
75 | ␉␉␉echo "DEBUG: Backing up existing ${3}/Extra"␊ |
76 | ␉␉␉mkdir -p "${3}"/ExtraBackup␊ |
77 | ␉␉␉cp -f -R "${3}"/Extra "${3}"/ExtraBackup␊ |
78 | ␉␉␉echo "Executing command: rm -f -R ${3}/Extra"␊ |
79 | ␉␉␉rm -f -R "${3}"/Extra␊ |
80 | ␉␉fi␊ |
81 | ␊ |
82 | ␉␉echo "Executing command: cp ${3}/.Chameleon/Extra ${3}/Extra"␊ |
83 | ␉␉cp -R "${3}"/.Chameleon/Extra "${3}"/Extra␊ |
84 | ␉fi␊ |
85 | ␊ |
86 | fi␊ |
87 | ␊ |
88 | ␊ |
89 | echo "==============================================="␊ |
90 | echo "Remove any temporary files"␊ |
91 | echo "**************************"␊ |
92 | ␊ |
93 | # check the /.Chameleon temporary directory exists␊ |
94 | # if yes, remove the temporary /.Chameleon directory␊ |
95 | ␊ |
96 | if [ -d "${3}"/.Chameleon ]; then␊ |
97 | ␉echo "Executing command: rm -f -R ${3}/.Chameleon/"␊ |
98 | ␉rm -f -R "${3}"/.Chameleon␊ |
99 | fi␊ |
100 | ␊ |
101 | # remove the temporary boot sector files if they exist␊ |
102 | if [ -d /tmp/newbs ]; then␊ |
103 | ␉echo "Executing command: rm /tmp/newbs"␊ |
104 | ␉rm /tmp/newbs␊ |
105 | fi␊ |
106 | if [ -d /tmp/origbs ]; then␊ |
107 | ␉echo "Executing command: rm /tmp/origbs"␊ |
108 | ␉rm /tmp/origbs␊ |
109 | fi␊ |
110 | ␊ |
111 | ␊ |
112 | exit 0␊ |
113 | |