forked from os-x-hackers/macos-downloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
macOS Downloader.sh
executable file
·650 lines (504 loc) · 23.7 KB
/
macOS Downloader.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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
#!/bin/bash
# Copyright (C) 2020-present github/seyoon20087
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
parameters="${1}${2}${3}${4}${5}${6}${7}${8}${9}"
Escape_Variables()
{
text_progress="\033[38;5;113m"
text_success="\033[38;5;113m"
text_warning="\033[38;5;221m"
text_error="\033[38;5;203m"
text_message="\033[38;5;75m"
text_bold="\033[1m"
text_faint="\033[2m"
text_italic="\033[3m"
text_underline="\033[4m"
erase_style="\033[0m"
erase_line="\033[0K"
move_up="\033[1A"
move_down="\033[1B"
move_foward="\033[1C"
move_backward="\033[1D"
}
Parameter_Variables()
{
if [[ $parameters == *"-v"* || $parameters == *"-verbose"* ]]; then
verbose="1"
set -x
fi
if [[ $parameters == *"-l"* || $parameters == *"-local"* ]]; then
local="1"
fi
}
Real_Path()
{
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#.}"
}
Path_Variables()
{
script_path="${0}"
directory_path="$(Real_Path "${0%/*}")"
resources_path="$directory_path/resources"
}
Input_Off()
{
stty -echo
}
Input_On()
{
stty echo
}
Output_Off()
{
if [[ $verbose == "1" ]]; then
"$@"
else
"$@" &>/dev/null
fi
}
Check_Environment()
{
echo -e $(date "+%b %m %H:%M:%S") ${text_progress}"> Checking system environment."${erase_style}
if [ -d /Install\ *.app ]; then
environment="installer"
else
environment="system"
fi
echo -e $(date "+%b %m %H:%M:%S") ${move_up}${erase_line}${text_success}"+ Checked system environment."${erase_style}
}
Check_Volume_Version()
{
echo -e $(date "+%b %m %H:%M:%S") ${text_progress}"> Checking system version."${erase_style}
volume_version="$(defaults read /System/Library/CoreServices/SystemVersion.plist ProductVersion)"
volume_version_short="$(defaults read /System/Library/CoreServices/SystemVersion.plist ProductVersion | cut -c-5)"
volume_build="$(defaults read /System/Library/CoreServices/SystemVersion.plist ProductBuildVersion)"
if [[ ${#volume_version} == "6" ]]; then
volume_version_short="$(defaults read /System/Library/CoreServices/SystemVersion.plist ProductVersion | cut -c-4)"
fi
if [[ ${#volume_version_short} == "4" ]]; then
volume_version_short="$(defaults read /System/Library/CoreServices/SystemVersion.plist ProductVersion | cut -c-2)"
fi
echo -e $(date "+%b %m %H:%M:%S") ${move_up}${erase_line}${text_success}"+ Checked system version."${erase_style}
}
Check_Volume_Support()
{
echo -e $(date "+%b %m %H:%M:%S") ${text_progress}"> Checking system support."${erase_style}
if [[ $volume_version_short == "10."[6-9] || $volume_version_short == "10.1"[0-5] || $volume_version_short == "11" ]]; then
echo -e $(date "+%b %m %H:%M:%S") ${move_up}${erase_line}${text_success}"+ System support check passed."${erase_style}
else
echo -e $(date "+%b %m %H:%M:%S") ${text_error}"- System support check failed."${erase_style}
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ Run this tool on a supported system."${erase_style}
Input_On
exit 1
fi
}
Check_Resources()
{
echo -e $(date "+%b %m %H:%M:%S") ${text_progress}"> Checking for resources."${erase_style}
if [[ -d "$resources_path" ]]; then
resources_check="passed"
echo -e $(date "+%b %m %H:%M:%S") ${move_up}${erase_line}${text_success}"+ Resources check passed."${erase_style}
else
resources_check="failed"
echo -e $(date "+%b %m %H:%M:%S") ${text_error}"- Resources check failed."${erase_style}
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ Run this tool with the required resources."${erase_style}
Input_On
exit 1
fi
}
Input_Folder()
{
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ What save folder would you like to use?"${erase_style}
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ Input a save folder path."${erase_style}
Input_On
read -e -p "$(date "+%b %m %H:%M:%S") / " save_folder
Input_Off
}
Check_Write()
{
echo -e $(date "+%b %m %H:%M:%S") ${text_progress}"> Checking for write permissions on save folder."${erase_style}
if [[ -w "$save_folder" ]]; then
write_check="passed"
echo -e $(date "+%b %m %H:%M:%S") ${move_up}${erase_line}${text_success}"+ Write permissions check passed."${erase_style}
else
root_check="failed"
echo -e $(date "+%b %m %H:%M:%S") ${text_error}"- Write permissions check failed."${erase_style}
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ Run this tool with a writable save folder."${erase_style}
Input_On
exit 1
fi
}
Input_Version()
{
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ What operation would you like to run?"${erase_style}
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ Input an operation number."${erase_style}
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ 1 - Monterey (Beta)"${erase_style}
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ 2 - Big Sur"${erase_style}
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ 3 - Catalina"${erase_style}
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ 4 - Mojave"${erase_style}
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ 5 - High Sierra"${erase_style}
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ 6 - Sierra"${erase_style}
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ 7 - El Capitan"${erase_style}
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ 8 - Yosemite"${erase_style}
Input_On
read -e -p "$(date "+%b %m %H:%M:%S") / " operation_version
Input_Off
if [[ $operation_version == "1" ]]; then
installer_choice="mn"
fi
if [[ $operation_version == "2" ]]; then
installer_choice="bs"
fi
if [[ $operation_version == "3" ]]; then
installer_choice="c"
fi
if [[ $operation_version == "4" ]]; then
installer_choice="m"
fi
if [[ $operation_version == "5" ]]; then
installer_choice="hs"
fi
if [[ $operation_version == "6" ]]; then
installer_choice="s"
fi
if [[ $operation_version == "7" ]]; then
installer_choice="ec"
fi
if [[ $operation_version == "8" ]]; then
installer_choice="y"
fi
if [[ $operation_version == [1-2] ]]; then
Import_Catalog
Import_Second_Catalog
Download_Installer_3
Prepare_Installer_3
Import_Second_Catalog
fi
if [[ $operation_version == [3-5] ]]; then
Import_Catalog
Import_Second_Catalog
Input_Download
Import_Second_Catalog
fi
if [[ $operation_version == [6-8] ]]; then
Import_Catalog
Import_Second_Catalog
Download_Installer_2
Prepare_Installer_2
Import_Second_Catalog
fi
}
Import_Catalog()
{
echo -e $(date "+%b %m %H:%M:%S") ${text_progress}"> Importing catalog"${erase_style}
chmod +x "$resources_path"/curl
if [[ -f "$directory_path"/Catalog.sh && $local == "1" ]]; then
chmod +x "$directory_path"/Catalog.sh
source "$directory_path"/Catalog.sh
echo -e $(date "+%b %m %H:%M:%S") ${move_up}${erase_line}${text_success}"+ Catalog imported."${erase_style}
else
"$resources_path"/curl --cacert "$resources_path"/cacert.pem -L -s -o /tmp/Catalog.sh https://raw.githubusercontent.com/seyoon20087/macos-downloader/master/Catalog.sh
if [[ -f /tmp/Catalog.sh ]]; then
chmod +x /tmp/Catalog.sh
source /tmp/Catalog.sh
echo -e $(date "+%b %m %H:%M:%S") ${move_up}${erase_line}${text_success}"+ Catalog imported."${erase_style}
else
echo -e $(date "+%b %m %H:%M:%S") ${text_error}"- Catalog import failed."${erase_style}
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ Run this tool while connected to the internet."${erase_style}
Input_On
exit
fi
fi
update_option="${installer_choice}_update_option"
combo_update_option="${installer_choice}_combo_update_option"
installer_url="${installer_choice}_installer_url"
installer_key="${installer_choice}_installer_key"
installer_name="${installer_choice}_installer_name"
installer_version="${installer_choice}_installer_version"
update_url="${installer_choice}_update_url"
update_key="${installer_choice}_update_key"
update_version="${installer_choice}_update_version"
combo_update_url="${installer_choice}_combo_update_url"
combo_update_key="${installer_choice}_combo_update_key"
}
Input_Download()
{
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ What operation would you like to run?"${erase_style}
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ Input an operation number."${erase_style}
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ 1 - Installer"${erase_style}
if [[ ${!update_option} == "1" ]]; then
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ 2 - Beta Update"${erase_style}
fi
if [[ ${!combo_update_option} == "1" ]]; then
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ 3 - Beta Combo Update"${erase_style}
fi
Input_On
read -e -p "$(date "+%b %m %H:%M:%S") / " operation_download
Input_Off
if [[ $operation_download == "1" ]]; then
Download_Installer
Prepare_Installer
fi
if [[ $operation_download == "2" ]]; then
update_name="macOSUpd"
update_url="${!update_url}"
update_key="${!update_key}"
update_version="${!update_version}"
fi
if [[ $operation_download == "3" ]]; then
update_name="macOSUpdCombo"
update_url="${!combo_update_url}"
update_key="${!combo_update_key}"
update_version="${!combo_update_version}"
fi
if [[ $operation_download == [2-3] ]]; then
Download_Update
Prepare_Update
fi
}
Import_Second_Catalog()
{
if [[ -d /tmp/"${!installer_name}" ]]; then
chmod +x /tmp/"${!installer_name}"/Catalog.sh
source /tmp/"${!installer_name}"/Catalog.sh
fi
if [[ -d /tmp/"${update_name}${update_version}" ]]; then
chmod +x /tmp/"${update_name}${update_version}"/Catalog.sh
source /tmp/"${update_name}${update_version}"/Catalog.sh
fi
}
Download_Installer()
{
echo -e $(date "+%b %m %H:%M:%S") ${text_progress}"> Downloading installer files."${erase_style}
if [[ ! -d /tmp/"${!installer_name}" ]]; then
mkdir /tmp/"${!installer_name}"
fi
echo -e "installer_download=\"1\"" >> /tmp/"${!installer_name}"/Catalog.sh
if [[ ! "$InstallAssistantAuto_pkg" == "1" ]]; then
"$resources_path"/curl --cacert "$resources_path"/cacert.pem -L -s -o /tmp/"${!installer_name}"/InstallAssistantAuto.pkg http://swcdn.apple.com/content/downloads/${!installer_url}/InstallAssistantAuto.pkg
echo -e "InstallAssistantAuto_pkg=\"1\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
if [[ ! "$AppleDiagnostics_chunklist" == "1" ]]; then
"$resources_path"/curl --cacert "$resources_path"/cacert.pem -L -s -o /tmp/"${!installer_name}"/AppleDiagnostics.chunklist http://swcdn.apple.com/content/downloads/${!installer_url}/AppleDiagnostics.chunklist
echo -e "AppleDiagnostics_chunklist=\"1\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
if [[ ! "$AppleDiagnostics_dmg" == "1" ]]; then
"$resources_path"/curl --cacert "$resources_path"/cacert.pem -L -s -o /tmp/"${!installer_name}"/AppleDiagnostics.dmg http://swcdn.apple.com/content/downloads/${!installer_url}/AppleDiagnostics.dmg
echo -e "AppleDiagnostics_dmg=\"1\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
if [[ ! "$BaseSystem_chunklist" == "1" ]]; then
"$resources_path"/curl --cacert "$resources_path"/cacert.pem -L -s -o /tmp/"${!installer_name}"/BaseSystem.chunklist http://swcdn.apple.com/content/downloads/${!installer_url}/BaseSystem.chunklist
echo -e "BaseSystem_chunklist=\"1\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
if [[ ! "$BaseSystem_dmg" == "1" ]]; then
"$resources_path"/curl --cacert "$resources_path"/cacert.pem -L -s -o /tmp/"${!installer_name}"/BaseSystem.dmg http://swcdn.apple.com/content/downloads/${!installer_url}/BaseSystem.dmg
echo -e "BaseSystem_dmg=\"1\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
if [[ ! "$InstallESD_dmg" == "1" ]]; then
"$resources_path"/curl --cacert "$resources_path"/cacert.pem -L -s -o /tmp/"${!installer_name}"/InstallESD.dmg http://swcdn.apple.com/content/downloads/${!installer_url}/InstallESDDmg.pkg
echo -e "InstallESD_dmg=\"1\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
echo -e "installer_download=\"2\"" >> /tmp/"${!installer_name}"/Catalog.sh
echo -e $(date "+%b %m %H:%M:%S") ${move_up}${erase_line}${text_success}"+ Downloaded installer files."${erase_style}
}
Prepare_Installer()
{
echo -e $(date "+%b %m %H:%M:%S") ${text_progress}"> Preparing installer."${erase_style}
echo -e "installer_prepare=\"1\"" >> /tmp/"${!installer_name}"/Catalog.sh
cd /tmp/"${!installer_name}"
if [[ ! "$InstallAssistantAuto_pkg" == "2" ]]; then
chmod +x "$resources_path"/pbzx
"$resources_path"/pbzx /tmp/"${!installer_name}"/InstallAssistantAuto.pkg | Output_Off cpio -i
echo -e "InstallAssistantAuto_pkg=\"2\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
if [[ ! "$InstallAssistantAuto_pkg" == "3" ]]; then
mv /tmp/"${!installer_name}"/"${!installer_name}".app "$save_folder"
echo -e "InstallAssistantAuto_pkg=\"3\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
if [[ ! "$AppleDiagnostics_chunklist" == "3" ]]; then
mv /tmp/"${!installer_name}"/AppleDiagnostics.chunklist "$save_folder"/"${!installer_name}".app/Contents/SharedSupport
echo -e "AppleDiagnostics_chunklist=\"3\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
if [[ ! "$AppleDiagnostics_dmg" == "3" ]]; then
mv /tmp/"${!installer_name}"/AppleDiagnostics.dmg "$save_folder"/"${!installer_name}".app/Contents/SharedSupport
echo -e "AppleDiagnostics_dmg=\"3\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
if [[ ! "$BaseSystem_chunklist" == "3" ]]; then
mv /tmp/"${!installer_name}"/BaseSystem.chunklist "$save_folder"/"${!installer_name}".app/Contents/SharedSupport
echo -e "BaseSystem_chunklist=\"3\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
if [[ ! "$BaseSystem_dmg" == "3" ]]; then
mv /tmp/"${!installer_name}"/BaseSystem.dmg "$save_folder"/"${!installer_name}".app/Contents/SharedSupport
echo -e "BaseSystem_dmg=\"3\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
if [[ ! "$InstallESD_dmg" == "3" ]]; then
mv /tmp/"${!installer_name}"/InstallESD.dmg "$save_folder"/"${!installer_name}".app/Contents/SharedSupport
echo -e "InstallESD_dmg=\"3\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
echo -e "installer_prepare=\"2\"" >> /tmp/"${!installer_name}"/Catalog.sh
echo -e $(date "+%b %m %H:%M:%S") ${move_up}${erase_line}${text_success}"+ Prepared installer."${erase_style}
}
Download_Installer_2()
{
echo -e $(date "+%b %m %H:%M:%S") ${text_progress}"> Downloading installer files."${erase_style}
if [[ ! -d /tmp/"${!installer_name}" ]]; then
mkdir /tmp/"${!installer_name}"
fi
echo -e "installer_download=\"1\"" >> /tmp/"${!installer_name}"/Catalog.sh
if [[ ! "$Install_dmg" == "1" ]]; then
"$resources_path"/curl --cacert "$resources_path"/cacert.pem -L -s -o /tmp/"${!installer_name}"/"${!installer_name}".dmg ${!installer_url}
echo -e "Install_dmg=\"1\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
echo -e "installer_download=\"2\"" >> /tmp/"${!installer_name}"/Catalog.sh
echo -e $(date "+%b %m %H:%M:%S") ${move_up}${erase_line}${text_success}"+ Downloaded installer files."${erase_style}
}
Prepare_Installer_2()
{
echo -e $(date "+%b %m %H:%M:%S") ${text_progress}"> Preparing installer."${erase_style}
echo -e "installer_prepare=\"1\"" >> /tmp/"${!installer_name}"/Catalog.sh
Output_Off hdiutil attach /tmp/"${!installer_name}"/"${!installer_name}".dmg -mountpoint /tmp/"${!installer_name}"_dmg -nobrowse
installer_pkg="$(ls /tmp/"${!installer_name}"_dmg)"
installer_pkg_partial="${installer_pkg%.*}"
if [[ ! "$Install_pkg" == "1" ]]; then
pkgutil --expand /tmp/"${!installer_name}"_dmg/"${installer_pkg}" /tmp/"${!installer_name}"/"${installer_pkg_partial}"
echo -e "Install_pkg=\"1\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
if [[ ! "$Install_pkg" == "2" ]]; then
tar -xf /tmp/"${!installer_name}"/"${installer_pkg_partial}"/"${installer_pkg}"/Payload -C "$save_folder"
echo -e "Install_pkg=\"2\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
if [[ ! "$InstallESD_dmg" == "1" ]]; then
cp /tmp/"${!installer_name}"_dmg/"${installer_pkg}" "$save_folder"/"${!installer_name}".app/Contents/SharedSupport/InstallESD.dmg
echo -e "InstallESD_dmg=\"1\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
Output_Off hdiutil detach /tmp/"${!installer_name}"_dmg
echo -e "installer_prepare=\"2\"" >> /tmp/"${!installer_name}"/Catalog.sh
echo -e $(date "+%b %m %H:%M:%S") ${move_up}${erase_line}${text_success}"+ Prepared installer."${erase_style}
}
Download_Installer_3()
{
echo -e $(date "+%b %m %H:%M:%S") ${text_progress}"> Downloading installer files."${erase_style}
if [[ ! -d /tmp/"${!installer_name}" ]]; then
mkdir /tmp/"${!installer_name}"
fi
echo -e "installer_download=\"1\"" >> /tmp/"${!installer_name}"/Catalog.sh
if [[ ! "$Install_pkg" == "1" ]]; then
"$resources_path"/curl --cacert "$resources_path"/cacert.pem -L -s -o /tmp/"${!installer_name}"/"${!installer_name}".pkg ${!installer_url}
echo -e "Install_pkg=\"1\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
echo -e "installer_download=\"2\"" >> /tmp/"${!installer_name}"/Catalog.sh
echo -e $(date "+%b %m %H:%M:%S") ${move_up}${erase_line}${text_success}"+ Downloaded installer files."${erase_style}
}
Prepare_Installer_3()
{
echo -e $(date "+%b %m %H:%M:%S") ${text_progress}"> Preparing installer."${erase_style}
echo -e "installer_prepare=\"1\"" >> /tmp/"${!installer_name}"/Catalog.sh
if [[ ! "$Install_pkg" == "1" ]]; then
Output_Off pkgutil --expand /tmp/"${!installer_name}"/"${!installer_name}".pkg /tmp/"${!installer_name}"/"${!installer_name}"
echo -e "Install_pkg=\"1\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
if [[ ! "$Install_pkg" == "2" ]]; then
tar -xf /tmp/"${!installer_name}"/"${!installer_name}"/Payload -C /tmp/"${!installer_name}" Applications/"${!installer_name}".app
mv /tmp/"${!installer_name}"/Applications/"${!installer_name}".app "$save_folder"
echo -e "Install_pkg=\"2\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
if [[ ! "$SharedSupport_dmg" == "1" ]]; then
mkdir -p "$save_folder"/"${!installer_name}".app/Contents/SharedSupport
cp /tmp/"${!installer_name}"/"${!installer_name}".pkg "$save_folder"/"${!installer_name}".app/Contents/SharedSupport/SharedSupport.dmg
echo -e "SharedSupport_dmg=\"1\"" >> /tmp/"${!installer_name}"/Catalog.sh
fi
echo -e "installer_prepare=\"2\"" >> /tmp/"${!installer_name}"/Catalog.sh
echo -e $(date "+%b %m %H:%M:%S") ${move_up}${erase_line}${text_success}"+ Prepared installer."${erase_style}
}
Download_Update()
{
echo -e $(date "+%b %m %H:%M:%S") ${text_progress}"> Downloading update files."${erase_style}
if [[ ! -d /tmp/"${update_name}${update_version}" ]]; then
mkdir /tmp/"${update_name}${update_version}"
fi
echo -e "update_download=\"1\"" >> /tmp/"${update_name}${update_version}"/Catalog.sh
if [[ ! "$macOSBrain_pkg" == "1" ]]; then
"$resources_path"/curl --cacert "$resources_path"/cacert.pem -L -s -o /tmp/"${update_name}${update_version}"/macOSBrain.pkg http://swcdn.apple.com/content/downloads/${update_url}/macOSBrain.pkg
echo -e "macOSBrain_pkg=\"1\"" >> /tmp/"${update_name}${update_version}"/Catalog.sh
fi
if [[ ! "$FirmwareUpdate_pkg" == "1" ]]; then
"$resources_path"/curl --cacert "$resources_path"/cacert.pem -L -s -o /tmp/"${update_name}${update_version}"/FirmwareUpdate.pkg http://swcdn.apple.com/content/downloads/${update_url}/FirmwareUpdate.pkg
echo -e "FirmwareUpdate_pkg=\"1\"" >> /tmp/"${update_name}${update_version}"/Catalog.sh
fi
if [[ ! "$FullBundleUpdate_pkg" == "1" ]]; then
"$resources_path"/curl --cacert "$resources_path"/cacert.pem -L -s -o /tmp/"${update_name}${update_version}"/FullBundleUpdate.pkg http://swcdn.apple.com/content/downloads/${update_url}/FullBundleUpdate.pkg
echo -e "FullBundleUpdate_pkg=\"1\"" >> /tmp/"${update_name}${update_version}"/Catalog.sh
fi
if [[ ! "$EmbeddedOSFirmware_pkg" == "1" ]]; then
"$resources_path"/curl --cacert "$resources_path"/cacert.pem -L -s -o /tmp/"${update_name}${update_version}"/EmbeddedOSFirmware.pkg http://swcdn.apple.com/content/downloads/${update_url}/EmbeddedOSFirmware.pkg
echo -e "EmbeddedOSFirmware_pkg=\"1\"" >> /tmp/"${update_name}${update_version}"/Catalog.sh
fi
if [[ ! "$SecureBoot_pkg" == "1" ]]; then
"$resources_path"/curl --cacert "$resources_path"/cacert.pem -L -s -o /tmp/"${update_name}${update_version}"/SecureBoot.pkg http://swcdn.apple.com/content/downloads/${update_url}/SecureBoot.pkg
echo -e "SecureBoot_pkg=\"1\"" >> /tmp/"${update_name}${update_version}"/Catalog.sh
fi
if [[ ! "$macOSUpd_pkg" == "1" ]]; then
"$resources_path"/curl --cacert "$resources_path"/cacert.pem -L -s -o /tmp/"${update_name}${update_version}"/${update_name}${update_version}.pkg http://swcdn.apple.com/content/downloads/${update_url}/${update_name}${update_version}.pkg
echo -e "macOSUpd_pkg=\"1\"" >> /tmp/"${update_name}${update_version}"/Catalog.sh
fi
if [[ ! "$macOSUpd_RecoveryHDUpdate_pkg" == "1" ]]; then
"$resources_path"/curl --cacert "$resources_path"/cacert.pem -L -s -o /tmp/"${update_name}${update_version}"/${update_name}${update_version}.RecoveryHDUpdate.pkg http://swcdn.apple.com/content/downloads/${update_url}/${update_name}${update_version}.RecoveryHDUpdate.pkg
echo -e "macOSUpd_RecoveryHDUpdate_pkg=\"1\"" >> /tmp/"${update_name}${update_version}"/Catalog.sh
fi
if [[ ! "$Distribution_dist" == "1" ]]; then
"$resources_path"/curl --cacert "$resources_path"/cacert.pem -L -s -o /tmp/"${update_name}${update_version}"/${update_key}.dist https://swdist.apple.com/content/downloads/${update_url}/${update_key}.English.dist
echo -e "Distribution_dist=\"1\"" >> /tmp/"${update_name}${update_version}"/Catalog.sh
fi
echo -e "update_download=\"2\"" >> /tmp/"${update_name}${update_version}"/Catalog.sh
echo -e $(date "+%b %m %H:%M:%S") ${move_up}${erase_line}${text_success}"+ Downloaded update files."${erase_style}
}
Prepare_Update()
{
echo -e $(date "+%b %m %H:%M:%S") ${text_progress}"> Preparing update."${erase_style}
echo -e "update_prepare=\"1\"" >> /tmp/"${update_name}${update_version}"/Catalog.sh
sed -i '' 's|<pkg-ref id="com\.apple\.pkg\.update\.os\.10\.14\.[0-9]\{1,\}Patch\.[a-zA-Z0-9]\{1,\}" auth="Root" packageIdentifier="com\.apple\.pkg\.update\.os\.10\.14\.[0-9]\{1,\}\.[a-zA-Z0-9]\{1,\}" onConclusion="RequireRestart">macOSUpd10\.14\.[0-9]\{1,\}Patch\.pkg<\/pkg-ref>||' /tmp/"${update_name}${update_version}"/${update_key}.dist
if [[ ! "$productbuild" == "1" ]]; then
Output_Off productbuild --distribution /tmp/"${update_name}${update_version}"/${update_key}.dist --package-path /tmp/"${update_name}${update_version}" "$save_folder/${update_name}${update_version}.pkg"
echo -e "productbuild=\"1\"" >> /tmp/"${update_name}${update_version}"/Catalog.sh
fi
echo -e "update_prepare=\"2\"" >> /tmp/"${update_name}${update_version}"/Catalog.sh
echo -e $(date "+%b %m %H:%M:%S") ${move_up}${erase_line}${text_success}"+ Prepared update."${erase_style}
}
End()
{
echo -e $(date "+%b %m %H:%M:%S") ${text_progress}"> Removing temporary files."${erase_style}
if [[ "$installer_prepare" == "2" ]]; then
Output_Off rm -R /tmp/"${!installer_name}"
fi
if [[ "$update_prepare" == "2" ]]; then
Output_Off rm -R /tmp/"${update_name}${update_version}"
fi
echo -e $(date "+%b %m %H:%M:%S") ${move_up}${erase_line}${text_success}"+ Removed temporary files."${erase_style}
echo -e $(date "+%b %m %H:%M:%S") ${text_message}"/ Thank you for using macOS Downloader."${erase_style}
Input_On
exit
}
Input_Off
Escape_Variables
Parameter_Variables
Path_Variables
Check_Environment
Check_Resources
Check_Volume_Version
Check_Volume_Support
Input_Folder
Check_Write
Input_Version
End