mirror of
https://github.com/luchina-gabriel/OSX-PROXMOX.git
synced 2024-11-29 13:05:15 +01:00
1539 lines
56 KiB
Bash
Executable File
1539 lines
56 KiB
Bash
Executable File
#!/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 legal@luchina.com.br
|
||
#
|
||
# 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="202209112045"
|
||
OCVERSION="0.8.4"
|
||
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
|
||
if [ `pveversion | grep -i 7.2 | wc -l` -eq 1 ]
|
||
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 initcall_blacklist=sysfb_init"/g' /etc/default/grub
|
||
else
|
||
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
|
||
fi
|
||
|
||
if [ ${OSX_PLATFORM} == "INTEL" ]
|
||
then
|
||
if [ `pveversion | grep -i 7.2 | wc -l` -eq 1 ]
|
||
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 initcall_blacklist=sysfb_init"/g' /etc/default/grub
|
||
else
|
||
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
|
||
fi
|
||
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 " 6 - macOS Ventura - 13"
|
||
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 -e "6.1" -e "6.2" | 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/${VM_ID}.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 -e "6.1" -e "6.2" | 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/${VM_ID}.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 -e "6.1" -e "6.2" | 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/${VM_ID}.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 -e "6.1" -e "6.2" | 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/${VM_ID}.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 -e "6.1" -e "6.2" | 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/${VM_ID}.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 -e "6.1" -e "6.2" | 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/${VM_ID}.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 -e "6.1" -e "6.2" | 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/${VM_ID}.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 -e "6.1" -e "6.2" | 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/${VM_ID}.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]: "
|
||
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-monterey.log
|
||
|
||
if [ ! -e ${ISODIR}/recovery-monterey.iso ]
|
||
then
|
||
dd if=/dev/zero of=${TMPDIR}/recovery-monterey.iso bs=1M count=800 > ${LOGFILE} 2>> ${LOGFILE}
|
||
mkfs.msdos -F 32 ${TMPDIR}/recovery-monterey.iso -n MONTEREY >> ${LOGFILE} 2>> ${LOGFILE}
|
||
losetup /dev/loop0 ${TMPDIR}/recovery-monterey.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-E43C1C25D4880AD6 -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-monterey.iso ${ISODIR}
|
||
|
||
rm -rf ${TMPDIR}
|
||
echo "Download and recovery created successfully."
|
||
else
|
||
echo "Recovery image of macOS Monterey already exists."
|
||
fi
|
||
else
|
||
echo " "
|
||
echo "Skipping download and creating recovery image ..."
|
||
fi
|
||
|
||
echo " "
|
||
echo "Creating virtual machine with macOS - Monterey ..."
|
||
|
||
if [ ${OSX_PLATFORM} == 'AMD' ]
|
||
then
|
||
|
||
LOGFILE=${LOGDIR}/crt-vm-amd-monterey.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 - Monterey' \
|
||
--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-monterey.iso,cache=unsafe,size=800M > ${LOGFILE} 2>> ${LOGFILE}
|
||
|
||
## Fix for QEMU 6.1 for PCI Passthrough
|
||
if [ `qemu-system-x86_64 --version | grep -e "6.1" -e "6.2" | 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/${VM_ID}.conf
|
||
fi
|
||
|
||
fi
|
||
|
||
if [ ${OSX_PLATFORM} == 'INTEL' ]
|
||
then
|
||
|
||
LOGFILE=${LOGDIR}/crt-vm-intel-monterey.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 - Monterey' \
|
||
--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-monterey.iso,cache=unsafe,size=800M > ${LOGFILE} 2>> ${LOGFILE}
|
||
|
||
## Fix for QEMU 6.1 for PCI Passthrough
|
||
if [ `qemu-system-x86_64 --version | grep -e "6.1" -e "6.2" | 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/${VM_ID}.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 Ventura - 13
|
||
|
||
if [ ${OPT} -eq 6 ]
|
||
then
|
||
clear
|
||
echo " "
|
||
echo "macOS Ventura"
|
||
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-VENTURA]: "
|
||
read VM_NAME
|
||
|
||
if [ -z $VM_NAME ]; then VM_NAME="${DEFAULT_VM_PREFIX}VENTURA"; 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-ventura.log
|
||
##
|
||
## if [ ! -e ${ISODIR}/recovery-ventura.iso ]
|
||
## then
|
||
## dd if=/dev/zero of=${TMPDIR}/recovery-ventura.iso bs=1M count=800 > ${LOGFILE} 2>> ${LOGFILE}
|
||
## mkfs.msdos -F 32 ${TMPDIR}/recovery-ventura.iso -n VENTURA >> ${LOGFILE} 2>> ${LOGFILE}
|
||
## losetup /dev/loop0 ${TMPDIR}/recovery-ventura.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-E43C1C25D4880AD6 -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-ventura.iso ${ISODIR}
|
||
##
|
||
## rm -rf ${TMPDIR}
|
||
## echo "Download and recovery created successfully."
|
||
## else
|
||
## echo "Recovery image of macOS Ventura already exists."
|
||
## fi
|
||
## else
|
||
## echo " "
|
||
## echo "Skipping download and creating recovery image ..."
|
||
## fi
|
||
|
||
echo " "
|
||
echo -n "Please send your ISO of macOS Ventura Beta to Proxmox and replace in config of your VM!"
|
||
echo " "
|
||
|
||
echo " "
|
||
echo "Creating virtual machine with macOS - Ventura ..."
|
||
|
||
if [ ${OSX_PLATFORM} == 'AMD' ]
|
||
then
|
||
|
||
LOGFILE=${LOGDIR}/crt-vm-amd-ventura.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 - Ventura' \
|
||
--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 > ${LOGFILE} 2>> ${LOGFILE}
|
||
## --ide2 local:iso/recovery-ventura.iso,cache=unsafe,size=800M > ${LOGFILE} 2>> ${LOGFILE}
|
||
|
||
## Fix for QEMU 6.1 for PCI Passthrough
|
||
if [ `qemu-system-x86_64 --version | grep -e "6.1" -e "6.2" | 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/${VM_ID}.conf
|
||
fi
|
||
|
||
fi
|
||
|
||
if [ ${OSX_PLATFORM} == 'INTEL' ]
|
||
then
|
||
|
||
LOGFILE=${LOGDIR}/crt-vm-intel-ventura.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 - Ventura' \
|
||
--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 > ${LOGFILE} 2>> ${LOGFILE}
|
||
## --ide2 local:iso/recovery-ventura.iso,cache=unsafe,size=800M > ${LOGFILE} 2>> ${LOGFILE}
|
||
|
||
## Fix for QEMU 6.1 for PCI Passthrough
|
||
if [ `qemu-system-x86_64 --version | grep -e "6.1" -e "6.2" | 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/${VM_ID}.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
|
||
|
||
################################################################################################################################################################################################
|
||
################################################################################################################################################################################################
|
||
################################################################################################################################################################################################
|
||
|
||
## Add Promox VE NO Subscription repository
|
||
if [ ${OPT} -eq 200 ]
|
||
then
|
||
|
||
clear
|
||
|
||
LOGFILE=${LOGDIR}/add-repo-pve-no-subscription.log
|
||
|
||
echo " "
|
||
echo "Adding 'Promox VE NO Subscription repository' ..."
|
||
echo " "
|
||
echo "Please wait ..."
|
||
echo " "
|
||
|
||
echo "deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription" > /etc/apt/sources.list.d/pxve-no-sub.list
|
||
apt update -y >> ${LOGFILE} 2>> ${LOGFILE}
|
||
if [ $? -ne 0 ]; then echo "apt update error - check log file ${LOGFILE}"; exit; fi;
|
||
|
||
echo "Promox VE NO Subscription repository has been successfully added."
|
||
exit
|
||
|
||
fi
|
||
|
||
################################################################################################################################################################################################
|
||
################################################################################################################################################################################################
|
||
################################################################################################################################################################################################
|
||
|
||
## Update Opencore ISO
|
||
|
||
if [ ${OPT} -eq 201 ]
|
||
then
|
||
|
||
clear
|
||
|
||
LOGFILE=${LOGDIR}/update-opencore-iso.log
|
||
|
||
echo " "
|
||
echo "Copying 'opencore-osx-proxmox-vm.iso' to '/var/lib/vz/template/iso'"
|
||
echo " "
|
||
|
||
cd /var/lib/vz/template/iso/ > ${LOGFILE} 2>> ${LOGFILE}
|
||
rm -f opencore-osx-proxmox-vm.iso >> ${LOGFILE} 2>> ${LOGFILE}
|
||
wget https://github.com/luchina-gabriel/OSX-PROXMOX/raw/main/EFI/opencore-osx-proxmox-vm.iso >> ${LOGFILE} 2>> ${LOGFILE}
|
||
cd ~
|
||
|
||
echo "Please wait ..."
|
||
echo "Copy of 'opencore-osx-proxmox-vm.iso' completed!"
|
||
echo " "
|
||
|
||
exit
|
||
|
||
fi
|
||
|
||
################################################################################################################################################################################################
|
||
################################################################################################################################################################################################
|
||
################################################################################################################################################################################################
|
||
|
||
## Clear ALL macOS Recovery Images
|
||
|
||
if [ ${OPT} -eq 202 ]
|
||
then
|
||
|
||
clear
|
||
|
||
echo " "
|
||
echo "Clearing all macOS Recovery Images in '/var/lib/vz/template/iso'"
|
||
echo " "
|
||
|
||
rm -f /var/lib/vz/template/iso/recovery-*.iso
|
||
rm -f ${LOGDIR}/crt-recovery-*.log
|
||
|
||
echo "Please wait ..."
|
||
echo "Clear of ALL macOS Recovery Images completed!"
|
||
echo " "
|
||
|
||
exit
|
||
|
||
fi
|
||
|
||
################################################################################################################################################################################################
|
||
################################################################################################################################################################################################
|
||
################################################################################################################################################################################################
|
||
|
||
################################################################################################################################################################################################
|
||
################################################################################################################################################################################################
|
||
################################################################################################################################################################################################
|
||
|
||
## Remove Proxmox Subscription Notice
|
||
|
||
if [ ${OPT} -eq 203 ]
|
||
then
|
||
|
||
clear
|
||
|
||
echo " "
|
||
echo "Removing Proxmox Subscription Notice..."
|
||
echo " "
|
||
|
||
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 && systemctl restart pveproxy.service
|
||
|
||
echo "Please wait ..."
|
||
echo "Remove of Proxmox Subscription Notice completed!"
|
||
echo " "
|
||
|
||
exit
|
||
|
||
fi
|
||
|
||
################################################################################################################################################################################################
|
||
################################################################################################################################################################################################
|
||
################################################################################################################################################################################################
|
||
|
||
################################################################################################################################################################################################
|
||
################################################################################################################################################################################################
|
||
################################################################################################################################################################################################
|
||
|
||
## Enable macOS in Cloud (VultR Provider)
|
||
|
||
if [ ${OPT} -eq 204 ]
|
||
then
|
||
|
||
clear
|
||
|
||
LOGFILE=${LOGDIR}/activate-macOS-in-cloud-vultr.log
|
||
|
||
echo " "
|
||
echo "Enabling macOS in Cloud (VultR Provider)"
|
||
echo " "
|
||
echo "Please wait ..."
|
||
echo " "
|
||
|
||
echo -e "\n## Interface for VMs \nauto vmbr1
|
||
iface vmbr1 inet static
|
||
address 192.168.1.1
|
||
netmask 255.255.255.0
|
||
bridge_ports none
|
||
bridge_stp off
|
||
bridge_fd 0
|
||
\n
|
||
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
|
||
post-up iptables -t nat -A POSTROUTING -s '192.168.1.0/24' -o vmbr0 -j MASQUERADE
|
||
post-down iptables -t nat -D POSTROUTING -s '192.168.1.0/24' -o vmbr0 -j MASQUERADE" >> /etc/network/interfaces
|
||
|
||
ifup vmbr1 >> ${LOGFILE} 2>> ${LOGFILE}
|
||
|
||
apt -y update >> ${LOGFILE} 2>> ${LOGFILE}
|
||
apt -y install sysstat net-tools isc-dhcp-server >> ${LOGFILE} 2>> ${LOGFILE}
|
||
|
||
sed -i 's/INTERFACESv4=""/INTERFACESv4="vmbr1"/g' /etc/default/isc-dhcp-server
|
||
|
||
cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.backup
|
||
|
||
echo 'subnet 192.168.1.0 netmask 255.255.255.0 {
|
||
range 192.168.1.10 192.168.1.100;
|
||
option routers 192.168.1.1;
|
||
option subnet-mask 255.255.255.0;
|
||
default-lease-time 600;
|
||
max-lease-time 7200;
|
||
ddns-update-style none;
|
||
authoritative;
|
||
option domain-name-servers 8.8.8.8,8.8.4.4;
|
||
option domain-name "local";
|
||
}' > /etc/dhcp/dhcpd.conf
|
||
|
||
echo " "
|
||
echo "Enable of macOS in Cloud (VultR Provider) completed!"
|
||
echo " "
|
||
echo "Your server are reboot in 5s"
|
||
|
||
sleep 5s && reboot
|
||
|
||
fi
|
||
|
||
################################################################################################################################################################################################
|
||
################################################################################################################################################################################################
|
||
################################################################################################################################################################################################
|
||
|
||
## Option for QUIT PROGRAM
|
||
if [ ${OPT} -eq 0 ]
|
||
then
|
||
exit
|
||
fi
|
||
|
||
done
|