aboutsummaryrefslogtreecommitdiff
path: root/custom
diff options
context:
space:
mode:
authorsickcodes <[email protected]>2021-05-02 23:45:04 +0000
committerGitHub <[email protected]>2021-05-02 23:45:04 +0000
commit57f1532dd147d4b02aff1edab5ac988f3fb3e424 (patch)
tree60cace8091a02fbd5e994a32c0d6d461ea51c5aa /custom
parentRevert glibc patch when applicable. (diff)
parentAdd cool shield from https://dockeri.co/ to README.md (diff)
downloaddocker-osx-glibc-revert-wip.tar.xz
docker-osx-glibc-revert-wip.zip
Merge branch 'master' into glibc-revert-wipglibc-revert-wip
Diffstat (limited to 'custom')
-rw-r--r--custom/README.md7
-rw-r--r--custom/config-nopicker-custom.plist9
-rwxr-xr-xcustom/generate-specific-bootdisk.sh205
-rwxr-xr-xcustom/generate-unique-machine-values.sh318
-rwxr-xr-xcustom/opencore-image-ng.sh2
5 files changed, 378 insertions, 163 deletions
diff --git a/custom/README.md b/custom/README.md
new file mode 100644
index 0000000..92bb97d
--- /dev/null
+++ b/custom/README.md
@@ -0,0 +1,7 @@
+# OSX Serial Generator
+
+This folder has been moved to its own repository :)
+
+This is a temporary copy for hardlinks.
+
+See [https://github.com/sickcodes/osx-serial-generator](https://github.com/sickcodes/osx-serial-generator) \ No newline at end of file
diff --git a/custom/config-nopicker-custom.plist b/custom/config-nopicker-custom.plist
index 6166234..6602df5 100644
--- a/custom/config-nopicker-custom.plist
+++ b/custom/config-nopicker-custom.plist
@@ -1,4 +1,5 @@
-<!-- This file is modified from https://github.com/kholia/OSX-KVM/tree/master/OpenCore-Catalina -->
+<!-- This file is modified by @sickcodes from https://github.com/kholia/OSX-KVM/tree/master/OpenCore-Catalina -->
+<!-- The modifications are placeholders for: {{DEVICE_MODEL}}, {{SERIAL}}, {{BOARD_SERIAL}}, {{UUID}}, {{ROM}}, {{WIDTH}}, {{HEIGHT}} -->
<!-- All credit for this file https://github.com/kholia/OSX-KVM/blob/master/CREDITS.md -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -704,9 +705,7 @@
<key>MLB</key>
<string>{{BOARD_SERIAL}}</string>
<key>ROM</key>
- <data>
- {{ROM}}
- </data>
+ <data>{{ROM}}</data>
<key>SpoofVendor</key>
<true/>
<key>SystemProductName</key>
@@ -816,7 +815,7 @@
<key>ReplaceTabWithSpace</key>
<false/>
<key>Resolution</key>
- <string>1920x1080@32</string>
+ <string>{{WIDTH}}x{{HEIGHT}}@32</string>
<key>SanitiseClearScreen</key>
<false/>
<key>TextRenderer</key>
diff --git a/custom/generate-specific-bootdisk.sh b/custom/generate-specific-bootdisk.sh
index 76aff0c..386c13b 100755
--- a/custom/generate-specific-bootdisk.sh
+++ b/custom/generate-specific-bootdisk.sh
@@ -1,43 +1,58 @@
#!/bin/bash
-# ____ __ ____ ______ __
-# / __ \____ _____/ /_____ _____/ __ \/ ___/ |/ /
-# / / / / __ \/ ___/ //_/ _ \/ ___/ / / /\__ \| /
-# / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / |
-# /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| GEN BOOT DISK
+# ___ _____ __ ___ _ _ ___ _
+# / _ \/ __\ \/ / / __| ___ _ _(_)__ _| | / __|___ _ _ ___ _ _ __ _| |_ ___ _ _
+# | (_) \__ \> < \__ \/ -_) '_| / _` | | | (_ / -_) ' \/ -_) '_/ _` | _/ _ \ '_|
+# \___/|___/_/\_\ |___/\___|_| |_\__,_|_| \___\___|_||_\___|_| \__,_|\__\___/_|
#
-# Repo: https://github.com/sickcodes/Docker-OSX/
-# Title: Mac on Docker (Docker-OSX)
+# Repo: https://github.com/sickcodes/osx-serial-generator/
+# Title: OSX Serial Generator
# Author: Sick.Codes https://sick.codes/
# Version: 3.1
# License: GPLv3+
-help_text="Usage: generate-specific-bootdisk.sh
+set -e
-General options:
+help_text="Usage: ./generate-specific-bootdisk.sh
+
+Required options:
--model <string> Device model, e.g. 'iMacPro1,1'
- --serial <filename> Device Serial number.
- --board-serial <filename> Board Serial number.
- --uuid <filename> SmUUID.
- --mac-address <string> Used to set the ROM value; lowercased and without a colon.
- --output-bootdisk <filename> Optionally change the bootdisk output filename.
+ --serial <string> Device Serial number
+ --board-serial <string> Main Logic Board Serial number (MLB)
+ --uuid <string> SMBIOS UUID (SmUUID)
+ --mac-address <string> Used for both the MAC address and to set ROM
+ ROM is lowercased sans any colons
+Optional options:
+ --width <integer> Resolution x axis length in px, default 1920
+ --height <integer> Resolution y axis length in px, default 1080
+ --input-plist-url <url> Specify an alternative master plist, via URL
+ --master-plist-url <url> Same as above.
--custom-plist <filename> Optionally change the input plist.
-
+ --master-plist <filename> Same as above.
+ --output-bootdisk <filename> Optionally change the bootdisk filename
+ --output-plist <filename> Optionally change the output plist filename
--help, -h, help Display this help and exit
+Placeholders: {{DEVICE_MODEL}}, {{SERIAL}}, {{BOARD_SERIAL}}, {{UUID}},
+ {{ROM}}, {{WIDTH}}, {{HEIGHT}}
+
Example:
- ./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
+ ./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 \\
+ --width 1920 \\
+ --height 1080
Author: Sick.Codes https://sick.codes/
-Project: https://github.com/sickcodes/Docker-OSX/
+Project: https://github.com/sickcodes/osx-serial-generator/
+License: GPLv3+
"
-PLIST_MASTER=config-nopicker-custom.plist
+OPENCORE_IMAGE_MAKER_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/opencore-image-ng.sh'
+MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-nopicker-custom.plist'
# gather arguments
while (( "$#" )); do
@@ -51,6 +66,7 @@ while (( "$#" )); do
export DEVICE_MODEL="${1#*=}"
shift
;;
+
--model* | -m* )
export DEVICE_MODEL="${2}"
shift
@@ -61,6 +77,7 @@ while (( "$#" )); do
export SERIAL="${1#*=}"
shift
;;
+
--serial* )
export SERIAL="${2}"
shift
@@ -71,6 +88,7 @@ while (( "$#" )); do
export BOARD_SERIAL="${1#*=}"
shift
;;
+
--board-serial* )
export BOARD_SERIAL="${2}"
shift
@@ -81,6 +99,7 @@ while (( "$#" )); do
export UUID="${1#*=}"
shift
;;
+
--uuid* )
export UUID="${2}"
shift
@@ -91,34 +110,81 @@ while (( "$#" )); do
export MAC_ADDRESS="${1#*=}"
shift
;;
+
--mac-address* )
export MAC_ADDRESS="${2}"
shift
shift
;;
+ --width=* )
+ export WIDTH="${1#*=}"
+ shift
+ ;;
+
+ --width* )
+ export WIDTH="${2}"
+ shift
+ shift
+ ;;
+
+ --height=* )
+ export HEIGHT="${1#*=}"
+ shift
+ ;;
+
+ --height* )
+ export HEIGHT="${2}"
+ shift
+ shift
+ ;;
+
--output-bootdisk=* )
export OUTPUT_QCOW="${1#*=}"
shift
;;
+
--output-bootdisk* )
export OUTPUT_QCOW="${2}"
shift
shift
;;
- --custom-plist=* )
- export INPUT_PLIST="${1#*=}"
+ --output-plist=* )
+ export OUTPUT_PLIST="${1#*=}"
+ shift
+ ;;
+
+ --output-plist* )
+ export OUTPUT_PLIST="${2}"
+ shift
+ shift
+ ;;
+
+ --master-plist-url=* | --input-plist-url=* | --custom-plist-url=* )
+ export MASTER_PLIST_URL="${1#*=}"
shift
;;
- --custom-plist* )
- export INPUT_PLIST="${2}"
+
+ --master-plist-url* | --input-plist-url* | --custom-plist-url* )
+ export MASTER_PLIST_URL="${2}"
+ shift
+ shift
+ ;;
+
+ --master-plist=* | --input-plist=* | --custom-plist=* )
+ export MASTER_PLIST="${1#*=}"
+ shift
+ ;;
+
+ --master-plist* | --input-plist* | --custom-plist* )
+ export MASTER_PLIST="${2}"
shift
shift
;;
*)
- echo "Invalid option. Running with default values..."
+ echo "Invalid option ${1}. Running with default values..."
shift
;;
esac
@@ -126,36 +192,69 @@ 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
+
+ export EFI_FOLDER=./OpenCore-Catalina/EFI
+ export RESOURCES_FOLDER=./resources/OcBinaryData/Resources
+
+ # check if we are inside OSX-KVM already
+ # if not, download OSX-KVM locally
+ [ -d ./OpenCore-Catalina/EFI/ ] || {
+ [ -d ./OSX-KVM/ ] || git clone --recurse-submodules --depth 1 https://github.com/kholia/OSX-KVM.git
+ export EFI_FOLDER="./OSX-KVM/${EFI_FOLDER}"
+ }
+
+ [ -d ./resources/OcBinaryData/Resources/ ] || {
+ export RESOURCES_FOLDER="./OSX-KVM/${RESOURCES_FOLDER}"
+ }
+
# EFI Shell commands
touch startup.nsh && echo 'fs0:\EFI\BOOT\BOOTx64.efi' > startup.nsh
+
+ cp -a "${EFI_FOLDER}" .
+
+ mkdir -p ./EFI/OC/Resources
+
+ # copy Apple drivers into EFI/OC/Resources
+ cp -a "${RESOURCES_FOLDER}"/* ./EFI/OC/Resources
}
generate_bootdisk () {
- [[ -e ./config-nopicker-custom.plist ]] || wget https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/custom/config-nopicker-custom.plist
- [[ -e ./opencore-image-ng.sh ]] || wget https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/custom/opencore-image-ng.sh && chmod +x opencore-image-ng.sh
+
+ # need a config.plist
+ if [ "${MASTER_PLIST}" ]; then
+ [ -e "${MASTER_PLIST}" ] || echo "Could not find: ${MASTER_PLIST}"
+ elif [ "${MASTER_PLIST}" ] && [ "${MASTER_PLIST_URL}" ]; then
+ echo 'You specified both a custom plist FILE & custom plist URL.'
+ echo 'Use only one of those options.'
+ elif [ "${MASTER_PLIST_URL}" ]; then
+ wget -O "${MASTER_PLIST:=./config-custom.plist}" "${MASTER_PLIST_URL}"
+ else
+ # default is config-nopicker-custom.plist from OSX-KVM with placeholders used in Docker-OSX
+ wget -O "${MASTER_PLIST:=./config-nopicker-custom.plist}" "${MASTER_PLIST_URL}"
+ fi
+
+ [ -e ./opencore-image-ng.sh ] \
+ || { wget "${OPENCORE_IMAGE_MAKER_URL}" \
+ && chmod +x opencore-image-ng.sh ; }
+
# plist required for bootdisks, so create anyway.
- if [[ "${DEVICE_MODEL}" ]] \
- && [[ "${SERIAL}" ]] \
- && [[ "${BOARD_SERIAL}" ]] \
- && [[ "${UUID}" ]] \
- && [[ "${MAC_ADDRESS}" ]]; then
+ if [ "${DEVICE_MODEL}" ] \
+ && [ "${SERIAL}" ] \
+ && [ "${BOARD_SERIAL}" ] \
+ && [ "${UUID}" ] \
+ && [ "${MAC_ADDRESS}" ]; then
ROM="${MAC_ADDRESS//\:/}"
ROM="${ROM,,}"
- 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}" > ./tmp.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 \
+ -e s/\{\{WIDTH\}\}/"${WIDTH:-1920}"/g \
+ -e s/\{\{HEIGHT\}\}/"${HEIGHT:-1080}"/g \
+ "${MASTER_PLIST}" > ./tmp.config.plist || exit 1
else
- cat <<EOF
+ cat <<EOF && exit 1
Error: one of the following values is missing:
--model "${DEVICE_MODEL:-MISSING}"
@@ -164,12 +263,14 @@ Error: one of the following values is missing:
--uuid "${UUID:-MISSING}"
--mac-address "${MAC_ADDRESS:-MISSING}"
+--width "${WIDTH:-1920}"
+--height "${HEIGHT:-1080}"
+
EOF
- exit 1
fi
./opencore-image-ng.sh \
- --cfg "${INPUT_PLIST:-./tmp.config.plist}" \
+ --cfg "./tmp.config.plist" \
--img "${OUTPUT_QCOW:-./${SERIAL}.OpenCore-nopicker.qcow2}" || exit 1
rm ./tmp.config.plist
diff --git a/custom/generate-unique-machine-values.sh b/custom/generate-unique-machine-values.sh
index 2248005..1cdd707 100755
--- a/custom/generate-unique-machine-values.sh
+++ b/custom/generate-unique-machine-values.sh
@@ -1,58 +1,63 @@
#!/bin/bash
-# ____ __ ____ ______ __
-# / __ \____ _____/ /_____ _____/ __ \/ ___/ |/ /
-# / / / / __ \/ ___/ //_/ _ \/ ___/ / / /\__ \| /
-# / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / |
-# /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| SERIALIZER
+# ___ _____ __ ___ _ _ ___ _
+# / _ \/ __\ \/ / / __| ___ _ _(_)__ _| | / __|___ _ _ ___ _ _ __ _| |_ ___ _ _
+# | (_) \__ \> < \__ \/ -_) '_| / _` | | | (_ / -_) ' \/ -_) '_/ _` | _/ _ \ '_|
+# \___/|___/_/\_\ |___/\___|_| |_\__,_|_| \___\___|_||_\___|_| \__,_|\__\___/_|
#
-# Repo: https://github.com/sickcodes/Docker-OSX/
-# Title: Mac on Docker (Docker-OSX)
+# Repo: https://github.com/sickcodes/osx-serial-generator/
+# Title: OSX Serial Generator
# Author: Sick.Codes https://sick.codes/
# Version: 3.1
# License: GPLv3+
-help_text="Usage: generate-unique-machine-values.sh
+set -e
+
+help_text="Usage: ./generate-unique-machine-values.sh
General options:
--count, -n, -c <count> Number of serials to generate
--model, -m <model> Device model, e.g. 'iMacPro1,1'
- --csv <filename> Optionally change the CSV output filename.
- --tsv <filename> Optionally change the TSV output filename.
- --output-bootdisk <filename> Optionally change the bootdisk qcow output filename. Useless when count > 1.
- --output-env <filename> Optionally change the bootdisk env filename. Useless when count > 1.
- --output-dir <directory> Optionally change the script output location.
-
+ --csv <filename> Optionally change the CSV output filename
+ --tsv <filename> Optionally change the TSV output filename
+ --output-dir <directory> Optionally change the script output location
+ --width <string> Resolution x axis length in px, default 1920
+ --height <string> Resolution y axis length in px, default 1080
+ --input-plist-url <url> Specify an alternative master plist, via URL
+ --master-plist-url <url> Same as above.
+ --custom-plist <filename> Optionally change the input plist.
+ --master-plist <filename> Same as above.
+ --output-bootdisk <filename> Optionally change the bootdisk filename
+ --create-envs, --envs Create all corresponding sourcable envs
+ --create-plists, --plists Create all corresponding config.plists
+ --create-bootdisks, --bootdisks Create all corresponding bootdisks [SLOW]
--help, -h, help Display this help and exit
- --plists Create corresponding config.plists for each serial set.
- --bootdisks [SLOW] Create corresponding boot disk images for each serial set.
+
+Additional options only if you are creating ONE serial set:
+ --output-bootdisk <filename> Optionally change the bootdisk filename
+ --output-env <filename> Optionally change the serials env filename
+
+Custom plist placeholders:
+ {{DEVICE_MODEL}}, {{SERIAL}}, {{BOARD_SERIAL}},
+ {{UUID}}, {{ROM}}, {{WIDTH}}, {{HEIGHT}}
Example:
- ./generate-unique-machine-values.sh --count 1 --model='iMacPro1,1' --plists --bootdisks
-
- 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 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'.
+ ./generate-unique-machine-values.sh --count 1 --plists --bootdisks --envs
+
+Defaults:
+ - One serial, for 'iMacPro1,1', in the current working directory
+ - CSV and TSV output
+ - plists in ./plists/ & bootdisks in ./bootdisks/ & envs in ./envs
+ - if you set --bootdisk name, --bootdisks is assumed
+ - if you set --custom-plist, --plists is assumed
+ - if you set --output-env, --envs is assumed
Author: Sick.Codes https://sick.codes/
-Project: https://github.com/sickcodes/Docker-OSX/
+Project: https://github.com/sickcodes/osx-serial-generator/
+License: GPLv3+
"
-MACINFOPKG_VERSION=2.1.2
-PLIST_MASTER=config-nopicker-custom.plist
+OPENCORE_IMAGE_MAKER_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/opencore-image-ng.sh'
+MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-nopicker-custom.plist'
# gather arguments
while (( "$#" )); do
@@ -66,6 +71,7 @@ while (( "$#" )); do
export SERIAL_SET_COUNT="${1#*=}"
shift
;;
+
--count* | -c* | -n* )
export SERIAL_SET_COUNT="${2}"
shift
@@ -76,6 +82,7 @@ while (( "$#" )); do
export CSV_OUTPUT_FILENAME="${1#*=}"
shift
;;
+
--csv* )
export CSV_OUTPUT_FILENAME="${2}"
shift
@@ -86,6 +93,7 @@ while (( "$#" )); do
export TSV_OUTPUT_FILENAME="${1#*=}"
shift
;;
+
--tsv* )
export TSV_OUTPUT_FILENAME="${2}"
shift
@@ -96,6 +104,7 @@ while (( "$#" )); do
export OUTPUT_DIRECTORY="${1#*=}"
shift
;;
+
--output-dir* )
export OUTPUT_DIRECTORY="${2}"
shift
@@ -103,11 +112,12 @@ while (( "$#" )); do
;;
--output-bootdisk=* )
- export OUTPUT_QCOW="${1#*=}"
+ export OUTPUT_BOOTDISK="${1#*=}"
shift
;;
+
--output-bootdisk* )
- export OUTPUT_QCOW="${2}"
+ export OUTPUT_BOOTDISK="${2}"
shift
shift
;;
@@ -116,6 +126,7 @@ while (( "$#" )); do
export OUTPUT_ENV="${1#*=}"
shift
;;
+
--output-env* )
export OUTPUT_ENV="${2}"
shift
@@ -126,18 +137,69 @@ while (( "$#" )); do
export DEVICE_MODEL="${1#*=}"
shift
;;
+
--model* | -m* )
export DEVICE_MODEL="${2}"
shift
shift
;;
- --plists )
+ --width=* )
+ export WIDTH="${1#*=}"
+ shift
+ ;;
+
+ --width* )
+ export WIDTH="${2}"
+ shift
+ shift
+ ;;
+
+ --height=* )
+ export HEIGHT="${1#*=}"
+ shift
+ ;;
+
+ --height* )
+ export HEIGHT="${2}"
+ shift
+ shift
+ ;;
+
+ --master-plist-url=* | --input-plist-url=* | --custom-plist-url=* )
+ export MASTER_PLIST_URL="${1#*=}"
+ shift
+ ;;
+
+ --master-plist-url* | --input-plist-url* | --custom-plist-url* )
+ export MASTER_PLIST_URL="${2}"
+ shift
+ shift
+ ;;
+
+ --master-plist=* | --input-plist=* | --custom-plist=* )
+ export MASTER_PLIST="${1#*=}"
+ shift
+ ;;
+
+ --master-plist* | --input-plist* | --custom-plist* )
+ export MASTER_PLIST="${2}"
+ shift
+ shift
+ ;;
+
+ --create-plists | --plists )
export CREATE_PLISTS=1
shift
;;
- --bootdisks )
- export CREATE_QCOWS=1
+
+ --create-bootdisks | --bootdisks )
+ export CREATE_BOOTDISKS=1
+ shift
+ ;;
+
+ --create-envs | --envs )
+ export CREATE_ENVS=1
shift
;;
@@ -150,124 +212,168 @@ done
build_mac_serial () {
- export MACINFOPKG_VERSION="${MACINFOPKG_VERSION:=2.1.2}"
- wget -O "${TARBALL:=./MacInfoPkg.tar.gz}" \
- "https://github.com/acidanthera/MacInfoPkg/archive/${MACINFOPKG_VERSION}.tar.gz"
- tar -xzvf "${TARBALL}"
- cd "./MacInfoPkg-${MACINFOPKG_VERSION}/macserial" \
- && ./build.tool \
- && cd -
- mv "./MacInfoPkg-${MACINFOPKG_VERSION}/macserial/bin/macserial" .
- rm -f "${TARBALL}"
- rm -rf "./MacInfoPkg-${MACINFOPKG_VERSION}/"
+ [ -d ./OpenCorePkg ] || git clone --depth 1 https://github.com/acidanthera/OpenCorePkg.git
+ make -C ./OpenCorePkg/Utilities/macserial/
+ mv ./OpenCorePkg/Utilities/macserial/macserial .
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
+ [ -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 --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
+
+ export EFI_FOLDER=./OpenCore-Catalina/EFI
+ export RESOURCES_FOLDER=./resources/OcBinaryData/Resources
+
+ # check if we are inside OSX-KVM already
+ # if not, download OSX-KVM locally
+ [ -d ./OpenCore-Catalina/EFI/ ] || {
+ [ -d ./OSX-KVM/ ] || git clone --recurse-submodules --depth 1 https://github.com/kholia/OSX-KVM.git
+ export EFI_FOLDER="./OSX-KVM/${EFI_FOLDER}"
+ }
+
+ [ -d ./resources/OcBinaryData/Resources/ ] || {
+ export RESOURCES_FOLDER="./OSX-KVM/${RESOURCES_FOLDER}"
+ }
+
# EFI Shell commands
touch startup.nsh && echo 'fs0:\EFI\BOOT\BOOTx64.efi' > startup.nsh
+
+ cp -a "${EFI_FOLDER}" .
+
+ mkdir -p ./EFI/OC/Resources
+
+ # copy Apple drivers into EFI/OC/Resources
+ cp -a "${RESOURCES_FOLDER}"/* ./EFI/OC/Resources
}
generate_serial_sets () {
- [[ -e ./config-nopicker-custom.plist ]] || wget https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/custom/config-nopicker-custom.plist
- [[ -e ./opencore-image-ng.sh ]] || wget https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/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}"
- export VENDOR_REGEX="${VENDOR_REGEX:=Apple, Inc.}"
+
+
- 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}"
+ if [ "${CSV_OUTPUT_FILENAME}" ]; then
+ [ "${CSV_OUTPUT_FILENAME}" ] && export CSV_SERIAL_SETS_FILE="${CSV_OUTPUT_FILENAME}"
else
- export SERIAL_SETS_FILE="${OUTPUT_DIRECTORY}/serial_sets-${DATE_NOW}.csv"
+ export CSV_SERIAL_SETS_FILE="${OUTPUT_DIRECTORY}/serial_sets-${DATE_NOW}.csv"
+ fi
+
+ if [ "${TSV_OUTPUT_FILENAME}" ]; then
+ [ "${TSV_OUTPUT_FILENAME}" ] && export TSV_SERIAL_SETS_FILE="${TSV_OUTPUT_FILENAME}"
+ else
+ export TSV_SERIAL_SETS_FILE="${OUTPUT_DIRECTORY}/serial_sets-${DATE_NOW}.tsv"
fi
-
- touch "${SERIAL_SETS_FILE}"
- echo "Writing serial sets to ${SERIAL_SETS_FILE}"
+
./macserial \
- --num "${SERIAL_SET_COUNT:=1}" \
+ --num "${SERIAL_SET_COUNT}" \
--model "${DEVICE_MODEL}" \
| while IFS='\ \|\ ' read -r SERIAL BOARD_SERIAL; do
# make a uuid...
UUID="$(uuidgen)"
- UUID="${UUID^^}"
+ # bash 3-5 compatible
+ # UUID="${UUID^^}"
+ UUID="$(tr '[:lower:]' '[:upper:]' <<< "${UUID}")"
# 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}")"
- MAC_ADDRESS="$(printf "${RANDOM_MAC_PREFIX}:%02X:%02X:%02X" $[RANDOM%256] $[RANDOM%256] $[RANDOM%256])"
+ MAC_ADDRESS="$(printf "${RANDOM_MAC_PREFIX}:%02X:%02X:%02X" "$((RANDOM%256))" "$((RANDOM%256))" "$((RANDOM%256))")"
+
+ [ -z "${WIDTH}" ] && WIDTH=1920
+ [ -z "${HEIGHT}" ] && HEIGHT=1080
# append to csv file
- if [[ "${CSV_SERIAL_SETS_FILE}" ]]; then
- echo "\"${DEVICE_MODEL}\",\"${SERIAL}\",\"${BOARD_SERIAL}\",\"${UUID}\",\"${MAC_ADDRESS}\"" >> "${CSV_SERIAL_SETS_FILE}"
- fi
+ tee -a "${CSV_SERIAL_SETS_FILE}" <<EOF
+"${DEVICE_MODEL}","${SERIAL}","${BOARD_SERIAL}","${UUID}","${MAC_ADDRESS}","${WIDTH}","${HEIGHT}"
+EOF
+ echo "Wrote CSV to: ${CSV_SERIAL_SETS_FILE}"
# append to tsv file
- if [[ "${TSV_SERIAL_SETS_FILE}" ]]; then
- 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"}"
- touch "${OUTPUT_ENV_FILE}"
- cat <<EOF > "${OUTPUT_ENV_FILE}"
+ T=$'\t'
+ tee -a "${TSV_SERIAL_SETS_FILE}" <<EOF
+${DEVICE_MODEL}${T}${SERIAL}${T}${BOARD_SERIAL}${T}${UUID}${T}${MAC_ADDRESS}${T}${WIDTH}${T}${HEIGHT}
+EOF
+ echo "Wrote TSV to: ${TSV_SERIAL_SETS_FILE}"
+
+ # if any of these are on, we need the env file.
+ if [ "${CREATE_ENVS}" ] || [ "${CREATE_PLISTS}" ] || [ "${CREATE_BOOTDISKS}" ] || [ "${OUTPUT_BOOTDISK}" ] || [ "${OUTPUT_ENV}" ]; then
+ mkdir -p "${OUTPUT_DIRECTORY}/envs"
+ OUTPUT_ENV_FILE="${OUTPUT_ENV:-"${OUTPUT_DIRECTORY}/envs/${SERIAL}.env.sh"}"
+ touch "${OUTPUT_ENV_FILE}"
+ cat <<EOF > "${OUTPUT_ENV_FILE}"
export DEVICE_MODEL="${DEVICE_MODEL}"
export SERIAL="${SERIAL}"
export BOARD_SERIAL="${BOARD_SERIAL}"
export UUID="${UUID}"
export MAC_ADDRESS="${MAC_ADDRESS}"
+export WIDTH="${WIDTH}"
+export HEIGHT="${HEIGHT}"
EOF
+ fi
+
# plist required for bootdisks, so create anyway.
- if [[ "${CREATE_PLISTS}" ]] || [[ "${CREATE_QCOWS}" ]]; then
+ if [ "${CREATE_PLISTS}" ] || [ "${CREATE_BOOTDISKS}" ]; then
+
+ # need a config.plist
+ if [ "${MASTER_PLIST}" ]; then
+ [ -e "${MASTER_PLIST}" ] || echo "Could not find: ${MASTER_PLIST}"
+ elif [ "${MASTER_PLIST}" ] && [ "${MASTER_PLIST_URL}" ]; then
+ echo 'You specified both a custom plist FILE & custom plist URL.'
+ echo 'Use only one of those options.'
+ elif [ "${MASTER_PLIST_URL}" ]; then
+ wget -O "${MASTER_PLIST:=./config-custom.plist}" "${MASTER_PLIST_URL}"
+ else
+ # default is config-nopicker-custom.plist from OSX-KVM with placeholders used in Docker-OSX
+ wget -O "${MASTER_PLIST:=./config-nopicker-custom.plist}" "${MASTER_PLIST_URL}"
+ fi
+
mkdir -p "${OUTPUT_DIRECTORY}/plists"
source "${OUTPUT_ENV_FILE}"
ROM_VALUE="${MAC_ADDRESS//\:/}"
ROM_VALUE="${ROM_VALUE,,}"
- 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
+ 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 \
+ -e s/\{\{WIDTH\}\}/"${WIDTH}"/g \
+ -e s/\{\{HEIGHT\}\}/"${HEIGHT}"/g \
+ "${MASTER_PLIST}" > "${OUTPUT_DIRECTORY}/plists/${SERIAL}.config.plist" || exit 1
fi
- if [[ "${CREATE_QCOWS}" ]]; then
- mkdir -p "${OUTPUT_DIRECTORY}/qcows"
+ # make bootdisk qcow2 format if --bootdisks, but also if you set the bootdisk filename
+ if [ "${CREATE_BOOTDISKS}" ] || [ "${OUTPUT_BOOTDISK}" ]; then
+ [ -e ./opencore-image-ng.sh ] \
+ || { wget "${OPENCORE_IMAGE_MAKER_URL}" \
+ && chmod +x opencore-image-ng.sh ; }
+ mkdir -p "${OUTPUT_DIRECTORY}/bootdisks"
./opencore-image-ng.sh \
--cfg "${OUTPUT_DIRECTORY}/plists/${SERIAL}.config.plist" \
- --img "${OUTPUT_QCOW:-${OUTPUT_DIRECTORY}/qcows/${SERIAL}.OpenCore-nopicker.qcow2}" || exit 1
+ --img "${OUTPUT_BOOTDISK:-${OUTPUT_DIRECTORY}/bootdisks/${SERIAL}.OpenCore-nopicker.qcow2}" || exit 1
fi
done
- [[ -e "${CSV_SERIAL_SETS_FILE}" ]] && \
- cat <(echo "DEVICE_MODEL,SERIAL,BOARD_SERIAL,UUID,MAC_ADDRESS") "${CSV_SERIAL_SETS_FILE}"
+ [ -e "${CSV_SERIAL_SETS_FILE}" ] && \
+ cat <(echo "DEVICE_MODEL,SERIAL,BOARD_SERIAL,UUID,MAC_ADDRESS,WIDTH,HEIGHT") "${CSV_SERIAL_SETS_FILE}"
- [[ -e "${TSV_SERIAL_SETS_FILE}" ]] && \
- cat <(printf "DEVICE_MODEL\tSERIAL\tBOARD_SERIAL\tUUID\tMAC_ADDRESS\n") "${TSV_SERIAL_SETS_FILE}"
-
+ [ -e "${TSV_SERIAL_SETS_FILE}" ] && \
+ cat <(printf "DEVICE_MODEL\tSERIAL\tBOARD_SERIAL\tUUID\tMAC_ADDRESS\tWIDTH\tHEIGHT\n") "${TSV_SERIAL_SETS_FILE}"
+
}
main () {
# setting default variables if there are no options
+ export DATE_NOW="$(date +%F-%T)"
export DEVICE_MODEL="${DEVICE_MODEL:=iMacPro1,1}"
+ export VENDOR_REGEX="${VENDOR_REGEX:=Apple, Inc.}"
export SERIAL_SET_COUNT="${SERIAL_SET_COUNT:=1}"
export OUTPUT_DIRECTORY="${OUTPUT_DIRECTORY:=.}"
cat <<EOF
@@ -275,10 +381,12 @@ DEVICE_MODEL: ${DEVICE_MODEL}
SERIAL_SET_COUNT: ${SERIAL_SET_COUNT}
OUTPUT_DIRECTORY: ${OUTPUT_DIRECTORY}
EOF
- [[ -d "${OUTPUT_DIRECTORY}" ]] || mkdir -p "${OUTPUT_DIRECTORY}"
- [[ -e ./macserial ]] || build_mac_serial
+ [ -d "${OUTPUT_DIRECTORY}" ] || mkdir -p "${OUTPUT_DIRECTORY}"
+ [ -e ./macserial ] || build_mac_serial
download_vendor_mac_addresses
- download_qcow_efi_folder
+ if [ "${CREATE_BOOTDISKS}" ] || [ "${OUTPUT_BOOTDISK}" ]; then
+ download_qcow_efi_folder
+ fi
generate_serial_sets
echo "${SERIAL_SETS_FILE}"
}
diff --git a/custom/opencore-image-ng.sh b/custom/opencore-image-ng.sh
index 56eaa45..5743b05 100755
--- a/custom/opencore-image-ng.sh
+++ b/custom/opencore-image-ng.sh
@@ -89,7 +89,7 @@ function fish_fini() {
fish umount-all
}
-# disabled by sick.codes to allow unattended image overwrites
+# disabled by @sickcodes to allow unattended image overwrites
######################################################################
# sanity checks