-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path_hack_cmds.sh
executable file
·279 lines (255 loc) · 10.4 KB
/
_hack_cmds.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#!/bin/bash
tools_dir=$(dirname ${BASH_SOURCE[0]})
repo_dir=$(dirname $0)
source $tools_dir/_download_cmds.sh
source $tools_dir/_install_cmds.sh
source $tools_dir/_archive_cmds.sh
source $tools_dir/_config_cmds.sh
source $tools_dir/_hda_cmds.sh
source $tools_dir/_lilu_helper.sh
downloads_dir=$repo_dir/Downloads
hotpatch_dir=$repo_dir/Hotpatch/Downloads
local_kexts_dir=$repo_dir/Kexts
build_dir=$repo_dir/Build
tools_config=$tools_dir/org.the-braveknight.config.plist
if [[ -z "$repo_plist" ]]; then
if [[ -e "$repo_dir/repo_config.plist" ]]; then
repo_plist=$repo_dir/repo_config.plist
else
echo "No repo_config.plist file found. Exiting..."
exit 1
fi
fi
if [[ -z "$config_plist" ]]; then
if [[ -e "$repo_dir/config.plist" ]]; then
config_plist=$repo_dir/config.plist
else
echo "No config.plist file found. Exiting..."
exit 2
fi
fi
function installAppWithName() {
# $1: App name
app=$(findApp "$1" "$downloads_dir")
if [[ -e "$app" ]]; then
installApp "$app"
fi
}
function installKextWithName() {
# $1: Kext name
kext=$(findKext "$1" "$downloads_dir" "$local_kexts_dir")
if [[ -e "$kext" ]]; then
installKext "$kext"
fi
}
function installToolWithName() {
# $1: Tool name
tool=$(findTool "$1" "$downloads_dir")
if [[ -e "$tool" ]]; then
installTool "$tool"
fi
}
function installEssentialKextWithName() {
# $1: Kext name
if [[ ! -d "$efi" ]]; then efi=$($tools_dir/mount_efi.sh); fi
kext=$(findKext "$1" "$downloads_dir" "$local_kexts_dir")
if [[ -e "$kext" ]]; then
installKext "$kext" "$efi/EFI/CLOVER/kexts/Other"
fi
}
case "$1" in
--download-requirements)
rm -Rf $downloads_dir && mkdir -p $downloads_dir
rm -Rf $hotpatch_dir && mkdir -p $hotpatch_dir
# Bitbucket downloads
for ((index=0; 1; index++)); do
author=$(printValue "Downloads:Bitbucket:$index:Author" "$repo_plist")
repo=$(printValue "Downloads:Bitbucket:$index:Repo" "$repo_plist")
if [[ $? -ne 0 ]]; then break; fi
name=$(printValue "Downloads:Bitbucket:$index:Name" "$repo_plist" 2> /dev/null)
bitbucketDownload "$author" "$repo" "$downloads_dir" "$name"
done
# GitHub downloads
for ((index=0; 1; index++)); do
author=$(printValue "Downloads:GitHub:$index:Author" "$repo_plist")
repo=$(printValue "Downloads:GitHub:$index:Repo" "$repo_plist")
if [[ $? -ne 0 ]]; then break; fi
name=$(printValue "Downloads:GitHub:$index:Name" "$repo_plist" 2> /dev/null)
githubDownload "$author" "$repo" "$downloads_dir" "$name"
done
# Hotpatch SSDT downloads
downloadAllHotpatchSSDTs "$hotpatch_dir"
;;
--install-apps)
unarchiveAllInDirectory "$downloads_dir"
# GitHub apps
for ((downloadIndex=0; 1; downloadIndex++)); do
download=$(printValue "Downloads:GitHub:$downloadIndex" "$repo_plist" 2> /dev/null)
if [[ $? -ne 0 ]]; then break; fi
for ((installIndex=0; 1; installIndex++)); do
name=$(printValue "Downloads:GitHub:$downloadIndex:Installations:Apps:$installIndex:Name" "$repo_plist" 2> /dev/null)
if [[ $? -ne 0 ]]; then break; fi
installAppWithName "$name"
done
done
# Bitbucket apps
for ((downloadIndex=0; 1; downloadIndex++)); do
download=$(printValue "Downloads:Bitbucket:$downloadIndex" "$repo_plist" 2> /dev/null)
if [[ $? -ne 0 ]]; then break; fi
for ((installIndex=0; 1; installIndex++)); do
name=$(printValue "Downloads:Bitbucket:$downloadIndex:Installations:Apps:$installIndex:Name" "$repo_plist" 2> /dev/null)
if [[ $? -ne 0 ]]; then break; fi
installAppWithName "$name"
done
done
;;
--install-tools)
unarchiveAllInDirectory "$downloads_dir"
# GitHub tools
for ((downloadIndex=0; 1; downloadIndex++)); do
download=$(printValue "Downloads:GitHub:$downloadIndex" "$repo_plist" 2> /dev/null)
if [[ $? -ne 0 ]]; then break; fi
for ((installIndex=0; 1; installIndex++)); do
name=$(printValue "Downloads:GitHub:$downloadIndex:Installations:Tools:$installIndex:Name" "$repo_plist" 2> /dev/null)
if [[ $? -ne 0 ]]; then break; fi
installToolWithName "$name"
done
done
# Bitbucket tools
for ((downloadIndex=0; 1; downloadIndex++)); do
download=$(printValue "Downloads:Bitbucket:$downloadIndex" "$repo_plist" 2> /dev/null)
if [[ $? -ne 0 ]]; then break; fi
for ((installIndex=0; 1; installIndex++)); do
name=$(printValue "Downloads:Bitbucket:$downloadIndex:Installations:Tools:$installIndex:Name" "$repo_plist" 2> /dev/null)
if [[ $? -ne 0 ]]; then break; fi
installToolWithName "$name"
done
done
;;
--install-kexts)
unarchiveAllInDirectory "$downloads_dir"
# GitHub kexts
for ((downloadIndex=0; 1; downloadIndex++)); do
download=$(printValue "Downloads:GitHub:$downloadIndex" "$repo_plist" 2> /dev/null)
if [[ $? -ne 0 ]]; then break; fi
for ((installIndex=0; 1; installIndex++)); do
name=$(printValue "Downloads:GitHub:$downloadIndex:Installations:Kexts:$installIndex:Name" "$repo_plist" 2> /dev/null)
if [[ $? -ne 0 ]]; then break; fi
installKextWithName "$name"
done
done
# Bitbucket kexts
for ((downloadIndex=0; 1; downloadIndex++)); do
download=$(printValue "Downloads:Bitbucket:$downloadIndex" "$repo_plist" 2> /dev/null)
if [[ $? -ne 0 ]]; then break; fi
for ((installIndex=0; 1; installIndex++)); do
name=$(printValue "Downloads:Bitbucket:$downloadIndex:Installations:Kexts:$installIndex:Name" "$repo_plist" 2> /dev/null)
if [[ $? -ne 0 ]]; then break; fi
installKextWithName "$name"
done
done
# Local kexts
for ((index=0; 1; index++)); do
name=$(printValue "Local Installations:Kexts:$index:Name" "$repo_plist" 2> /dev/null)
if [[ $? -ne 0 ]]; then break; fi
installKextWithName "$name"
done
;;
--install-essential-kexts)
unarchiveAllInDirectory "$downloads_dir"
EFI=$($tools_dir/mount_efi.sh)
efi_kexts_dest=$EFI/EFI/CLOVER/kexts/Other
rm -Rf $efi_kexts_dest/*.kext
# GitHub kexts
for ((downloadIndex=0; 1; downloadIndex++)); do
download=$(printValue "Downloads:GitHub:$downloadIndex" "$repo_plist" 2> /dev/null)
if [[ $? -ne 0 ]]; then break; fi
for ((installIndex=0; 1; installIndex++)); do
name=$(printValue "Downloads:GitHub:$downloadIndex:Installations:Kexts:$installIndex:Name" "$repo_plist" 2> /dev/null)
if [[ $? -ne 0 ]]; then break; fi
essential=$(printValue "Downloads:GitHub:$downloadIndex:Installations:Kexts:$installIndex:Essential" "$repo_plist" 2> /dev/null)
if [[ "$essential" == "true" ]]; then
installEssentialKextWithName "$name"
fi
done
done
# Bitbucket kexts
for ((downloadIndex=0; 1; downloadIndex++)); do
download=$(printValue "Downloads:Bitbucket:$downloadIndex" "$repo_plist" 2> /dev/null)
if [[ $? -ne 0 ]]; then break; fi
for ((installIndex=0; 1; installIndex++)); do
name=$(printValue "Downloads:Bitbucket:$downloadIndex:Installations:Kexts:$installIndex:Name" "$repo_plist" 2> /dev/null)
if [[ $? -ne 0 ]]; then break; fi
essential=$(printValue "Downloads:Bitbucket:$downloadIndex:Installations:Kexts:$installIndex:Essential" "$repo_plist" 2> /dev/null)
if [[ "$essential" == "true" ]]; then
installEssentialKextWithName "$name"
fi
done
done
# Local kexts
for ((index=0; 1; index++)); do
name=$(printValue "Local Installations:Kexts:$index:Name" "$repo_plist" 2> /dev/null)
if [[ $? -ne 0 ]]; then break; fi
essential=$(printValue "Local Installations:Kexts:$index:Essential" "$repo_plist" 2> /dev/null)
if [[ "$essential" == "true" ]]; then
installEssentialKextWithName "$name"
fi
done
;;
--remove-installed-kexts)
for kext in $(printInstalledItems "Kexts"); do
removeKext "$kext"
done
;;
--remove-installed-apps)
for app in $(printInstalledItems "Apps"); do
removeApp "$app"
done
;;
--remove-installed-tools)
for tool in $(printInstalledItems "Tools"); do
removeTool "$tool"
done
;;
--remove-deprecated-kexts)
# To override default list of deprecated kexts in macos-tools/org.the-braveknight.deprecated.plist, set 'Deprecated:Override Defaults' to 'true'.
override=$(printValue "Deprecated:Override Defaults" "$repo_plist" 2> /dev/null)
if [[ "$override" != "true" ]]; then
for kext in $(printArrayItems "Deprecated:Kexts" "$tools_config" 2> /dev/null); do
removeKext "$kext"
done
fi
for kext in $(printArrayItems "Deprecated:Kexts" "$repo_plist" 2> /dev/null); do
removeKext "$kext"
done
;;
--install-config)
installConfig "$config_plist"
;;
--update-config)
updateConfig "$config_plist"
;;
--update-kernelcache)
sudo kextcache -i /
;;
--install-lilu-helper)
if [[ ! -d "$build_dir" ]]; then mkdir $build_dir; fi
createLiluHelper "$build_dir"
installKext "$build_dir/LiluHelper.kext"
;;
--update)
echo "Checking for updates..."
git stash --quiet && git pull
echo "Checking for macos-tools updates..."
cd $tools_dir && git stash --quiet && git pull && cd ..
;;
--install-downloads)
$0 --install-tools
$0 --install-apps
$0 --remove-deprecated-kexts
$0 --install-essential-kexts
$0 --install-kexts
$0 --install-lilu-helper
$0 --update-kernelcache
;;
esac