From 5aa689e8ad4fe46f1a781b394486c81831f2b3d5 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Wed, 24 Feb 2021 05:12:38 +0000 Subject: WIP: Machine unique value generator --- custom/config-nopicker-custom.plist | 885 +++++++++++++++++++++++++++++++ custom/generate-unique-machine-values.sh | 172 ++++++ 2 files changed, 1057 insertions(+) create mode 100644 custom/config-nopicker-custom.plist create mode 100755 custom/generate-unique-machine-values.sh (limited to 'custom') diff --git a/custom/config-nopicker-custom.plist b/custom/config-nopicker-custom.plist new file mode 100644 index 0000000..c93ee96 --- /dev/null +++ b/custom/config-nopicker-custom.plist @@ -0,0 +1,885 @@ + + + + + + + ACPI + + Add + + + Comment + add DTGP method + Enabled + + Path + SSDT-DTGP.aml + + + Comment + Fake EC and USBX Power + Enabled + + Path + SSDT-EC.aml + + + Comment + USB 2.0 Injection + Enabled + + Path + SSDT-EHCI.aml + + + Comment + CPU AGPM Plugin=1 + Enabled + + Path + SSDT-PLUG.aml + + + Delete + + + All + + Comment + Delete CpuPm + Enabled + + OemTableId + Q3B1UG0AAAA= + TableLength + 0 + TableSignature + U1NEVA== + + + All + + Comment + Delete Cpu0Ist + Enabled + + OemTableId + Q3B1MElzdAA= + TableLength + 0 + TableSignature + U1NEVA== + + + Patch + + + Comment + _Q11 to XQ11 + Count + 1 + Enabled + + Find + X1ExMQ== + Limit + 0 + Mask + + OemTableId + + Replace + WFExMQ== + ReplaceMask + + Skip + 0 + TableLength + 0 + TableSignature + + + + Comment + _Q12 to XQ12 + Count + 1 + Enabled + + Find + X1ExMg== + Limit + 0 + Mask + + OemTableId + + Replace + WFExMg== + ReplaceMask + + Skip + 0 + TableLength + 0 + TableSignature + + + + Quirks + + FadtEnableReset + + NormalizeHeaders + + RebaseRegions + + ResetHwSig + + ResetLogoStatus + + + + Booter + + MmioWhitelist + + Quirks + + AvoidRuntimeDefrag + + DevirtualiseMmio + + DisableSingleUser + + DisableVariableWrite + + DiscardHibernateMap + + EnableSafeModeSlide + + EnableWriteUnprotector + + ForceExitBootServices + + ProtectMemoryRegions + + ProtectSecureBoot + + ProtectUefiServices + + ProvideCustomSlide + + ProvideMaxSlide + 0 + RebuildAppleMemoryMap + + SetupVirtualMap + + SignalAppleOS + + SyncRuntimePermissions + + + + DeviceProperties + + Add + + PciRoot(0x1)/Pci(0x1F,0x0) + + compatible + pci8086,2916 + device-id + + FikA + + name + pci8086,2916 + + + Delete + + PciRoot(0x0)/Pci(0x1b,0x0) + + MaximumBootBeepVolume + + + + Kernel + + Add + + + Arch + Any + BundlePath + VoodooHDA.kext + Comment + + Enabled + + ExecutablePath + Contents/MacOS/VoodooHDA + MaxKernel + + MinKernel + + PlistPath + Contents/Info.plist + + + Arch + x86_64 + BundlePath + Lilu.kext + Comment + Patch engine + Enabled + + ExecutablePath + Contents/MacOS/Lilu + MaxKernel + + MinKernel + 12.0.0 + PlistPath + Contents/Info.plist + + + Arch + x86_64 + BundlePath + VirtualSMC.kext + Comment + SMC emulator + Enabled + + ExecutablePath + Contents/MacOS/VirtualSMC + MaxKernel + + MinKernel + 12.0.0 + PlistPath + Contents/Info.plist + + + Arch + x86_64 + BundlePath + WhateverGreen.kext + Comment + Video patches + Enabled + + ExecutablePath + Contents/MacOS/WhateverGreen + MaxKernel + + MinKernel + 12.0.0 + PlistPath + Contents/Info.plist + + + BundlePath + AGPMInjector.kext + Comment + + Enabled + + ExecutablePath + + MaxKernel + + MinKernel + + PlistPath + Contents/Info.plist + + + BundlePath + USBPorts.kext + Comment + + Enabled + + ExecutablePath + + MaxKernel + + MinKernel + + PlistPath + Contents/Info.plist + + + Arch + x86_64 + BundlePath + MCEReporterDisabler.kext + Comment + AppleMCEReporter disabler + Enabled + + ExecutablePath + + MaxKernel + + MinKernel + 19.0.0 + PlistPath + Contents/Info.plist + + + Block + + + Arch + Any + Comment + + Enabled + + Identifier + com.apple.driver.AppleTyMCEDriver + MaxKernel + + MinKernel + + + + Emulate + + Cpuid1Data + + VAYFAAAAAAAAAAAAAAAAAA== + + Cpuid1Mask + + ////AAAAAAAAAAAAAAAAAA== + + + Force + + + Arch + Any + BundlePath + System/Library/Extensions/IONetworkingFamily.kext + Comment + Patch engine + Enabled + + Identifier + com.apple.iokit.IONetworkingFamily + ExecutablePath + Contents/MacOS/IONetworkingFamily + MaxKernel + 13.99.99 + MinKernel + + PlistPath + Contents/Info.plist + + + Patch + + + Base + _cpu_topology_sort + Comment + algrey - cpu_topology_sort -disable _x86_validate_topology + Count + 1 + Enabled + + Find + + 6AAA//8= + + Identifier + kernel + Limit + 0 + Mask + + /wAA//8= + + MaxKernel + 20.99.99 + MinKernel + 17.0.0 + Replace + + Dx9EAAA= + + ReplaceMask + + + Skip + 0 + + + Base + + Comment + algrey - cpuid_set_cpufamily - force CPUFAMILY_INTEL_PENRYN + Count + 1 + Enabled + + Find + + MduAPQAAAAAGdQA= + + Identifier + kernel + Limit + 0 + Mask + + /////wAAAP///wA= + + MaxKernel + 20.99.99 + MinKernel + 17.0.0 + Replace + + u7xP6njpXQAAAJA= + + ReplaceMask + + + Skip + 0 + + + Quirks + + AppleCpuPmCfgLock + + AppleXcpmCfgLock + + AppleXcpmExtraMsrs + + AppleXcpmForceBoost + + CustomSMBIOSGuid + + DisableIoMapper + + DisableLinkeditJettison + + DisableRtcChecksum + + DummyPowerManagement + + ExternalDiskIcons + + IncreasePciBarSize + + LapicKernelPanic + + PanicNoKextDump + + PowerTimeoutKernelPanic + + ThirdPartyDrives + + XhciPortLimit + + + Scheme + + FuzzyMatch + + KernelArch + x86_64 + KernelCache + Auto + + + Misc + + BlessOverride + + Boot + + ConsoleAttributes + 0 + HibernateMode + Auto + HideAuxiliary + + PickerAttributes + 1 + PickerAudioAssist + + PickerMode + External + PollAppleHotKeys + + ShowPicker + + TakeoffDelay + 0 + Timeout + 0 + + Debug + + AppleDebug + + ApplePanic + + DisableWatchDog + + DisplayDelay + 0 + DisplayLevel + 2147483650 + SerialInit + + SysReport + + Target + 3 + + Entries + + Security + + AllowNvramReset + + AllowSetDefault + + ApECID + 0 + AuthRestart + + BootProtect + None + DmgLoading + Signed + EnablePassword + + ExposeSensitiveData + 6 + HaltLevel + 2147483648 + PasswordHash + + PasswordSalt + + ScanPolicy + 0 + SecureBootModel + Disabled + Vault + Optional + + Tools + + + Arguments + + Auxiliary + + Comment + Not signed for security reasons + Enabled + + Name + UEFI Shell + Path + OpenShell.efi + + + Arguments + Shutdown + Auxiliary + + Comment + Perform shutdown + Enabled + + Name + Shutdown + Path + ResetSystem.efi + + + + NVRAM + + Add + + 4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14 + + DefaultBackgroundColor + AAAAAA== + UIScale + AQ== + + 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102 + + rtc-blacklist + + + 7C436110-AB2A-4BBB-A880-FE41995C9F82 + + SystemAudioVolume + Rg== + boot-args + -v keepsyms=1 tlbto_us=0 vti=9 + run-efi-updater + No + csr-active-config + ZwAAAA== + prev-lang:kbd + ZW4tVVM6MA== + + + Delete + + 4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14 + + UIScale + DefaultBackgroundColor + + 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102 + + rtc-blacklist + + 7C436110-AB2A-4BBB-A880-FE41995C9F82 + + boot-args + + + LegacyEnable + + LegacyOverwrite + + LegacySchema + + 7C436110-AB2A-4BBB-A880-FE41995C9F82 + + EFILoginHiDPI + EFIBluetoothDelay + LocationServicesEnabled + SystemAudioVolume + SystemAudioVolumeDB + SystemAudioVolumeSaved + bluetoothActiveControllerInfo + bluetoothInternalControllerInfo + flagstate + fmm-computer-name + nvda_drv + prev-lang:kbd + + 8BE4DF61-93CA-11D2-AA0D-00E098032B8C + + Boot0080 + Boot0081 + Boot0082 + BootNext + BootOrder + + + WriteFlash + + + PlatformInfo + + Automatic + + Generic + + AdviseWindows + + MLB + {{BOARD_SERIAL_OLD}} + ROM + + {{ROM_OLD}} + + SpoofVendor + + SystemProductName + {{DEVICE_MODEL}} + SystemSerialNumber + {{SERIAL_OLD}} + SystemUUID + {{SYSTEM_UUID_OLD}} + + UpdateDataHub + + UpdateNVRAM + + UpdateSMBIOS + + UpdateSMBIOSMode + Create + + UEFI + + APFS + + EnableJumpstart + + GlobalConnect + + HideVerbose + + JumpstartHotPlug + + MinDate + 0 + MinVersion + 0 + + Audio + + AudioCodec + 0 + AudioDevice + PciRoot(0x1)/Pci(0x1,0x0)/Pci(0x0,0x1) + AudioOut + 0 + AudioSupport + + MinimumVolume + 20 + PlayChime + + VolumeAmplifier + 0 + + ConnectDrivers + + Drivers + + VBoxHfs.efi + OpenRuntime.efi + OpenCanopy.efi + #AudioDxe.efi + #OpenUsbKbDxe.efi + #UsbMouseDxe.efi + #Ps2KeyboardDxe.efi + #Ps2MouseDxe.efi + #HiiDatabase.efi + #NvmExpressDxe.efi + #XhciDxe.efi + #ExFatDxe.efi + #PartitionDxe.efi + #CrScreenshotDxe.efi + + Input + + KeyFiltering + + KeyForgetThreshold + 5 + KeyMergeThreshold + 2 + KeySupport + + KeySupportMode + Auto + KeySwap + + PointerSupport + + PointerSupportMode + ASUS + TimerResolution + 50000 + + Output + + ClearScreenOnModeSwitch + + ConsoleMode + + DirectGopRendering + + IgnoreTextInGraphics + + ProvideConsoleGop + + ReconnectOnResChange + + ReplaceTabWithSpace + + Resolution + 1920x1080@32 + SanitiseClearScreen + + TextRenderer + BuiltinGraphics + UgaPassThrough + + + ProtocolOverrides + + AppleAudio + + AppleBootPolicy + + AppleDebugLog + + AppleEvent + + AppleFramebufferInfo + + AppleImageConversion + + AppleImg4Verification + + AppleKeyMap + + AppleRtcRam + + AppleSecureBoot + + AppleSmcIo + + AppleUserInterfaceTheme + + DataHub + + DeviceProperties + + FirmwareVolume + + HashServices + + OSInfo + + UnicodeCollation + + + Quirks + + ExitBootServicesDelay + 0 + IgnoreInvalidFlexRatio + + ReleaseUsbOwnership + + RequestBootVarRouting + + TscSyncTimeout + 0 + UnblockFsConnect + + ConnectDrivers + + + + + diff --git a/custom/generate-unique-machine-values.sh b/custom/generate-unique-machine-values.sh new file mode 100755 index 0000000..e87905c --- /dev/null +++ b/custom/generate-unique-machine-values.sh @@ -0,0 +1,172 @@ +#!/bin/bash +# ____ __ ____ ______ __ +# / __ \____ _____/ /_____ _____/ __ \/ ___/ |/ / +# / / / / __ \/ ___/ //_/ _ \/ ___/ / / /\__ \| / +# / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / | +# /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| SERIALIZER +# +# Repo: https://github.com/sickcodes/Docker-OSX/ +# Title: Mac on Docker (Docker-OSX) +# Author: Sick.Codes https://sick.codes/ +# Version: 3.1 +# License: GPLv3+ + +help_text="Usage: generate-unique-machine-values.sh + +Example: + ./generate-unique-machine-values.sh --count 1 --model="iMacPro1,1" + +General options: + --count, -n, -c Number of serials to generate + --model, -m Device model, e.g. "iMacPro1,1" + --csv Optionally change the CSV output filename. + --output-dir Optionally change the script output location. + --help, -h, help Display this help and exit + +Notes: + - Default is 1 serial for "iMacPro1,1" in the current working directory. + - CSV is double quoted. + - If you do not set a CSV filename, the output will be sent to the output-dir. + - If you do not set an output-dir, the current directory will be the output directory. + - Sourcable environment variable shell files will be written to a folder, "envs". + +Author: Sick.Codes https://sick.codes/ +Project: https://github.com/sickcodes/Docker-OSX/ +" + +MACINFOPKG_VERSION=2.1.2 + +# gather arguments +while (( "$#" )); do + case "${1}" in + + --help | -h | h | help ) + echo "${help_text}" && exit 0 + ;; + + --count=* | -c=* | -n=* ) + export SERIAL_SET_COUNT="${1#*=}" + shift + ;; + --count* | -c* | -n* ) + export SERIAL_SET_COUNT="${2}" + shift + shift + ;; + + --csv=* ) + export CSV_OUTPUT_FILENAME="${1#*=}" + shift + ;; + --csv* ) + export CSV_OUTPUT_FILENAME="${2}" + shift + shift + ;; + + --output-dir=* ) + export OUTPUT_DIRECTORY="${1#*=}" + shift + ;; + --output-dir* ) + export OUTPUT_DIRECTORY="${2}" + shift + shift + ;; + + --model=* | -m=* ) + export DEVICE_MODEL="${1#*=}" + shift + ;; + --model* | -m* ) + export DEVICE_MODEL="${2}" + shift + shift + ;; + + *) + echo "Invalid option. Running with default values..." + shift + ;; + esac +done + + +build_mac_serial () { + MACINFOPKG_VERSION="${MACINFOPKG_VERSION:=2.1.2}" + wget -O "${TARBALL:=./MacInfoPkg.tar.gz}" \ + "https://github.com/acidanthera/MacInfoPkg/archive/${MACINFOPKG_VERSION:=2.1.2}.tar.gz" + tar -xzvf "${TARBALL}" + cd "./MacInfoPkg-${MACINFOPKG_VERSION}/macserial" \ + && ./build.tool 2>/dev/null \ + && cd - + mv "./MacInfoPkg-${MACINFOPKG_VERSION}/macserial/bin/macserial" . + rm -f "${TARBALL}" + rm -rf "./MacInfoPkg-${MACINFOPKG_VERSION}/" + chmod +x macserial + stat ./macserial +} + +download_vendor_mac_addresses () { + # download the MAC Address vendor list + [[ -e "${MAC_ADDRESSES_FILE:=vendor_macs.tsv}" ]] || wget -O "${MAC_ADDRESSES_FILE}" https://gitlab.com/wireshark/wireshark/-/raw/master/manuf +} + +generate_serial_sets () { + mkdir -p "${OUTPUT_DIRECTORY}/envs" + export DATE_NOW="$(date +%F-%T)" + export DEVICE_MODEL="${DEVICE_MODEL:=iMacPro1,1}" + export VENDOR_REGEX="${VENDOR_REGEX:=Apple, Inc.}" + + if [[ "${CSV_OUTPUT_FILENAME}" ]]; then + export SERIAL_SETS_FILE="${CSV_OUTPUT_FILENAME}" + else + export SERIAL_SETS_FILE="${OUTPUT_DIRECTORY}/serial_sets-${DATE_NOW}.csv" + fi + + touch "${SERIAL_SETS_FILE}" + echo "Writing serial sets to ${SERIAL_SETS_FILE}" + + ./macserial \ + --num "${SERIAL_SET_COUNT:=1}" \ + --model "${DEVICE_MODEL}" \ + | while IFS='\ \|\ ' read -r Serial BoardSerial; do + # make a uuid... + SmUUID="$(uuidgen)" + SmUUID="${SmUUID^^}" + + # get a random vendor specific MAC address. + RANDOM_MAC_PREFIX="$(grep -e "${VENDOR_REGEX}" < "${MAC_ADDRESSES_FILE:=vendor_macs.tsv}" | sort --random-sort | head -n1)" + RANDOM_MAC_PREFIX="$(cut -d$'\t' -f1 <<< "${RANDOM_MAC_PREFIX}")" + MacAddress="$(printf "${RANDOM_MAC_PREFIX}:%02X:%02X:%02X" $[RANDOM%256] $[RANDOM%256] $[RANDOM%256])" + + echo "\"${DEVICE_MODEL}\",\"${Serial}\",\"${BoardSerial}\",\"${SmUUID}\",\"${MacAddress}\"" >> "${SERIAL_SETS_FILE}" + touch "${OUTPUT_DIRECTORY}/envs/${Serial}.env.sh" + cat < "${OUTPUT_DIRECTORY}/envs/${Serial}.env.sh" +export Type=${DEVICE_MODEL} +export Serial=${Serial} +export BoardSerial=${BoardSerial} +export SmUUID=${SmUUID} +export MacAddress=${MacAddress} +EOF + done + + cat <(echo "Type,Serial,BoardSerial,SmUUID,MacAddress") "${SERIAL_SETS_FILE}" +} + +main () { + # setting default variables if there are no options + cat < Date: Wed, 24 Feb 2021 05:29:17 +0000 Subject: Add zip, fix global variables in the serial generator. --- custom/generate-unique-machine-values.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'custom') diff --git a/custom/generate-unique-machine-values.sh b/custom/generate-unique-machine-values.sh index e87905c..c97db87 100755 --- a/custom/generate-unique-machine-values.sh +++ b/custom/generate-unique-machine-values.sh @@ -93,17 +93,17 @@ done build_mac_serial () { - MACINFOPKG_VERSION="${MACINFOPKG_VERSION:=2.1.2}" + export MACINFOPKG_VERSION="${MACINFOPKG_VERSION:=2.1.2}" wget -O "${TARBALL:=./MacInfoPkg.tar.gz}" \ - "https://github.com/acidanthera/MacInfoPkg/archive/${MACINFOPKG_VERSION:=2.1.2}.tar.gz" + "https://github.com/acidanthera/MacInfoPkg/archive/${MACINFOPKG_VERSION}.tar.gz" tar -xzvf "${TARBALL}" cd "./MacInfoPkg-${MACINFOPKG_VERSION}/macserial" \ - && ./build.tool 2>/dev/null \ + && ./build.tool \ && cd - mv "./MacInfoPkg-${MACINFOPKG_VERSION}/macserial/bin/macserial" . rm -f "${TARBALL}" rm -rf "./MacInfoPkg-${MACINFOPKG_VERSION}/" - chmod +x macserial + chmod +x ./macserial stat ./macserial } @@ -156,10 +156,13 @@ EOF main () { # setting default variables if there are no options + export DEVICE_MODEL="${DEVICE_MODEL:=iMacPro1,1}" + export SERIAL_SET_COUNT="${SERIAL_SET_COUNT:=1}" + export OUTPUT_DIRECTORY="${OUTPUT_DIRECTORY:=.}" cat < Date: Wed, 24 Feb 2021 05:52:17 +0000 Subject: Add config.plist and OpenCore boot disk generator to the script. --- custom/generate-unique-machine-values.sh | 50 +++++++++- custom/opencore-image-ng.sh | 163 +++++++++++++++++++++++++++++++ 2 files changed, 212 insertions(+), 1 deletion(-) create mode 100755 custom/opencore-image-ng.sh (limited to 'custom') diff --git a/custom/generate-unique-machine-values.sh b/custom/generate-unique-machine-values.sh index c97db87..a93aab6 100755 --- a/custom/generate-unique-machine-values.sh +++ b/custom/generate-unique-machine-values.sh @@ -21,7 +21,10 @@ General options: --model, -m Device model, e.g. "iMacPro1,1" --csv Optionally change the CSV output filename. --output-dir Optionally change the script output location. + --help, -h, help Display this help and exit + --plists Create corresponding config.plists for each serial set. + --qcows [SLOW] Create corresponding boot disk images for each serial set. Notes: - Default is 1 serial for "iMacPro1,1" in the current working directory. @@ -29,12 +32,14 @@ Notes: - If you do not set a CSV filename, the output will be sent to the output-dir. - If you do not set an output-dir, the current directory will be the output directory. - Sourcable environment variable shell files will be written to a folder, "envs". + - config.plist files will be written to a folder, "plists". Author: Sick.Codes https://sick.codes/ Project: https://github.com/sickcodes/Docker-OSX/ " MACINFOPKG_VERSION=2.1.2 +PLIST_MASTER=config-nopicker-custom.plist # gather arguments while (( "$#" )); do @@ -84,6 +89,15 @@ while (( "$#" )); do shift ;; + --plists ) + export CREATE_PLISTS=1 + shift + ;; + --qcows ) + export CREATE_QCOWS=1 + shift + ;; + *) echo "Invalid option. Running with default values..." shift @@ -112,6 +126,21 @@ download_vendor_mac_addresses () { [[ -e "${MAC_ADDRESSES_FILE:=vendor_macs.tsv}" ]] || wget -O "${MAC_ADDRESSES_FILE}" https://gitlab.com/wireshark/wireshark/-/raw/master/manuf } +download_qcow_efi_folder () { + git clone https://github.com/kholia/OSX-KVM.git + cp -ra ./OSX-KVM/OpenCore-Catalina/EFI . + mkdir -p ./EFI/OC/Resources + # clone some Apple drivers + git clone https://github.com/acidanthera/OcBinaryData.git + + # copy said drivers into EFI/OC/Resources + cp -a ./OcBinaryData/Resources/* ./EFI/OC/Resources + + # EFI Shell commands + touch startup.nsh && echo 'fs0:\EFI\BOOT\BOOTx64.efi' > startup.nsh +} + + generate_serial_sets () { mkdir -p "${OUTPUT_DIRECTORY}/envs" export DATE_NOW="$(date +%F-%T)" @@ -149,7 +178,25 @@ export BoardSerial=${BoardSerial} export SmUUID=${SmUUID} export MacAddress=${MacAddress} EOF - done + + if [[ "${CREATE_PLISTS}" ]] || [[ "${CREATE_QCOWS}" ]]; then + mkdir -p "${OUTPUT_DIRECTORY}/plists" + sed -e s/{{DEVICE_MODEL}}/"${Type}"/g \ + -e s/{{SERIAL_OLD}}/"${Serial}"/g \ + -e s/{{BOARD_SERIAL_OLD}}/"${BoardSerial}"/g \ + -e s/{{SYSTEM_UUID_OLD}}/"${SmUUID}"/g \ + -e s/{{ROM_OLD}}/"${ROM_VALUE}"/g \ + "${PLIST_MASTER}" > "${OUTPUT_DIRECTORY}/plists/${Serial}.config.plist" || exit 1 + fi + + if [[ "${CREATE_QCOWS}" ]]; then + mkdir -p "${OUTPUT_DIRECTORY}/qcows" + ./opencore-image-ng.sh \ + --cfg "${OUTPUT_DIRECTORY}/plists/${Serial}.config.plist" \ + --img "${OUTPUT_DIRECTORY}/qcows/${Serial}.OpenCore-nopicker.qcow2" || exit 1 + fi + + done cat <(echo "Type,Serial,BoardSerial,SmUUID,MacAddress") "${SERIAL_SETS_FILE}" } @@ -167,6 +214,7 @@ EOF [[ -d "${OUTPUT_DIRECTORY}" ]] || mkdir -p "${OUTPUT_DIRECTORY}" [[ -e ./macserial ]] || build_mac_serial download_vendor_mac_addresses + download_qcow_efi_folder generate_serial_sets echo "${SERIAL_SETS_FILE}" } diff --git a/custom/opencore-image-ng.sh b/custom/opencore-image-ng.sh new file mode 100755 index 0000000..6cbfe5b --- /dev/null +++ b/custom/opencore-image-ng.sh @@ -0,0 +1,163 @@ +#!/usr/bin/env bash + +# https://github.com/kraxel/imagefish + +###################################################################### +# defaults + +iso="" +img="" +cfg="" + +###################################################################### +# create work dir + +function msg() { + local txt="$1" + local bold="\x1b[1m" + local normal="\x1b[0m" + echo -e "${bold}### ${txt}${normal}" +} + +function do_cleanup() { + msg "cleaning up ..." + if test "$GUESTFISH_PID" != ""; then + guestfish --remote -- exit >/dev/null 2>&1 || true + fi + sudo rm -rf "$WORK" +} + +WORK="${TMPDIR-/var/tmp}/${0##*/}-$$" +mkdir "$WORK" || exit 1 +trap 'do_cleanup' EXIT + +BASE="$(dirname $0)" + +###################################################################### +# parse args + +function print_help() { +cat < + --img + --cfg +EOF +} + +while test "$1" != ""; do + case "$1" in + --iso) + iso="$2" + shift; shift + ;; + --img) + img="$2" + shift; shift + ;; + --cfg) + cfg="$2" + shift; shift + ;; + esac +done + +###################################################################### +# guestfish script helpers + +function fish() { + echo "#" "$@" + guestfish --remote -- "$@" || exit 1 +} + +function fish_init() { + local format + + case "$img" in + *.raw) format="raw" ;; + *) format="qcow2";; + esac + + msg "creating and adding disk image" + fish disk-create $img $format 384M + fish add $img + fish run +} + +function fish_fini() { + fish umount-all +} + +###################################################################### +# sanity checks + +if test ! -f "$cfg"; then + echo "ERROR: cfg not found: $cfg" + exit 1 +fi +if test -f "$img"; then + if test "$allow_override" = "yes"; then + rm -f "$img" + else + echo "ERROR: image exists: $img" + exit 1 + fi +fi + +###################################################################### +# go! + +msg "copy files from local folder" +BASE="$(dirname $0)" +cp -a $BASE/EFI $WORK +find "$WORK" + +#msg "[debug] list drivers in EFI/OC" +#(cd $WORK/EFI/OC; find driver* -print) + +export LIBGUESTFS_BACKEND=direct +eval $(guestfish --listen) +if test "$GUESTFISH_PID" = ""; then + echo "ERROR: starting guestfish failed" + exit 1 +fi + +fish_init + +msg "partition disk image" +fish part-init /dev/sda gpt +fish part-add /dev/sda p 2048 300000 +fish part-add /dev/sda p 302048 -2048 +fish part-set-gpt-type /dev/sda 1 C12A7328-F81F-11D2-BA4B-00A0C93EC93B +fish part-set-bootable /dev/sda 1 true +fish mkfs vfat /dev/sda1 label:EFI +fish mkfs vfat /dev/sda2 label:OpenCoreBoo +fish mount /dev/sda2 / +fish mkdir /ESP +fish mount /dev/sda1 /ESP + +msg "copy files to disk image" +cp -v "$cfg" $WORK/config.plist +fish mkdir /ESP/EFI +fish mkdir /ESP/EFI/OC +fish mkdir /ESP/EFI/OC/Kexts +fish mkdir /ESP/EFI/OC/ACPI +fish mkdir /ESP/EFI/OC/Resources +fish mkdir /ESP/EFI/OC/Tools +fish copy-in $WORK/EFI/BOOT /ESP/EFI +fish copy-in $WORK/EFI/OC/OpenCore.efi /ESP/EFI/OC +fish copy-in $WORK/EFI/OC/Drivers /ESP/EFI/OC/ +fish copy-in $WORK/EFI/OC/Kexts /ESP/EFI/OC/ +fish copy-in $WORK/EFI/OC/ACPI /ESP/EFI/OC/ +fish copy-in $WORK/EFI/OC/Resources /ESP/EFI/OC/ +fish copy-in $WORK/EFI/OC/Tools /ESP/EFI/OC/ + +# Note +fish copy-in startup.nsh / + +BASE="$(dirname $0)" +fish copy-in "$WORK/config.plist" /ESP/EFI/OC/ + +fish find /ESP/ +fish_fini -- cgit v1.2.3 From 246fd12c1842da1ef03d2b6241c15e7e60731609 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Wed, 24 Feb 2021 09:46:18 +0000 Subject: TSV output, for easier scripting --- custom/generate-unique-machine-values.sh | 69 +++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 15 deletions(-) (limited to 'custom') diff --git a/custom/generate-unique-machine-values.sh b/custom/generate-unique-machine-values.sh index a93aab6..d754d04 100755 --- a/custom/generate-unique-machine-values.sh +++ b/custom/generate-unique-machine-values.sh @@ -13,26 +13,37 @@ help_text="Usage: generate-unique-machine-values.sh -Example: - ./generate-unique-machine-values.sh --count 1 --model="iMacPro1,1" - General options: --count, -n, -c Number of serials to generate - --model, -m Device model, e.g. "iMacPro1,1" + --model, -m Device model, e.g. 'iMacPro1,1' --csv Optionally change the CSV output filename. + --tsv Optionally change the TSV output filename. --output-dir Optionally change the script output location. --help, -h, help Display this help and exit --plists Create corresponding config.plists for each serial set. --qcows [SLOW] Create corresponding boot disk images for each serial set. +Example: + ./generate-unique-machine-values.sh --count 1 --model='iMacPro1,1' --plists --qcows + + The above example will generate a + - serial + - board serial + - uuid + - MAC address + - ROM value based on lowercase MAC address + - Boot disk qcow image. + - config.plist + Notes: - - Default is 1 serial for "iMacPro1,1" in the current working directory. + - Default is 1 serial for 'iMacPro1,1' in the current working directory. + - Default output is CSV, whereas setting the TSV option will output as tab-separated. - CSV is double quoted. - If you do not set a CSV filename, the output will be sent to the output-dir. - If you do not set an output-dir, the current directory will be the output directory. - - Sourcable environment variable shell files will be written to a folder, "envs". - - config.plist files will be written to a folder, "plists". + - Sourcable environment variable shell files will be written to a folder, 'envs'. + - config.plist files will be written to a folder, 'plists'. Author: Sick.Codes https://sick.codes/ Project: https://github.com/sickcodes/Docker-OSX/ @@ -69,6 +80,16 @@ while (( "$#" )); do shift ;; + --tsv=* ) + export TSV_OUTPUT_FILENAME="${1#*=}" + shift + ;; + --tsv* ) + export TSV_OUTPUT_FILENAME="${2}" + shift + shift + ;; + --output-dir=* ) export OUTPUT_DIRECTORY="${1#*=}" shift @@ -127,15 +148,13 @@ download_vendor_mac_addresses () { } download_qcow_efi_folder () { - git clone https://github.com/kholia/OSX-KVM.git + git clone --depth 1 https://github.com/kholia/OSX-KVM.git cp -ra ./OSX-KVM/OpenCore-Catalina/EFI . mkdir -p ./EFI/OC/Resources # clone some Apple drivers - git clone https://github.com/acidanthera/OcBinaryData.git - + git clone --depth 1 https://github.com/acidanthera/OcBinaryData.git # copy said drivers into EFI/OC/Resources cp -a ./OcBinaryData/Resources/* ./EFI/OC/Resources - # EFI Shell commands touch startup.nsh && echo 'fs0:\EFI\BOOT\BOOTx64.efi' > startup.nsh } @@ -147,8 +166,9 @@ generate_serial_sets () { export DEVICE_MODEL="${DEVICE_MODEL:=iMacPro1,1}" export VENDOR_REGEX="${VENDOR_REGEX:=Apple, Inc.}" - if [[ "${CSV_OUTPUT_FILENAME}" ]]; then - export SERIAL_SETS_FILE="${CSV_OUTPUT_FILENAME}" + if [[ "${CSV_OUTPUT_FILENAME}" ]] || [[ "${TSV_OUTPUT_FILENAME}" ]]; then + [[ ${CSV_OUTPUT_FILENAME} ]] && export CSV_SERIAL_SETS_FILE="${CSV_OUTPUT_FILENAME}" + [[ ${TSV_OUTPUT_FILENAME} ]] && export TSV_SERIAL_SETS_FILE="${TSV_OUTPUT_FILENAME}" else export SERIAL_SETS_FILE="${OUTPUT_DIRECTORY}/serial_sets-${DATE_NOW}.csv" fi @@ -169,7 +189,16 @@ generate_serial_sets () { RANDOM_MAC_PREFIX="$(cut -d$'\t' -f1 <<< "${RANDOM_MAC_PREFIX}")" MacAddress="$(printf "${RANDOM_MAC_PREFIX}:%02X:%02X:%02X" $[RANDOM%256] $[RANDOM%256] $[RANDOM%256])" - echo "\"${DEVICE_MODEL}\",\"${Serial}\",\"${BoardSerial}\",\"${SmUUID}\",\"${MacAddress}\"" >> "${SERIAL_SETS_FILE}" + # append to csv file + if [[ "${CSV_SERIAL_SETS_FILE}" ]]; then + echo "\"${DEVICE_MODEL}\",\"${Serial}\",\"${BoardSerial}\",\"${SmUUID}\",\"${MacAddress}\"" >> "${CSV_SERIAL_SETS_FILE}" + fi + + # append to tsv file + if [[ "${TSV_SERIAL_SETS_FILE}" ]]; then + printf "${DEVICE_MODEL}\t${Serial}\t${BoardSerial}\t${SmUUID}\t${MacAddress}\n" >> "${TSV_SERIAL_SETS_FILE}" + fi + touch "${OUTPUT_DIRECTORY}/envs/${Serial}.env.sh" cat < "${OUTPUT_DIRECTORY}/envs/${Serial}.env.sh" export Type=${DEVICE_MODEL} @@ -179,8 +208,12 @@ export SmUUID=${SmUUID} export MacAddress=${MacAddress} EOF + # plist required for qcows, so create anyway. if [[ "${CREATE_PLISTS}" ]] || [[ "${CREATE_QCOWS}" ]]; then mkdir -p "${OUTPUT_DIRECTORY}/plists" + source "${OUTPUT_DIRECTORY}/envs/${Serial}.env.sh" + ROM_VALUE="${MacAddress//\:/}" + ROM_VALUE="${ROM_VALUE,,}" sed -e s/{{DEVICE_MODEL}}/"${Type}"/g \ -e s/{{SERIAL_OLD}}/"${Serial}"/g \ -e s/{{BOARD_SERIAL_OLD}}/"${BoardSerial}"/g \ @@ -198,7 +231,13 @@ EOF done - cat <(echo "Type,Serial,BoardSerial,SmUUID,MacAddress") "${SERIAL_SETS_FILE}" + [[ -e "${CSV_SERIAL_SETS_FILE}" ]] && \ + cat <(echo "Type,Serial,BoardSerial,SmUUID,MacAddress") "${CSV_SERIAL_SETS_FILE}" + + + [[ -e "${TSV_SERIAL_SETS_FILE}" ]] && \ + cat <(printf "Type\tSerial\tBoardSerial\tSmUUID\tMacAddress\n") "${TSV_SERIAL_SETS_FILE}" + } main () { -- cgit v1.2.3 From 7886e0fd065bfaaa773787aed2ac055061abd388 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Wed, 24 Feb 2021 11:49:20 +0000 Subject: Add --output-env && --output-bootdisk --- custom/generate-unique-machine-values.sh | 39 +++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'custom') diff --git a/custom/generate-unique-machine-values.sh b/custom/generate-unique-machine-values.sh index d754d04..aef200b 100755 --- a/custom/generate-unique-machine-values.sh +++ b/custom/generate-unique-machine-values.sh @@ -18,14 +18,16 @@ General options: --model, -m Device model, e.g. 'iMacPro1,1' --csv Optionally change the CSV output filename. --tsv Optionally change the TSV output filename. + --output-bootdisk Optionally change the bootdisk qcow output filename. Useless when count > 1. + --output-env Optionally change the bootdisk env filename. Useless when count > 1. --output-dir Optionally change the script output location. --help, -h, help Display this help and exit --plists Create corresponding config.plists for each serial set. - --qcows [SLOW] Create corresponding boot disk images for each serial set. + --bootdisks [SLOW] Create corresponding boot disk images for each serial set. Example: - ./generate-unique-machine-values.sh --count 1 --model='iMacPro1,1' --plists --qcows + ./generate-unique-machine-values.sh --count 1 --model='iMacPro1,1' --plists --bootdisks The above example will generate a - serial @@ -100,6 +102,26 @@ while (( "$#" )); do shift ;; + --output-bootdisk=* ) + export OUTPUT_QCOW="${1#*=}" + shift + ;; + --output-bootdisk* ) + export OUTPUT_QCOW="${2}" + shift + shift + ;; + + --output-env=* ) + export OUTPUT_ENV="${1#*=}" + shift + ;; + --output-env* ) + export OUTPUT_ENV="${2}" + shift + shift + ;; + --model=* | -m=* ) export DEVICE_MODEL="${1#*=}" shift @@ -114,7 +136,7 @@ while (( "$#" )); do export CREATE_PLISTS=1 shift ;; - --qcows ) + --bootdisks ) export CREATE_QCOWS=1 shift ;; @@ -199,8 +221,9 @@ generate_serial_sets () { printf "${DEVICE_MODEL}\t${Serial}\t${BoardSerial}\t${SmUUID}\t${MacAddress}\n" >> "${TSV_SERIAL_SETS_FILE}" fi - touch "${OUTPUT_DIRECTORY}/envs/${Serial}.env.sh" - cat < "${OUTPUT_DIRECTORY}/envs/${Serial}.env.sh" + OUTPUT_ENV_FILE="${OUTPUT_ENV:-"${OUTPUT_DIRECTORY}/envs/${Serial}.env.sh"}" + touch "${OUTPUT_ENV_FILE}" + cat < "${OUTPUT_ENV_FILE}" export Type=${DEVICE_MODEL} export Serial=${Serial} export BoardSerial=${BoardSerial} @@ -208,10 +231,10 @@ export SmUUID=${SmUUID} export MacAddress=${MacAddress} EOF - # plist required for qcows, so create anyway. + # plist required for bootdisks, so create anyway. if [[ "${CREATE_PLISTS}" ]] || [[ "${CREATE_QCOWS}" ]]; then mkdir -p "${OUTPUT_DIRECTORY}/plists" - source "${OUTPUT_DIRECTORY}/envs/${Serial}.env.sh" + source "${OUTPUT_ENV_FILE}" ROM_VALUE="${MacAddress//\:/}" ROM_VALUE="${ROM_VALUE,,}" sed -e s/{{DEVICE_MODEL}}/"${Type}"/g \ @@ -226,7 +249,7 @@ EOF mkdir -p "${OUTPUT_DIRECTORY}/qcows" ./opencore-image-ng.sh \ --cfg "${OUTPUT_DIRECTORY}/plists/${Serial}.config.plist" \ - --img "${OUTPUT_DIRECTORY}/qcows/${Serial}.OpenCore-nopicker.qcow2" || exit 1 + --img "${OUTPUT_QCOW:-${OUTPUT_DIRECTORY}/qcows/${Serial}.OpenCore-nopicker.qcow2}" || exit 1 fi done -- cgit v1.2.3 From 4ffed5472416cf0662cf356343bde23f20f0e541 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Wed, 24 Feb 2021 12:17:16 +0000 Subject: WIP generate-specific-bootdisk.sh --- custom/generate-specific-bootdisk.sh | 184 +++++++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100755 custom/generate-specific-bootdisk.sh (limited to 'custom') diff --git a/custom/generate-specific-bootdisk.sh b/custom/generate-specific-bootdisk.sh new file mode 100755 index 0000000..2717d22 --- /dev/null +++ b/custom/generate-specific-bootdisk.sh @@ -0,0 +1,184 @@ +#!/bin/bash +# ____ __ ____ ______ __ +# / __ \____ _____/ /_____ _____/ __ \/ ___/ |/ / +# / / / / __ \/ ___/ //_/ _ \/ ___/ / / /\__ \| / +# / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / | +# /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| GEN BOOT DISK +# +# Repo: https://github.com/sickcodes/Docker-OSX/ +# Title: Mac on Docker (Docker-OSX) +# Author: Sick.Codes https://sick.codes/ +# Version: 3.1 +# License: GPLv3+ + +help_text="Usage: generate-specific-bootdisk.sh + +General options: + --model Device model, e.g. 'iMacPro1,1' + --serial Device Serial number. + --board-serial Board Serial number. + --uuid SmUUID. + --mac-address Used to set the ROM value; lowercased and without a colon. + --output-bootdisk Optionally change the bootdisk output filename. + --custom-plist Optionally change the input plist. + + --help, -h, help Display this help and exit + +Example: + ./genboot.sh \\ + --model iMacPro1,1 \\ + --serial C02TW0WAHX87 \\ + --board-serial C027251024NJG36UE \\ + --uuid 5CCB366D-9118-4C61-A00A-E5BAF3BED451 \\ + --mac-address A8:5C:2C:9A:46:2F \\ + --output-bootdisk OpenCore-nopicker.qcow2 + +Author: Sick.Codes https://sick.codes/ +Project: https://github.com/sickcodes/Docker-OSX/ +" + +PLIST_MASTER=config-nopicker-custom.plist + +# gather arguments +while (( "$#" )); do + case "${1}" in + + --help | -h | h | help ) + echo "${help_text}" && exit 0 + ;; + + --model=* | -m=* ) + export DEVICE_MODEL="${1#*=}" + shift + ;; + --model* | -m* ) + export DEVICE_MODEL="${2}" + shift + shift + ;; + + --serial=* ) + export SERIAL_NUMBER="${1#*=}" + shift + ;; + --serial* ) + export SERIAL_NUMBER="${2}" + shift + shift + ;; + + --board-serial=* ) + export BOARD_SERIAL_NUMBER="${1#*=}" + shift + ;; + --board-serial* ) + export BOARD_SERIAL_NUMBER="${2}" + shift + shift + ;; + + --uuid=* ) + export UUID="${1#*=}" + shift + ;; + --uuid* ) + export UUID="${2}" + shift + shift + ;; + + --mac-address=* ) + export MAC_ADDRESS="${1#*=}" + shift + ;; + --mac-address* ) + export MAC_ADDRESS="${2}" + shift + shift + ;; + + --output-bootdisk=* ) + export OUTPUT_QCOW="${1#*=}" + shift + ;; + --output-bootdisk* ) + export OUTPUT_QCOW="${2}" + shift + shift + ;; + + --custom-plist=* ) + export INPUT_PLIST="${1#*=}" + shift + ;; + --custom-plist* ) + export INPUT_PLIST="${2}" + shift + shift + ;; + + *) + echo "Invalid option. Running with default values..." + shift + ;; + esac +done + + +download_qcow_efi_folder () { + git clone --depth 1 https://github.com/kholia/OSX-KVM.git + cp -ra ./OSX-KVM/OpenCore-Catalina/EFI . + mkdir -p ./EFI/OC/Resources + # clone some Apple drivers + git clone --depth 1 https://github.com/acidanthera/OcBinaryData.git + # copy said drivers into EFI/OC/Resources + cp -a ./OcBinaryData/Resources/* ./EFI/OC/Resources + # EFI Shell commands + touch startup.nsh && echo 'fs0:\EFI\BOOT\BOOTx64.efi' > startup.nsh +} + +generate_bootdisk () { + [[ -e ./config-nopicker-custom.plist ]] || wget https://raw.githubusercontent.com/sickcodes/Docker-OSX/custom-identity/custom/config-nopicker-custom.plist + [[ -e ./opencore-image-ng.sh ]] || wget https://raw.githubusercontent.com/sickcodes/Docker-OSX/custom-identity/custom/opencore-image-ng.sh && chmod +x opencore-image-ng.sh + # plist required for bootdisks, so create anyway. + if [[ "${DEVICE_MODEL}" ]] \ + && [[ "${SERIAL_NUMBER}" ]] \ + && [[ "${BOARD_SERIAL_NUMBER}" ]] \ + && [[ "${UUID}" ]] \ + && [[ "${MAC_ADDRESS}" ]]; then + ROM_VALUE="${MacAddress//\:/}" + ROM_VALUE="${ROM_VALUE,,}" + sed -e s/{{DEVICE_MODEL}}/"${DEVICE_MODEL}"/g \ + -e s/{{SERIAL_OLD}}/"${SERIAL_NUMBER}"/g \ + -e s/{{BOARD_SERIAL_OLD}}/"${BOARD_SERIAL_NUMBER}"/g \ + -e s/{{SYSTEM_UUID_OLD}}/"${UUID}"/g \ + -e s/{{ROM_OLD}}/"${ROM_VALUE}"/g \ + "${PLIST_MASTER}" > ./tmp.config.plist || exit 1 + else + cat < Date: Thu, 25 Feb 2021 08:52:56 +0000 Subject: Add Linux, libguestfs for building bootdisks within the Docker container. Add CPU_STRING to optionally override the whole CPU string. Unify variable names in ./custom. --- custom/config-nopicker-custom.plist | 8 +++--- custom/generate-specific-bootdisk.sh | 42 ++++++++++++++--------------- custom/generate-unique-machine-values.sh | 46 ++++++++++++++++---------------- custom/opencore-image-ng.sh | 25 ++++++++--------- 4 files changed, 61 insertions(+), 60 deletions(-) (limited to 'custom') diff --git a/custom/config-nopicker-custom.plist b/custom/config-nopicker-custom.plist index c93ee96..6166234 100644 --- a/custom/config-nopicker-custom.plist +++ b/custom/config-nopicker-custom.plist @@ -702,19 +702,19 @@ AdviseWindows MLB - {{BOARD_SERIAL_OLD}} + {{BOARD_SERIAL}} ROM - {{ROM_OLD}} + {{ROM}} SpoofVendor SystemProductName {{DEVICE_MODEL}} SystemSerialNumber - {{SERIAL_OLD}} + {{SERIAL}} SystemUUID - {{SYSTEM_UUID_OLD}} + {{UUID}} UpdateDataHub diff --git a/custom/generate-specific-bootdisk.sh b/custom/generate-specific-bootdisk.sh index 2717d22..46c3571 100755 --- a/custom/generate-specific-bootdisk.sh +++ b/custom/generate-specific-bootdisk.sh @@ -25,12 +25,12 @@ General options: --help, -h, help Display this help and exit Example: - ./genboot.sh \\ - --model iMacPro1,1 \\ - --serial C02TW0WAHX87 \\ - --board-serial C027251024NJG36UE \\ - --uuid 5CCB366D-9118-4C61-A00A-E5BAF3BED451 \\ - --mac-address A8:5C:2C:9A:46:2F \\ + ./generate-specific-bootdisk.sh \ + --model iMacPro1,1 \ + --serial C02TW0WAHX87 \ + --board-serial C027251024NJG36UE \ + --uuid 5CCB366D-9118-4C61-A00A-E5BAF3BED451 \ + --mac-address A8:5C:2C:9A:46:2F \ --output-bootdisk OpenCore-nopicker.qcow2 Author: Sick.Codes https://sick.codes/ @@ -58,21 +58,21 @@ while (( "$#" )); do ;; --serial=* ) - export SERIAL_NUMBER="${1#*=}" + export SERIAL="${1#*=}" shift ;; --serial* ) - export SERIAL_NUMBER="${2}" + export SERIAL="${2}" shift shift ;; --board-serial=* ) - export BOARD_SERIAL_NUMBER="${1#*=}" + export BOARD_SERIAL="${1#*=}" shift ;; --board-serial* ) - export BOARD_SERIAL_NUMBER="${2}" + export BOARD_SERIAL="${2}" shift shift ;; @@ -142,25 +142,25 @@ generate_bootdisk () { [[ -e ./opencore-image-ng.sh ]] || wget https://raw.githubusercontent.com/sickcodes/Docker-OSX/custom-identity/custom/opencore-image-ng.sh && chmod +x opencore-image-ng.sh # plist required for bootdisks, so create anyway. if [[ "${DEVICE_MODEL}" ]] \ - && [[ "${SERIAL_NUMBER}" ]] \ - && [[ "${BOARD_SERIAL_NUMBER}" ]] \ + && [[ "${SERIAL}" ]] \ + && [[ "${BOARD_SERIALR}" ]] \ && [[ "${UUID}" ]] \ && [[ "${MAC_ADDRESS}" ]]; then - ROM_VALUE="${MacAddress//\:/}" - ROM_VALUE="${ROM_VALUE,,}" + ROM="${MAC_ADDRESS//\:/}" + ROM="${ROM,,}" sed -e s/{{DEVICE_MODEL}}/"${DEVICE_MODEL}"/g \ - -e s/{{SERIAL_OLD}}/"${SERIAL_NUMBER}"/g \ - -e s/{{BOARD_SERIAL_OLD}}/"${BOARD_SERIAL_NUMBER}"/g \ - -e s/{{SYSTEM_UUID_OLD}}/"${UUID}"/g \ - -e s/{{ROM_OLD}}/"${ROM_VALUE}"/g \ + -e s/{{SERIAL}}/"${SERIAL}"/g \ + -e s/{{BOARD_SERIAL}}/"${BOARD_SERIAL}"/g \ + -e s/{{UUID}}/"${UUID}"/g \ + -e s/{{ROM}}/"${ROM}"/g \ "${PLIST_MASTER}" > ./tmp.config.plist || exit 1 else cat <> "${CSV_SERIAL_SETS_FILE}" + echo "\"${DEVICE_MODEL}\",\"${SERIAL}\",\"${BOARD_SERIAL}\",\"${UUID}\",\"${MAC_ADDRESS}\"" >> "${CSV_SERIAL_SETS_FILE}" fi # append to tsv file if [[ "${TSV_SERIAL_SETS_FILE}" ]]; then - printf "${DEVICE_MODEL}\t${Serial}\t${BoardSerial}\t${SmUUID}\t${MacAddress}\n" >> "${TSV_SERIAL_SETS_FILE}" + printf "${DEVICE_MODEL}\t${SERIAL}\t${BOARD_SERIAL}\t${UUID}\t${MAC_ADDRESS}\n" >> "${TSV_SERIAL_SETS_FILE}" fi - OUTPUT_ENV_FILE="${OUTPUT_ENV:-"${OUTPUT_DIRECTORY}/envs/${Serial}.env.sh"}" + OUTPUT_ENV_FILE="${OUTPUT_ENV:-"${OUTPUT_DIRECTORY}/envs/${SERIAL}.env.sh"}" touch "${OUTPUT_ENV_FILE}" cat < "${OUTPUT_ENV_FILE}" -export Type=${DEVICE_MODEL} -export Serial=${Serial} -export BoardSerial=${BoardSerial} -export SmUUID=${SmUUID} -export MacAddress=${MacAddress} +export DEVICE_MODEL="${DEVICE_MODEL}" +export SERIAL="${SERIAL}" +export BOARD_SERIAL="${BOARD_SERIAL}" +export UUID="${UUID}" +export MAC_ADDRESS="${MAC_ADDRESS}" EOF # plist required for bootdisks, so create anyway. if [[ "${CREATE_PLISTS}" ]] || [[ "${CREATE_QCOWS}" ]]; then mkdir -p "${OUTPUT_DIRECTORY}/plists" source "${OUTPUT_ENV_FILE}" - ROM_VALUE="${MacAddress//\:/}" + ROM_VALUE="${MAC_ADDRESS//\:/}" ROM_VALUE="${ROM_VALUE,,}" - sed -e s/{{DEVICE_MODEL}}/"${Type}"/g \ - -e s/{{SERIAL_OLD}}/"${Serial}"/g \ - -e s/{{BOARD_SERIAL_OLD}}/"${BoardSerial}"/g \ - -e s/{{SYSTEM_UUID_OLD}}/"${SmUUID}"/g \ - -e s/{{ROM_OLD}}/"${ROM_VALUE}"/g \ - "${PLIST_MASTER}" > "${OUTPUT_DIRECTORY}/plists/${Serial}.config.plist" || exit 1 + sed -e s/{{DEVICE_MODEL}}/"${DEVICE_MODEL}"/g \ + -e s/{{SERIAL}}/"${SERIAL}"/g \ + -e s/{{BOARD_SERIAL}}/"${BOARD_SERIAL}"/g \ + -e s/{{UUID}}/"${UUID}"/g \ + -e s/{{ROM}}/"${ROM}"/g \ + "${PLIST_MASTER}" > "${OUTPUT_DIRECTORY}/plists/${SERIAL}.config.plist" || exit 1 fi if [[ "${CREATE_QCOWS}" ]]; then mkdir -p "${OUTPUT_DIRECTORY}/qcows" ./opencore-image-ng.sh \ - --cfg "${OUTPUT_DIRECTORY}/plists/${Serial}.config.plist" \ - --img "${OUTPUT_QCOW:-${OUTPUT_DIRECTORY}/qcows/${Serial}.OpenCore-nopicker.qcow2}" || exit 1 + --cfg "${OUTPUT_DIRECTORY}/plists/${SERIAL}.config.plist" \ + --img "${OUTPUT_QCOW:-${OUTPUT_DIRECTORY}/qcows/${SERIAL}.OpenCore-nopicker.qcow2}" || exit 1 fi done [[ -e "${CSV_SERIAL_SETS_FILE}" ]] && \ - cat <(echo "Type,Serial,BoardSerial,SmUUID,MacAddress") "${CSV_SERIAL_SETS_FILE}" + cat <(echo "DEVICE_MODEL,SERIAL,BOARD_SERIAL,UUID,MAC_ADDRESS") "${CSV_SERIAL_SETS_FILE}" [[ -e "${TSV_SERIAL_SETS_FILE}" ]] && \ - cat <(printf "Type\tSerial\tBoardSerial\tSmUUID\tMacAddress\n") "${TSV_SERIAL_SETS_FILE}" + cat <(printf "DEVICE_MODEL\tSERIAL\BOARD_SERIAL\tUUID\tMAC_ADDRESS\n") "${TSV_SERIAL_SETS_FILE}" } diff --git a/custom/opencore-image-ng.sh b/custom/opencore-image-ng.sh index 6cbfe5b..56eaa45 100755 --- a/custom/opencore-image-ng.sh +++ b/custom/opencore-image-ng.sh @@ -89,21 +89,22 @@ function fish_fini() { fish umount-all } +# disabled by sick.codes to allow unattended image overwrites ###################################################################### # sanity checks -if test ! -f "$cfg"; then - echo "ERROR: cfg not found: $cfg" - exit 1 -fi -if test -f "$img"; then - if test "$allow_override" = "yes"; then - rm -f "$img" - else - echo "ERROR: image exists: $img" - exit 1 - fi -fi +# if test ! -f "$cfg"; then +# echo "ERROR: cfg not found: $cfg" +# exit 1 +# fi +# if test -f "$img"; then +# if test "$allow_override" = "yes"; then +# rm -f "$img" +# else +# echo "ERROR: image exists: $img" +# exit 1 +# fi +# fi ###################################################################### # go! -- cgit v1.2.3 From 9f104526e04e7527b1f067290e9854a9b9fa8c0b Mon Sep 17 00:00:00 2001 From: sickcodes Date: Thu, 25 Feb 2021 08:58:52 +0000 Subject: Typo --- custom/generate-specific-bootdisk.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'custom') diff --git a/custom/generate-specific-bootdisk.sh b/custom/generate-specific-bootdisk.sh index 46c3571..e87bf3c 100755 --- a/custom/generate-specific-bootdisk.sh +++ b/custom/generate-specific-bootdisk.sh @@ -143,7 +143,7 @@ generate_bootdisk () { # plist required for bootdisks, so create anyway. if [[ "${DEVICE_MODEL}" ]] \ && [[ "${SERIAL}" ]] \ - && [[ "${BOARD_SERIALR}" ]] \ + && [[ "${BOARD_SERIAL}" ]] \ && [[ "${UUID}" ]] \ && [[ "${MAC_ADDRESS}" ]]; then ROM="${MAC_ADDRESS//\:/}" -- cgit v1.2.3 From 258f6b455d14aeb449260b668a9d16478a48ac5c Mon Sep 17 00:00:00 2001 From: sickcodes Date: Fri, 26 Feb 2021 06:42:57 +0000 Subject: Fix /env permissions for persistence after GENERATE_UNIQUE. Fix the following warning by chowning /dev/kvm earlier "libguestfs: warning: current user is not a member of the KVM group (group ID 108). This user cannot access /dev/kvm, so libguestfs may run very slowly. It is recommended that you 'chmod 0666 /dev/kvm' or add the current user to the KVM group (you might need to log out and log in again)." --- custom/generate-unique-machine-values.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'custom') diff --git a/custom/generate-unique-machine-values.sh b/custom/generate-unique-machine-values.sh index 18bdc5f..6692e29 100755 --- a/custom/generate-unique-machine-values.sh +++ b/custom/generate-unique-machine-values.sh @@ -259,7 +259,7 @@ EOF [[ -e "${TSV_SERIAL_SETS_FILE}" ]] && \ - cat <(printf "DEVICE_MODEL\tSERIAL\BOARD_SERIAL\tUUID\tMAC_ADDRESS\n") "${TSV_SERIAL_SETS_FILE}" + cat <(printf "DEVICE_MODEL\tSERIAL\tBOARD_SERIAL\tUUID\tMAC_ADDRESS\n") "${TSV_SERIAL_SETS_FILE}" } -- cgit v1.2.3 From 91131a6bbbe92615852e14e4b8e427ebe743f3a5 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Fri, 26 Feb 2021 09:25:40 +0000 Subject: Add exists exits and required serial number files for building disk --- custom/generate-unique-machine-values.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'custom') diff --git a/custom/generate-unique-machine-values.sh b/custom/generate-unique-machine-values.sh index 6692e29..4b2409a 100755 --- a/custom/generate-unique-machine-values.sh +++ b/custom/generate-unique-machine-values.sh @@ -183,6 +183,8 @@ download_qcow_efi_folder () { generate_serial_sets () { + [[ -e ./config-nopicker-custom.plist ]] || wget https://raw.githubusercontent.com/sickcodes/Docker-OSX/custom-identity/custom/config-nopicker-custom.plist + [[ -e ./opencore-image-ng.sh ]] || wget https://raw.githubusercontent.com/sickcodes/Docker-OSX/custom-identity/custom/opencore-image-ng.sh && chmod +x opencore-image-ng.sh mkdir -p "${OUTPUT_DIRECTORY}/envs" export DATE_NOW="$(date +%F-%T)" export DEVICE_MODEL="${DEVICE_MODEL:=iMacPro1,1}" -- cgit v1.2.3