forked from luchina-gabriel/OSX-PROXMOX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup
executable file
·1333 lines (1049 loc) · 48.5 KB
/
setup
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
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#
# Script: setup
#
# Author: Gabriel Luchina
# https://luchina.com.br
#
# COPYRIGHT - 2021, 2022
#
# All rights reserved - You may not copy, reproduce, distribute, publish, display, perform, modify,
# create derivative works, transmit, or in any way exploit any such content, nor may you distribute
# any part of this content over any network, including a local area network, sell or offer it for
# sale, or use such content to construct any kind of database.
#
# You may not alter or remove any copyright or other notice from copies of the content on any scripts
# in the solution of 'OSX-PROXMOX Solution - GABRIEL LUCHINA'.
#
# Copying or storing any content except as provided above is expressly prohibited without prior
# written permission of copyright holder identified in the individual content’s copyright notice.
#
# For permission to use the content 'OSX-PROXMOX Solution - GABRIEL LUCHINA',
# please contact [email protected]
#
# FOR DEV/STUDENT ONLY PURPOSES - NOT COMERCIAL
#
# Credits:
# https://github.com/acidanthera/OpenCorePkg
# https://github.com/corpnewt/MountEFI
################################################################################################################################################################################################
################################################################################################################################################################################################
################################################################################################################################################################################################
clear
if [ `pveversion | grep "pve-manager/7" | wc -l` -ne 1 ]
then
echo "This version of Proxmox Virtual Environment are not supported"
echo "Please, utilize version: 7.XX"
exit
fi
################################################################################################################################################################################################
################################################################################################################################################################################################
################################################################################################################################################################################################
SCRIPT_DIR=/root/OSX-PROXMOX
LOGDIR=${SCRIPT_DIR}/logs
TMPDIR=${SCRIPT_DIR}/tmp
ISODIR=/var/lib/vz/template/iso/
HACKPXVERSION="202206132324"
OCVERSION="0.8.1"
DEFAULT_VM_PREFIX="HACK-"
DEFAULT_RAM_SIZE=4096
if [ `lscpu | grep "Vendor ID" | grep -i amd | wc -l` -eq 1 ]; then OSX_PLATFORM="AMD"; else OSX_PLATFORM="INTEL"; fi
if [ ! -e ${TMPDIR} ]; then mkdir ${TMPDIR}; fi;
if [ ! -e ${LOGDIR} ]; then mkdir ${LOGDIR}; fi;
################################################################################################################################################################################################
################################################################################################################################################################################################
################################################################################################################################################################################################
if [ ! -e /etc/pve/qemu-server/.osx-proxmox ]
then
mkdir -p ${LOGDIR}
LOGFILE=${LOGDIR}/prerequisites-setup.log
echo " "
echo "OSX-PROXMOX (Version ${HACKPXVERSION}) - GABRIEL LUCHINA - https://osx-proxmox.com"
echo " "
echo "Prerequisites have not yet been installed and configured on this HOST."
echo " "
echo "Running the prerequisites and at the end your HOST will be rebooted ..."
echo " "
echo " "
cp ${SCRIPT_DIR}/EFI/*.iso /var/lib/vz/template/iso
echo "alias osx-setup='${SCRIPT_DIR}/setup'" >> /root/.bashrc
echo -e "LANG=en_US.UTF-8\nLC_ALL=en_US.UTF-8" > /etc/environment
echo "set mouse-=a" > ~/.vimrc
if [ -e /etc/apt/sources.list.d/pve-enterprise.list ]; then rm -rf /etc/apt/sources.list.d/pve-enterprise.list; fi;
apt-get update > ${LOGFILE} 2>> ${LOGFILE}
if [ $? -ne 0 ]
then
echo "Error with 'apt-get update' ..."
echo "Trying to change /etc/apt/sources.list"
sed -i 's/ftp.br.debian.org/ftp.debian.org/g' /etc/apt/sources.list
echo "Retrying 'apt-get update'"
apt-get update >> ${LOGFILE} 2>> ${LOGFILE}
if [ $? -ne 0 ]; then echo "Error with `apt-get update ...`"; exit; fi
fi
apt install vim unzip zip sysstat parted wget iptraf git htop -y >> ${LOGFILE} 2>> ${LOGFILE}
if [ $? -ne 0 ]; then echo "Error with `apt-get install ...`"; exit; fi
sed -i 's/GRUB_TIMEOUT=5/GRUB_TIMEOUT=0/g' /etc/default/grub
if [ ${OSX_PLATFORM} == "AMD" ]
then
sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="quiet"/GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on iommu=pt video=vesafb:off video=efifb:off"/g' /etc/default/grub
fi
if [ ${OSX_PLATFORM} == "INTEL" ]
then
sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="quiet"/GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt video=vesafb:off video=efifb:off"/g' /etc/default/grub
echo "options kvm-intel nested=Y" > /etc/modprobe.d/kvm-intel.conf
fi
echo -e "vfio\nvfio_iommu_type1\nvfio_pci\nvfio_virqfd\n" >> /etc/modules
echo -e "blacklist nouveau\nblacklist nvidia\nblacklist snd_hda_codec_hdmi\nblacklist snd_hda_intel\nblacklist snd_hda_codec\nblacklist snd_hda_core\nblacklist radeon\nblacklist amdgpu\n" >> /etc/modprobe.d/pve-blacklist.conf
echo "options kvm ignore_msrs=Y report_ignored_msrs=0" > /etc/modprobe.d/kvm.conf
echo "options vfio_iommu_type1 allow_unsafe_interrupts=1" > /etc/modprobe.d/iommu_unsafe_interrupts.conf
sed -i.backup -z "s/res === null || res === undefined || \!res || res\n\t\t\t.data.status.toLowerCase() \!== 'active'/false/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
touch /etc/pve/qemu-server/.osx-proxmox
update-grub >> ${LOGFILE} 2>> ${LOGFILE}
echo " "
echo " "
echo "... Successfully completed prerequisite process, your HOST will restart within 15s."
echo " "
echo "After rebooting, RUN: osx-setup"
echo " "
echo " "
sleep 15s && reboot
fi
################################################################################################################################################################################################
################################################################################################################################################################################################
################################################################################################################################################################################################
while [ true ]
do
NEXTID=`pvesh get /cluster/nextid`
clear
echo "#######################################################"
echo "################ O S X - P R O X M O X ################"
echo "############### https://osx-proxmox.com ###############"
echo "################ version: ${HACKPXVERSION} ################"
echo "#######################################################"
echo " "
echo " Enter the macOS version to be installed:"
echo " "
echo " 1 - macOS High Sierra - 10.13"
echo " 2 - macOS Mojave - 10.14"
echo " 3 - macOS Catalina - 10.15"
echo " 4 - macOS Big Sur - 11"
echo " 5 - macOS Monterey - 12"
echo " ? - macOS Ventura - 13 (coming soon)"
echo " "
echo " Next VM ID: ${NEXTID}"
echo " Opencore version: ${OCVERSION}"
echo " "
echo " 200 - Add Promox VE NO Subscription repository"
echo " 201 - Update Opencore ISO"
echo " 202 - Clear ALL macOS Recovery Images"
echo " 203 - Remove Proxmox Subscription Notice"
echo " 204 - Enable macOS in Cloud (VultR Provider)"
echo " "
echo " 0 - Quit (or press ENTER only)"
echo " "
echo -n " Option: "
read OPT
if [ -z $OPT ]
then
exit
fi
## Regular Expression for check integer number in size disk
re='^[0-9]+$'
################################################################################################################################################################################################
################################################################################################################################################################################################
################################################################################################################################################################################################
## macOS High Sierra - 10.13
if [ ${OPT} -eq 1 ]
then
clear
echo " "
echo "macOS High Sierra"
echo " "
echo -n "Enter the VM ID [or ENTER to automatically generate (${NEXTID})]: "
read VM_ID
if [ -z $VM_ID ]; then VM_ID=$NEXTID; fi;
echo " "
echo -n "Enter VM Name [or ENTER for Default: HACK-HIGHSIERRA]: "
read VM_NAME
if [ -z $VM_NAME ]; then VM_NAME="${DEFAULT_VM_PREFIX}HIGHSIERRA"; fi;
echo " "
echo -n "Enter a disk size [INTEGER] [or ENTER for Default: 64 Gb]: "
read SIZEDISK
if [ -z $SIZEDISK ]; then SIZEDISK=64; fi;
if ! [[ $SIZEDISK =~ $re ]] ; then echo "ERROR! SIZEDISK MUST HAVE INTEGER NUMBER!"; exit; fi;
echo " "
echo "Storages available:"
echo " "
for stg in `pvesh get storage --noborder --noheader`
do
echo " - ${stg}"
done
echo " "
echo -n "Enter which storage to create the VM [or ENTER for Default: local-lvm]: "
read STORAGECRTVM
if [ -z $STORAGECRTVM ]; then STORAGECRTVM="local-lvm"; fi;
echo " "
echo -n "Allocate CPU cores [Need Power of 2] [or ENTER for Default: 4]: "
read PROC_COUNT
if [ -z $PROC_COUNT ]; then PROC_COUNT=4; fi;
echo " "
echo -n "Allocate RAM [MiB] [Default: 4096]: "
read RAM_SIZE
if [ -z $RAM_SIZE ]; then RAM_SIZE=$DEFAULT_RAM_SIZE; fi;
echo " "
echo -n "Do you want to download and create the recovery image? [Y/N] [or ENTER for Default: Y]: "
read CRTRECODISK
if [ -z $CRTRECODISK ]; then CRTRECODISK="Y"; fi;
if [ "${CRTRECODISK}" == "Y" ] || [ "${CRTRECODISK}" == "y" ]
then
echo " "
echo "Downloading and creating the recovery image for installation ..."
LOGFILE=${LOGDIR}/crt-recovery-highsierra.log
if [ ! -e ${ISODIR}/recovery-highsierra.iso ]
then
dd if=/dev/zero of=${TMPDIR}/recovery-highsierra.iso bs=1M count=800 > ${LOGFILE} 2>> ${LOGFILE}
mkfs.msdos -F 32 ${TMPDIR}/recovery-highsierra.iso -n HIGHSIERRA >> ${LOGFILE} 2>> ${LOGFILE}
losetup /dev/loop0 ${TMPDIR}/recovery-highsierra.iso >> ${LOGFILE} 2>> ${LOGFILE}
mkdir -p /mnt/APPLE >> ${LOGFILE} 2>> ${LOGFILE}
mount /dev/loop0 /mnt/APPLE >> ${LOGFILE} 2>> ${LOGFILE}
mkdir /mnt/APPLE/com.apple.recovery.boot >> ${LOGFILE} 2>> ${LOGFILE}
cd /mnt/APPLE/com.apple.recovery.boot >> ${LOGFILE} 2>> ${LOGFILE}
python3.9 ${SCRIPT_DIR}/tools/macrecovery/macrecovery.py -b Mac-BE088AF8C5EB4FA2 -m 00000000000J80300 download >> ${LOGFILE} 2>> ${LOGFILE}
cd ${SCRIPT_DIR}
umount /mnt/APPLE >> ${LOGFILE} 2>> ${LOGFILE}
rmdir /mnt/APPLE
losetup -d /dev/loop0 >> ${LOGFILE} 2>> ${LOGFILE}
mv ${TMPDIR}/recovery-highsierra.iso ${ISODIR}
rm -rf ${TMPDIR}
echo "Download and recovery created successfully."
else
echo "Recovery image of macOS High Sierra already exists."
fi
else
echo " "
echo "Skipping download and creating recovery image ..."
fi
echo " "
echo "Creating virtual machine with macOS - High Sierra ..."
if [ ${OSX_PLATFORM} == 'AMD' ]
then
LOGFILE=${LOGDIR}/crt-vm-amd-highsierra.log
qm create ${VM_ID} \
--agent 1 \
--args '-device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" -smbios type=2 -device usb-kbd,bus=ehci.0,port=2 -device usb-mouse,bus=ehci.0,port=3 -cpu Penryn,kvm=on,vendor=GenuineIntel,+kvm_pv_unhalt,+kvm_pv_eoi,+hypervisor,+invtsc,+ssse3,+sse4.2,+popcnt,+avx,+avx2,+aes,+fma,+bmi1,+bmi2,+xsave,+xsaveopt,check' \
--autostart 0 \
--balloon 0 \
--bios ovmf \
--boot 'order=ide0;sata0' \
--cores ${PROC_COUNT} \
--description ' Hackintosh VM - High Sierra' \
--efidisk0 ${STORAGECRTVM}:4 \
--machine q35 \
--memory ${RAM_SIZE} \
--name ${VM_NAME} \
--net0 vmxnet3,bridge=vmbr0 \
--numa 0 \
--onboot 0 \
--ostype other \
--sockets 1 \
--start 0 \
--tablet 1 \
--vga vmware \
--vmgenid 1 \
--scsihw virtio-scsi-pci \
--sata0 ${STORAGECRTVM}:${SIZEDISK},cache=none,ssd=1,discard=on \
--ide0 local:iso/opencore-osx-proxmox-vm.iso,cache=unsafe,size=80M \
--ide2 local:iso/recovery-highsierra.iso,cache=unsafe,size=800M > ${LOGFILE} 2>> ${LOGFILE}
## Fix for QEMU 6.1 for PCI Passthrough
if [ `qemu-system-x86_64 --version | grep "6.1" | wc -l` -eq 1 ]
then
sed -i 's/+bmi2,+xsave,+xsaveopt,check/+bmi2,+xsave,+xsaveopt,check -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off/g' /etc/pve/qemu-server/${NEXTID}.conf
fi
fi
if [ ${OSX_PLATFORM} == 'INTEL' ]
then
LOGFILE=${LOGDIR}/crt-vm-intel-highsierra.log
qm create ${VM_ID} \
--agent 1 \
--args '-device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" -smbios type=2 -device usb-kbd,bus=ehci.0,port=2 -device usb-mouse,bus=ehci.0,port=3 -cpu host,kvm=on,vendor=GenuineIntel,+kvm_pv_unhalt,+kvm_pv_eoi,+hypervisor,+invtsc' \
--autostart 0 \
--balloon 0 \
--bios ovmf \
--boot 'order=ide0;sata0' \
--cores ${PROC_COUNT} \
--description ' Hackintosh VM - High Sierra' \
--efidisk0 ${STORAGECRTVM}:4 \
--machine q35 \
--memory ${RAM_SIZE} \
--name ${VM_NAME} \
--net0 vmxnet3,bridge=vmbr0 \
--numa 0 \
--onboot 0 \
--ostype other \
--sockets 1 \
--start 0 \
--tablet 1 \
--vga vmware \
--vmgenid 1 \
--scsihw virtio-scsi-pci \
--sata0 ${STORAGECRTVM}:${SIZEDISK},cache=none,ssd=1,discard=on \
--ide0 local:iso/opencore-osx-proxmox-vm.iso,cache=unsafe,size=80M \
--ide2 local:iso/recovery-highsierra.iso,cache=unsafe,size=800M > ${LOGFILE} 2>> ${LOGFILE}
## Fix for QEMU 6.1 for PCI Passthrough
if [ `qemu-system-x86_64 --version | grep "6.1" | wc -l` -eq 1 ]
then
sed -i 's/+kvm_pv_eoi,+hypervisor,+invtsc/+kvm_pv_eoi,+hypervisor,+invtsc -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off/g' /etc/pve/qemu-server/${NEXTID}.conf
fi
fi
echo "Virtual machine (${VM_NAME}) created successfully."
echo " "
echo "Access the Proxmox Web Panel to continue with the installation ..."
echo "https://`ip address show vmbr0 | grep -w "inet" | awk -F " " '{ print $2 }' | awk -F "/" '{ print $1 }'`:8006"
echo " "
exit
fi
################################################################################################################################################################################################
################################################################################################################################################################################################
################################################################################################################################################################################################
## macOS Mojave - 10.14
if [ ${OPT} -eq 2 ]
then
clear
echo " "
echo "macOS Mojave"
echo " "
echo -n "Enter the VM ID [or ENTER to automatically generate (${NEXTID})]: "
read VM_ID
if [ -z $VM_ID ]; then VM_ID=$NEXTID; fi;
echo " "
echo -n "Enter VM Name [or ENTER for Default: HACK-MOJAVE]: "
read VM_NAME
if [ -z $VM_NAME ]; then VM_NAME="${DEFAULT_VM_PREFIX}MOJAVE"; fi;
echo " "
echo -n "Enter a disk size [INTEGER] [or ENTER for Default: 64 Gb]: "
read SIZEDISK
if [ -z $SIZEDISK ]; then SIZEDISK=64; fi;
if ! [[ $SIZEDISK =~ $re ]] ; then echo "ERROR! SIZEDISK MUST HAVE INTEGER NUMBER!"; exit; fi;
echo " "
echo "Storages available:"
echo " "
for stg in `pvesh get storage --noborder --noheader`
do
echo " - ${stg}"
done
echo " "
echo -n "Enter which storage to create the VM [or ENTER for Default: local-lvm]: "
read STORAGECRTVM
if [ -z $STORAGECRTVM ]; then STORAGECRTVM="local-lvm"; fi;
echo " "
echo -n "Allocate CPU cores [Need Power of 2] [or ENTER for Default: 4]: "
read PROC_COUNT
if [ -z $PROC_COUNT ]; then PROC_COUNT=4; fi;
echo " "
echo -n "Allocate RAM [MiB] [or ENTER for Default: 4096]: "
read RAM_SIZE
if [ -z $RAM_SIZE ]; then RAM_SIZE=$DEFAULT_RAM_SIZE; fi;
echo " "
echo -n "Do you want to download and create the recovery image? [Y/N] [or ENTER for Default: Y]: "
read CRTRECODISK
if [ -z $CRTRECODISK ]; then CRTRECODISK="Y"; fi;
if [ "${CRTRECODISK}" == "Y" ] || [ "${CRTRECODISK}" == "y" ]
then
echo " "
echo "Downloading and creating the recovery image for installation ..."
LOGFILE=${LOGDIR}/crt-recovery-mojave.log
if [ ! -e ${ISODIR}/recovery-mojave.iso ]
then
dd if=/dev/zero of=${TMPDIR}/recovery-mojave.iso bs=1M count=800 > ${LOGFILE} 2>> ${LOGFILE}
mkfs.msdos -F 32 ${TMPDIR}/recovery-mojave.iso -n MOJAVE >> ${LOGFILE} 2>> ${LOGFILE}
losetup /dev/loop0 ${TMPDIR}/recovery-mojave.iso >> ${LOGFILE} 2>> ${LOGFILE}
mkdir -p /mnt/APPLE >> ${LOGFILE} 2>> ${LOGFILE}
mount /dev/loop0 /mnt/APPLE >> ${LOGFILE} 2>> ${LOGFILE}
mkdir /mnt/APPLE/com.apple.recovery.boot >> ${LOGFILE} 2>> ${LOGFILE}
cd /mnt/APPLE/com.apple.recovery.boot >> ${LOGFILE} 2>> ${LOGFILE}
python3.9 ${SCRIPT_DIR}/tools/macrecovery/macrecovery.py -b Mac-7BA5B2DFE22DDD8C -m 00000000000KXPG00 download >> ${LOGFILE} 2>> ${LOGFILE}
cd ${SCRIPT_DIR}
umount /mnt/APPLE >> ${LOGFILE} 2>> ${LOGFILE}
rmdir /mnt/APPLE
losetup -d /dev/loop0 >> ${LOGFILE} 2>> ${LOGFILE}
mv ${TMPDIR}/recovery-mojave.iso ${ISODIR}
rm -rf ${TMPDIR}
echo "Download and recovery created successfully."
else
echo "Recovery image of macOS Mojave already exists."
fi
else
echo " "
echo "Skipping download and creating recovery image ..."
fi
echo " "
echo "Creating virtual machine with macOS - Mojave ..."
if [ ${OSX_PLATFORM} == 'AMD' ]
then
LOGFILE=${LOGDIR}/crt-vm-amd-mojave.log
qm create ${VM_ID} \
--agent 1 \
--args '-device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" -smbios type=2 -device usb-kbd,bus=ehci.0,port=2 -device usb-mouse,bus=ehci.0,port=3 -cpu Penryn,kvm=on,vendor=GenuineIntel,+kvm_pv_unhalt,+kvm_pv_eoi,+hypervisor,+invtsc,+ssse3,+sse4.2,+popcnt,+avx,+avx2,+aes,+fma,+bmi1,+bmi2,+xsave,+xsaveopt,check' \
--autostart 0 \
--balloon 0 \
--bios ovmf \
--boot 'order=ide0;sata0' \
--cores ${PROC_COUNT} \
--description ' Hackintosh VM - Mojave' \
--efidisk0 ${STORAGECRTVM}:4 \
--machine q35 \
--memory ${RAM_SIZE} \
--name ${VM_NAME} \
--net0 vmxnet3,bridge=vmbr0 \
--numa 0 \
--onboot 0 \
--ostype other \
--sockets 1 \
--start 0 \
--tablet 1 \
--vga vmware \
--vmgenid 1 \
--scsihw virtio-scsi-pci \
--sata0 ${STORAGECRTVM}:${SIZEDISK},cache=none,ssd=1,discard=on \
--ide0 local:iso/opencore-osx-proxmox-vm.iso,cache=unsafe,size=80M \
--ide2 local:iso/recovery-mojave.iso,cache=unsafe,size=800M > ${LOGFILE} 2>> ${LOGFILE}
## Fix for QEMU 6.1 for PCI Passthrough
if [ `qemu-system-x86_64 --version | grep "6.1" | wc -l` -eq 1 ]
then
sed -i 's/+bmi2,+xsave,+xsaveopt,check/+bmi2,+xsave,+xsaveopt,check -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off/g' /etc/pve/qemu-server/${NEXTID}.conf
fi
fi
if [ ${OSX_PLATFORM} == 'INTEL' ]
then
LOGFILE=${LOGDIR}/crt-vm-intel-mojave.log
qm create ${VM_ID} \
--agent 1 \
--args '-device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" -smbios type=2 -device usb-kbd,bus=ehci.0,port=2 -device usb-mouse,bus=ehci.0,port=3 -cpu host,kvm=on,vendor=GenuineIntel,+kvm_pv_unhalt,+kvm_pv_eoi,+hypervisor,+invtsc' \
--autostart 0 \
--balloon 0 \
--bios ovmf \
--boot 'order=ide0;sata0' \
--cores ${PROC_COUNT} \
--description ' Hackintosh VM - Mojave' \
--efidisk0 ${STORAGECRTVM}:4 \
--machine q35 \
--memory ${RAM_SIZE} \
--name ${VM_NAME} \
--net0 vmxnet3,bridge=vmbr0 \
--numa 0 \
--onboot 0 \
--ostype other \
--sockets 1 \
--start 0 \
--tablet 1 \
--vga vmware \
--vmgenid 1 \
--scsihw virtio-scsi-pci \
--sata0 ${STORAGECRTVM}:${SIZEDISK},cache=none,ssd=1,discard=on \
--ide0 local:iso/opencore-osx-proxmox-vm.iso,cache=unsafe,size=80M \
--ide2 local:iso/recovery-mojave.iso,cache=unsafe,size=800M > ${LOGFILE} 2>> ${LOGFILE}
## Fix for QEMU 6.1 for PCI Passthrough
if [ `qemu-system-x86_64 --version | grep "6.1" | wc -l` -eq 1 ]
then
sed -i 's/+kvm_pv_eoi,+hypervisor,+invtsc/+kvm_pv_eoi,+hypervisor,+invtsc -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off/g' /etc/pve/qemu-server/${NEXTID}.conf
fi
fi
echo "Virtual machine (${VM_NAME}) created successfully."
echo " "
echo "Access the Proxmox Web Panel to continue with the installation ..."
echo "https://`ip address show vmbr0 | grep -w "inet" | awk -F " " '{ print $2 }' | awk -F "/" '{ print $1 }'`:8006"
echo " "
exit
fi
################################################################################################################################################################################################
################################################################################################################################################################################################
################################################################################################################################################################################################
## macOS Catalina - 10.15
if [ ${OPT} -eq 3 ]
then
clear
echo " "
echo "macOS Catalina"
echo " "
echo -n "Enter the VM ID [or ENTER to automatically generate (${NEXTID})]: "
read VM_ID
if [ -z $VM_ID ]; then VM_ID=$NEXTID; fi;
echo " "
echo -n "Enter VM Name [or ENTER for Default: HACK-CATALINA]: "
read VM_NAME
if [ -z $VM_NAME ]; then VM_NAME="${DEFAULT_VM_PREFIX}CATALINA"; fi;
echo " "
echo -n "Enter a disk size [INTEGER] [or ENTER for Default: 64 Gb]: "
read SIZEDISK
if [ -z $SIZEDISK ]; then SIZEDISK=64; fi;
if ! [[ $SIZEDISK =~ $re ]] ; then echo "ERROR! SIZEDISK MUST HAVE INTEGER NUMBER!"; exit; fi;
echo " "
echo "Storages available:"
echo " "
for stg in `pvesh get storage --noborder --noheader`
do
echo " - ${stg}"
done
echo " "
echo -n "Enter which storage to create the VM [or ENTER for Default: local-lvm]: "
read STORAGECRTVM
if [ -z $STORAGECRTVM ]; then STORAGECRTVM="local-lvm"; fi;
echo " "
echo -n "Allocate CPU cores [Need Power of 2] [or ENTER for Default: 4]: "
read PROC_COUNT
if [ -z $PROC_COUNT ]; then PROC_COUNT=4; fi;
echo " "
echo -n "Allocate RAM [MiB] [or ENTER for Default: 4096]: "
read RAM_SIZE
if [ -z $RAM_SIZE ]; then RAM_SIZE=$DEFAULT_RAM_SIZE; fi;
echo " "
echo -n "Do you want to download and create the recovery image? [Y/N] [or ENTER for Default: Y]: "
read CRTRECODISK
if [ -z $CRTRECODISK ]; then CRTRECODISK="Y"; fi;
if [ "${CRTRECODISK}" == "Y" ] || [ "${CRTRECODISK}" == "y" ]
then
echo " "
echo "Downloading and creating the recovery image for installation ..."
LOGFILE=${LOGDIR}/crt-recovery-catalina.log
if [ ! -e ${ISODIR}/recovery-catalina.iso ]
then
dd if=/dev/zero of=${TMPDIR}/recovery-catalina.iso bs=1M count=800 > ${LOGFILE} 2>> ${LOGFILE}
mkfs.msdos -F 32 ${TMPDIR}/recovery-catalina.iso -n CATALINA >> ${LOGFILE} 2>> ${LOGFILE}
losetup /dev/loop0 ${TMPDIR}/recovery-catalina.iso >> ${LOGFILE} 2>> ${LOGFILE}
mkdir -p /mnt/APPLE >> ${LOGFILE} 2>> ${LOGFILE}
mount /dev/loop0 /mnt/APPLE >> ${LOGFILE} 2>> ${LOGFILE}
mkdir /mnt/APPLE/com.apple.recovery.boot >> ${LOGFILE} 2>> ${LOGFILE}
cd /mnt/APPLE/com.apple.recovery.boot >> ${LOGFILE} 2>> ${LOGFILE}
python3.9 ${SCRIPT_DIR}/tools/macrecovery/macrecovery.py -b Mac-00BE6ED71E35EB86 -m 00000000000000000 download >> ${LOGFILE} 2>> ${LOGFILE}
cd ${SCRIPT_DIR}
umount /mnt/APPLE >> ${LOGFILE} 2>> ${LOGFILE}
rmdir /mnt/APPLE
losetup -d /dev/loop0 >> ${LOGFILE} 2>> ${LOGFILE}
mv ${TMPDIR}/recovery-catalina.iso ${ISODIR}
rm -rf ${TMPDIR}
echo "Download and recovery created successfully."
else
echo "Recovery image of macOS Catalina already exists."
fi
else
echo " "
echo "Skipping download and creating recovery image ..."
fi
echo " "
echo "Creating virtual machine with macOS - Catalina ..."
if [ ${OSX_PLATFORM} == 'AMD' ]
then
LOGFILE=${LOGDIR}/crt-vm-amd-catalina.log
qm create ${VM_ID} \
--agent 1 \
--args '-device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" -smbios type=2 -device usb-kbd,bus=ehci.0,port=2 -device usb-mouse,bus=ehci.0,port=3 -cpu Penryn,kvm=on,vendor=GenuineIntel,+kvm_pv_unhalt,+kvm_pv_eoi,+hypervisor,+invtsc,+ssse3,+sse4.2,+popcnt,+avx,+avx2,+aes,+fma,+bmi1,+bmi2,+xsave,+xsaveopt,check' \
--autostart 0 \
--balloon 0 \
--bios ovmf \
--boot 'order=ide0;virtio0' \
--cores ${PROC_COUNT} \
--description ' Hackintosh VM - Catalina' \
--efidisk0 ${STORAGECRTVM}:4 \
--machine q35 \
--memory ${RAM_SIZE} \
--name ${VM_NAME} \
--net0 vmxnet3,bridge=vmbr0 \
--numa 0 \
--onboot 0 \
--ostype other \
--sockets 1 \
--start 0 \
--tablet 1 \
--vga vmware \
--vmgenid 1 \
--scsihw virtio-scsi-pci \
--virtio0 ${STORAGECRTVM}:${SIZEDISK},cache=none,discard=on \
--ide0 local:iso/opencore-osx-proxmox-vm.iso,cache=unsafe,size=80M \
--ide2 local:iso/recovery-catalina.iso,cache=unsafe,size=800M > ${LOGFILE} 2>> ${LOGFILE}
## Fix for QEMU 6.1 for PCI Passthrough
if [ `qemu-system-x86_64 --version | grep "6.1" | wc -l` -eq 1 ]
then
sed -i 's/+bmi2,+xsave,+xsaveopt,check/+bmi2,+xsave,+xsaveopt,check -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off/g' /etc/pve/qemu-server/${NEXTID}.conf
fi
fi
if [ ${OSX_PLATFORM} == 'INTEL' ]
then
LOGFILE=${LOGDIR}/crt-vm-intel-catalina.log
qm create ${VM_ID} \
--agent 1 \
--args '-device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" -smbios type=2 -device usb-kbd,bus=ehci.0,port=2 -device usb-mouse,bus=ehci.0,port=3 -cpu host,kvm=on,vendor=GenuineIntel,+kvm_pv_unhalt,+kvm_pv_eoi,+hypervisor,+invtsc' \
--autostart 0 \
--balloon 0 \
--bios ovmf \
--boot 'order=ide0;virtio0' \
--cores ${PROC_COUNT} \
--description ' Hackintosh VM - Catalina' \
--efidisk0 ${STORAGECRTVM}:4 \
--machine q35 \
--memory ${RAM_SIZE} \
--name ${VM_NAME} \
--net0 vmxnet3,bridge=vmbr0 \
--numa 0 \
--onboot 0 \
--ostype other \
--sockets 1 \
--start 0 \
--tablet 1 \
--vga vmware \
--vmgenid 1 \
--scsihw virtio-scsi-pci \
--virtio0 ${STORAGECRTVM}:${SIZEDISK},cache=none,discard=on \
--ide0 local:iso/opencore-osx-proxmox-vm.iso,cache=unsafe,size=80M \
--ide2 local:iso/recovery-catalina.iso,cache=unsafe,size=800M > ${LOGFILE} 2>> ${LOGFILE}
## Fix for QEMU 6.1 for PCI Passthrough
if [ `qemu-system-x86_64 --version | grep "6.1" | wc -l` -eq 1 ]
then
sed -i 's/+kvm_pv_eoi,+hypervisor,+invtsc/+kvm_pv_eoi,+hypervisor,+invtsc -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off/g' /etc/pve/qemu-server/${NEXTID}.conf
fi
fi
echo "Virtual machine (${VM_NAME}) created successfully."
echo " "
echo "Access the Proxmox Web Panel to continue with the installation ..."
echo "https://`ip address show vmbr0 | grep -w "inet" | awk -F " " '{ print $2 }' | awk -F "/" '{ print $1 }'`:8006"
echo " "
exit
fi
################################################################################################################################################################################################
################################################################################################################################################################################################
################################################################################################################################################################################################
## macOS Big Sur - 11
if [ ${OPT} -eq 4 ]
then
clear
echo " "
echo "macOS Big Sur"
echo " "
echo -n "Enter the VM ID [or ENTER to automatically generate (${NEXTID})]: "
read VM_ID
if [ -z $VM_ID ]; then VM_ID=$NEXTID; fi;
echo " "
echo -n "Enter VM Name [or ENTER for Default: HACK-BIGSUR]: "
read VM_NAME
if [ -z $VM_NAME ]; then VM_NAME="${DEFAULT_VM_PREFIX}BIG-SUR"; fi;
echo " "
echo -n "Enter a disk size [INTEGER] [or ENTER for Default: 64 Gb]: "
read SIZEDISK
if [ -z $SIZEDISK ]; then SIZEDISK=64; fi;
if ! [[ $SIZEDISK =~ $re ]] ; then echo "ERROR! SIZEDISK MUST HAVE INTEGER NUMBER!"; exit; fi;
echo " "
echo "Storages available:"
echo " "
for stg in `pvesh get storage --noborder --noheader`
do
echo " - ${stg}"
done
echo " "
echo -n "Enter which storage to create the VM [or ENTER for Default: local-lvm]: "
read STORAGECRTVM
if [ -z $STORAGECRTVM ]; then STORAGECRTVM="local-lvm"; fi;
echo " "
echo -n "Allocate CPU cores [Need Power of 2] [or ENTER for Default: 4]: "
read PROC_COUNT
if [ -z $PROC_COUNT ]; then PROC_COUNT=4; fi;
echo " "
echo -n "Allocate RAM [MiB] [Default: 4096]: "
read RAM_SIZE
if [ -z $RAM_SIZE ]; then RAM_SIZE=$DEFAULT_RAM_SIZE; fi;
echo " "
echo -n "Do you want to download and create the recovery image? [Y/N] [or ENTER for Default: Y]: "
read CRTRECODISK
if [ -z $CRTRECODISK ]; then CRTRECODISK="Y"; fi;
if [ "${CRTRECODISK}" == "Y" ] || [ "${CRTRECODISK}" == "y" ]
then
echo " "
echo "Downloading and creating the recovery image for installation ..."
LOGFILE=${LOGDIR}/crt-recovery-bigsur.log
if [ ! -e ${ISODIR}/recovery-bigsur.iso ]
then
dd if=/dev/zero of=${TMPDIR}/recovery-bigsur.iso bs=1M count=800 > ${LOGFILE} 2>> ${LOGFILE}
mkfs.msdos -F 32 ${TMPDIR}/recovery-bigsur.iso -n BIGSUR >> ${LOGFILE} 2>> ${LOGFILE}
losetup /dev/loop0 ${TMPDIR}/recovery-bigsur.iso >> ${LOGFILE} 2>> ${LOGFILE}
mkdir -p /mnt/APPLE >> ${LOGFILE} 2>> ${LOGFILE}
mount /dev/loop0 /mnt/APPLE >> ${LOGFILE} 2>> ${LOGFILE}
mkdir /mnt/APPLE/com.apple.recovery.boot >> ${LOGFILE} 2>> ${LOGFILE}
cd /mnt/APPLE/com.apple.recovery.boot >> ${LOGFILE} 2>> ${LOGFILE}
python3.9 ${SCRIPT_DIR}/tools/macrecovery/macrecovery.py -b Mac-42FD25EABCABB274 -m 00000000000000000 download >> ${LOGFILE} 2>> ${LOGFILE}
cd ${SCRIPT_DIR}
umount /mnt/APPLE >> ${LOGFILE} 2>> ${LOGFILE}
rmdir /mnt/APPLE
losetup -d /dev/loop0 >> ${LOGFILE} 2>> ${LOGFILE}
mv ${TMPDIR}/recovery-bigsur.iso ${ISODIR}
rm -rf ${TMPDIR}
echo "Download and recovery created successfully."
else
echo "Recovery image of macOS Big Sur already exists."
fi
else
echo " "
echo "Skipping download and creating recovery image ..."
fi
echo " "
echo "Creating virtual machine with macOS - Big Sur ..."
if [ ${OSX_PLATFORM} == 'AMD' ]
then
LOGFILE=${LOGDIR}/crt-vm-amd-bigsur.log
qm create ${VM_ID} \
--agent 1 \
--args '-device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" -smbios type=2 -device usb-kbd,bus=ehci.0,port=2 -device usb-mouse,bus=ehci.0,port=3 -cpu Penryn,kvm=on,vendor=GenuineIntel,+kvm_pv_unhalt,+kvm_pv_eoi,+hypervisor,+invtsc,+ssse3,+sse4.2,+popcnt,+avx,+avx2,+aes,+fma,+bmi1,+bmi2,+xsave,+xsaveopt,check' \
--autostart 0 \
--balloon 0 \
--bios ovmf \
--boot 'order=ide0;virtio0' \
--cores ${PROC_COUNT} \
--description ' Hackintosh VM - Big Sur' \
--efidisk0 ${STORAGECRTVM}:4 \
--machine q35 \
--memory ${RAM_SIZE} \
--name ${VM_NAME} \
--net0 vmxnet3,bridge=vmbr0 \
--numa 0 \
--onboot 0 \
--ostype other \
--sockets 1 \
--start 0 \
--tablet 1 \
--vga vmware \
--vmgenid 1 \
--scsihw virtio-scsi-pci \
--virtio0 ${STORAGECRTVM}:${SIZEDISK},cache=none,discard=on \
--ide0 local:iso/opencore-osx-proxmox-vm.iso,cache=unsafe,size=80M \
--ide2 local:iso/recovery-bigsur.iso,cache=unsafe,size=800M > ${LOGFILE} 2>> ${LOGFILE}
## Fix for QEMU 6.1 for PCI Passthrough
if [ `qemu-system-x86_64 --version | grep "6.1" | wc -l` -eq 1 ]
then
sed -i 's/+bmi2,+xsave,+xsaveopt,check/+bmi2,+xsave,+xsaveopt,check -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off/g' /etc/pve/qemu-server/${NEXTID}.conf
fi
fi
if [ ${OSX_PLATFORM} == 'INTEL' ]
then
LOGFILE=${LOGDIR}/crt-vm-intel-bigsur.log
qm create ${VM_ID} \
--agent 1 \
--args '-device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" -smbios type=2 -device usb-kbd,bus=ehci.0,port=2 -device usb-mouse,bus=ehci.0,port=3 -cpu host,kvm=on,vendor=GenuineIntel,+kvm_pv_unhalt,+kvm_pv_eoi,+hypervisor,+invtsc' \
--autostart 0 \
--balloon 0 \
--bios ovmf \
--boot 'order=ide0;virtio0' \
--cores ${PROC_COUNT} \
--description ' Hackintosh VM - Big Sur' \
--efidisk0 ${STORAGECRTVM}:4 \
--machine q35 \
--memory ${RAM_SIZE} \
--name ${VM_NAME} \
--net0 vmxnet3,bridge=vmbr0 \
--numa 0 \
--onboot 0 \
--ostype other \
--sockets 1 \
--start 0 \
--tablet 1 \
--vga vmware \
--vmgenid 1 \
--scsihw virtio-scsi-pci \
--virtio0 ${STORAGECRTVM}:${SIZEDISK},cache=none,discard=on \
--ide0 local:iso/opencore-osx-proxmox-vm.iso,cache=unsafe,size=80M \
--ide2 local:iso/recovery-bigsur.iso,cache=unsafe,size=800M > ${LOGFILE} 2>> ${LOGFILE}
## Fix for QEMU 6.1 for PCI Passthrough
if [ `qemu-system-x86_64 --version | grep "6.1" | wc -l` -eq 1 ]
then
sed -i 's/+kvm_pv_eoi,+hypervisor,+invtsc/+kvm_pv_eoi,+hypervisor,+invtsc -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off/g' /etc/pve/qemu-server/${NEXTID}.conf
fi
fi
echo "Virtual machine (${VM_NAME}) created successfully."
echo " "
echo "Access the Proxmox Web Panel to continue with the installation ..."
echo "https://`ip address show vmbr0 | grep -w "inet" | awk -F " " '{ print $2 }' | awk -F "/" '{ print $1 }'`:8006"
echo " "
exit
fi
################################################################################################################################################################################################
################################################################################################################################################################################################
################################################################################################################################################################################################
## macOS Monterey - 12
if [ ${OPT} -eq 5 ]
then
clear
echo " "
echo "macOS Monterey"
echo " "
echo -n "Enter the VM ID [or ENTER to automatically generate (${NEXTID})]: "
read VM_ID
if [ -z $VM_ID ]; then VM_ID=$NEXTID; fi;
echo " "
echo -n "Enter VM Name [or ENTER for Default: HACK-MONTEREY]: "
read VM_NAME
if [ -z $VM_NAME ]; then VM_NAME="${DEFAULT_VM_PREFIX}MONTEREY"; fi;
echo " "
echo -n "Enter a disk size [INTEGER] [or ENTER for Default: 64 Gb]: "
read SIZEDISK
if [ -z $SIZEDISK ]; then SIZEDISK=64; fi;
if ! [[ $SIZEDISK =~ $re ]] ; then echo "ERROR! SIZEDISK MUST HAVE INTEGER NUMBER!"; exit; fi;
echo " "
echo "Storages available:"
echo " "
for stg in `pvesh get storage --noborder --noheader`
do
echo " - ${stg}"
done
echo " "
echo -n "Enter which storage to create the VM [or ENTER for Default: local-lvm]: "
read STORAGECRTVM
if [ -z $STORAGECRTVM ]; then STORAGECRTVM="local-lvm"; fi;
echo " "
echo -n "Allocate CPU cores [Need Power of 2] [or ENTER for Default: 4]: "