# Template file for 'macos' OSNAME="macos" PRETTY="MacOS" BASEDOF="-" DESCRIPTION="Work and play on your Mac are even more powerful. Elevate your presence on video calls. Access information in all-new ways. Boost gaming performance." HOMEPAGE="https://www.apple.com/macos" CREDENTIALS="-" GUEST="macos" IMAGE_TYPE="img" RELEASES="ventura sonoma monterey mojave catalina big-sur" function releases_() { echo mojave catalina big-sur monterey ventura sonoma } function generate_id() { local macRecoveryID="" local TYPE="${1}" local valid_chars=("0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F") for ((i=0; i&1 | tr ';' '\n' | awk -F'session=|;' '{print $2}' | grep 1) info=$(curl --disable -s -X POST -H "Host: osrecovery.apple.com" \ -H "Connection: close" \ -A "InternetRecovery/1.0" \ -b "session=\"${appleSession}\"" \ -H "Content-Type: text/plain" \ -d $'cid='"$(generate_id 16)"$'\nsn='${MLB}$'\nbid='${BOARD_ID}$'\nk='"$(generate_id 64)"$'\nfg='"$(generate_id 64)"$'\nos='${OS_TYPE} \ https://osrecovery.apple.com/InstallationPayload/RecoveryImage | tr ' ' '\n') downloadLink=$(echo "$info" | grep 'oscdn' | grep 'dmg') downloadSession=$(echo "$info" | grep 'expires' | grep 'dmg') chunkListLink=$(echo "$info" | grep 'oscdn' | grep 'chunklist') chunkListSession=$(echo "$info" | grep 'expires' | grep 'chunklist') if [ "${OPERATION}" == "show" ]; then test_result "${OS}" "${RELEASE}" "" "${downloadLink}" | tee -a "public/tmp_${OS}" exit 0 elif [ "${OPERATION}" == "test" ]; then CHECK=$(web_check "${downloadLink}" --header "Host: oscdn.apple.com" --header "Connection: close" --header "User-Agent: InternetRecovery/1.0" --header "Cookie: AssetToken=${downloadSession}" && echo "PASS" || echo "FAIL") test_result "${OS}" "${RELEASE}" "" "${downloadLink}" "${CHECK}" | tee -a "public/tmp_${OS}" exit 0 elif [ "${OPERATION}" == "download" ]; then echo "Downloading macOS (${RELEASE^}) RecoveryImage" echo " - URL: ${downloadLink}" web_get "${downloadLink}" "${VM_PATH}" RecoveryImage.dmg --header "Host: oscdn.apple.com" --header "Connection: close" --header "User-Agent: InternetRecovery/1.0" --header "Cookie: AssetToken=${downloadSession}" web_get "${chunkListLink}" "${VM_PATH}" RecoveryImage.chunklist --header "Host: oscdn.apple.com" --header "Connection: close" --header "User-Agent: InternetRecovery/1.0" --header "Cookie: AssetToken=${chunkListSession}" VM_PATH="$(pwd)" else if [ ! -e "${VM_PATH}/RecoveryImage.chunklist" ]; then echo "Downloading macOS (${RELEASE^}) RecoveryImage" echo " - URL: ${downloadLink}" web_get "${downloadLink}" "${VM_PATH}" RecoveryImage.dmg --header "Host: oscdn.apple.com" --header "Connection: close" --header "User-Agent: InternetRecovery/1.0" --header "Cookie: AssetToken=${downloadSession}" web_get "${chunkListLink}" "${VM_PATH}" RecoveryImage.chunklist --header "Host: oscdn.apple.com" --header "Connection: close" --header "User-Agent: InternetRecovery/1.0" --header "Cookie: AssetToken=${chunkListSession}" if ! "${CHUNKCHECK}" "${VM_PATH}" 2> /dev/null; then echo " - WARNING! Verification failed, continuing anyway" else echo " - Verification passed" fi if [ -e "${VM_PATH}/RecoveryImage.dmg" ] && [ ! -e "${VM_PATH}/RecoveryImage.img" ]; then echo " - Converting RecoveryImage.dmg" ${QEMU_IMG} convert "${VM_PATH}/RecoveryImage.dmg" -O raw "${VM_PATH}/RecoveryImage.img" 2>/dev/null fi rm "${VM_PATH}/RecoveryImage.dmg" "${VM_PATH}/RecoveryImage.chunklist" echo " - RecoveryImage.img is ready." fi echo "Downloading OpenCore & UEFI firmware" web_get "https://github.com/kholia/OSX-KVM/raw/master/OpenCore/OpenCore.qcow2" "${VM_PATH}" web_get "https://github.com/kholia/OSX-KVM/raw/master/OVMF_CODE.fd" "${VM_PATH}" if [ ! -e "${VM_PATH}/OVMF_VARS-1920x1080.fd" ]; then web_get "https://github.com/kholia/OSX-KVM/raw/master/OVMF_VARS-1920x1080.fd" "${VM_PATH}" fi fi make_vm_config RecoveryImage.img } function specific_tweaks() { echo "disk_size=\"128G\"" >> "${CONF_FILE}" echo "macos_release=\"${RELEASE}\"" >> "${CONF_FILE}" # https://github.com/quickemu-project/quickemu/issues/438 if [ "${RELEASE}" == "monterey" ]; then echo "cpu_cores=2" >> "${CONF_FILE}" fi }