Merge pull request #163 from sickcodes/resolution-changes-runtime

Add WIDTH and HEIGHT environment variables
This commit is contained in:
sickcodes 2021-03-04 13:46:58 +00:00 committed by GitHub
commit 3add4f7a98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 375 additions and 55 deletions

View File

@ -1,5 +1,7 @@
|Version|Date|Notes| |Version|Date|Notes|
|---|---|---| |---|---|---|
|4.1|2021-03-04|Add `-e MASTER_PLIST_URL` to all images to allow using your own remote plist.|
| |2021-03-03|Add `WIDTH` and `HEIGHT` to set the x and y resolutions, use in conjuction with serial numbers.|
| |2021-03-02|Add ADDITIONAL_PORTS, for example `-e ADDITIONAL_PORTS='hostfwd=tcp::23-:23,'`| | |2021-03-02|Add ADDITIONAL_PORTS, for example `-e ADDITIONAL_PORTS='hostfwd=tcp::23-:23,'`|
|4.0|2021-02-27|Add big-sur support. Use `sickcodes/docker-osx:big-sur` or build using `--build-arg VERSION=11`| |4.0|2021-02-27|Add big-sur support. Use `sickcodes/docker-osx:big-sur` or build using `--build-arg VERSION=11`|
| |2021-02-26|Change `-e NOPICKER=true` to simply do `sed -i '/^.*InstallMedia.*/d' Launch.sh` and `export BOOTDISK=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2`.| | |2021-02-26|Change `-e NOPICKER=true` to simply do `sed -i '/^.*InstallMedia.*/d' Launch.sh` and `export BOOTDISK=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2`.|

View File

@ -5,11 +5,12 @@
# / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / | # / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / |
# /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| # /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_|
# #
# Repo: https://github.com/sickcodes/Docker-OSX/ # Title: Docker-OSX (Mac on Docker)
# Title: Mac on Docker (Docker-OSX) # Author: Sick.Codes https://twitter.com/sickcodes
# Author: Sick.Codes https://sick.codes/ # Version: 4.1
# Version: 4.0
# License: GPLv3+ # License: GPLv3+
# Repository: https://github.com/sickcodes/Docker-OSX
# Website: https://sick.codes
# #
# All credits for OSX-KVM and the rest at @Kholia's repo: https://github.com/kholia/osx-kvm # All credits for OSX-KVM and the rest at @Kholia's repo: https://github.com/kholia/osx-kvm
# OpenCore support go to https://github.com/Leoyzen/KVM-Opencore # OpenCore support go to https://github.com/Leoyzen/KVM-Opencore
@ -259,8 +260,21 @@ ENV NETWORKING=vmxnet3
ENV NOPICKER=false ENV NOPICKER=false
ENV UNIQUE=false # Boolean for generating a bootdisk with new random serials.
# Boolean for generating a bootdisk with new serials. ENV GENERATE_UNIQUE=false
# Boolean for generating a bootdisk with specific serials.
ENV GENERATE_SPECIFIC=false
# boolean for skipping the disk selection menu at in the boot process
ENV NOPICKER=false
# The x and y coordinates for resolution.
# Must be used with either -e GENERATE_UNIQUE=true or -e GENERATE_SPECIFIC=true.
ENV WIDTH=1920
ENV HEIGHT=1080
ENV MASTER_PLIST_URL="https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/custom/config-nopicker-custom.plist"
VOLUME ["/tmp/.X11-unix"] VOLUME ["/tmp/.X11-unix"]
@ -296,21 +310,27 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS
; } \ ; } \
; [[ "${GENERATE_UNIQUE}" == true ]] && { \ ; [[ "${GENERATE_UNIQUE}" == true ]] && { \
./Docker-OSX/custom/generate-unique-machine-values.sh \ ./Docker-OSX/custom/generate-unique-machine-values.sh \
--count 1 \ --master-plist-url="${MASTER_PLIST_URL}" \
--tsv ./serial.tsv \ --count 1 \
--bootdisks \ --tsv ./serial.tsv \
--output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ --bootdisks \
--output-env "${ENV:=/env}" || exit 1 \ --width "${WIDTH:-1920}" \
--height "${HEIGHT:-1080}" \
--output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \
--output-env "${ENV:=/env}" \
; } \ ; } \
; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \
source "${ENV:=/env}" \ source "${ENV:=/env}" 2>/dev/null \
|| ./Docker-OSX/custom/generate-specific-bootdisk.sh \ ; ./Docker-OSX/custom/generate-specific-bootdisk.sh \
--master-plist-url="${MASTER_PLIST_URL}" \
--model "${DEVICE_MODEL}" \ --model "${DEVICE_MODEL}" \
--serial "${SERIAL}" \ --serial "${SERIAL}" \
--board-serial "${BOARD_SERIAL}" \ --board-serial "${BOARD_SERIAL}" \
--uuid "${UUID}" \ --uuid "${UUID}" \
--mac-address "${MAC_ADDRESS}" \ --mac-address "${MAC_ADDRESS}" \
--output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" || exit 1 \ --width "${WIDTH:-1920}" \
--height "${HEIGHT:-1080}" \
--output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \
; } \ ; } \
; case "$(file --brief /bootdisk)" in \ ; case "$(file --brief /bootdisk)" in \
QEMU\ QCOW2\ Image* ) export BOOTDISK=/bootdisk \ QEMU\ QCOW2\ Image* ) export BOOTDISK=/bootdisk \

View File

@ -3,13 +3,14 @@
# / __ \____ _____/ /_____ _____/ __ \/ ___/ |/ / # / __ \____ _____/ /_____ _____/ __ \/ ___/ |/ /
# / / / / __ \/ ___/ //_/ _ \/ ___/ / / /\__ \| / # / / / / __ \/ ___/ //_/ _ \/ ___/ / / /\__ \| /
# / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / | # / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / |
# /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| AUTOINSTALL # /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| :AUTO
# #
# Title: Mac on Docker (Docker-OSX) [AUTOINSTALL] # Title: Docker-OSX (Mac on Docker)
# Author: Sick.Codes https://twitter.com/sickcodes # Author: Sick.Codes https://twitter.com/sickcodes
# Version: 4.0 # Version: 4.1
# License: GPLv3+ # License: GPLv3+
# Repository: https://github.com/sickcodes/Docker-OSX # Repository: https://github.com/sickcodes/Docker-OSX
# Website: https://sick.codes
# #
# This Dockerfile is a pre-installed naked installation of Docker-OSX! # This Dockerfile is a pre-installed naked installation of Docker-OSX!
# #
@ -152,21 +153,27 @@ CMD echo "${BOILERPLATE}" \
; } \ ; } \
; [[ "${GENERATE_UNIQUE}" == true ]] && { \ ; [[ "${GENERATE_UNIQUE}" == true ]] && { \
./Docker-OSX/custom/generate-unique-machine-values.sh \ ./Docker-OSX/custom/generate-unique-machine-values.sh \
--count 1 \ --master-plist-url="${MASTER_PLIST_URL}" \
--tsv ./serial.tsv \ --count 1 \
--bootdisks \ --tsv ./serial.tsv \
--output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ --bootdisks \
--output-env "${ENV:=/env}" || exit 1 \ --width "${WIDTH:-1920}" \
--height "${HEIGHT:-1080}" \
--output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \
--output-env "${ENV:=/env}" \
; } \ ; } \
; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \
source "${ENV:=/env}" \ source "${ENV:=/env}" 2>/dev/null \
|| ./Docker-OSX/custom/generate-specific-bootdisk.sh \ ; ./Docker-OSX/custom/generate-specific-bootdisk.sh \
--master-plist-url="${MASTER_PLIST_URL}" \
--model "${DEVICE_MODEL}" \ --model "${DEVICE_MODEL}" \
--serial "${SERIAL}" \ --serial "${SERIAL}" \
--board-serial "${BOARD_SERIAL}" \ --board-serial "${BOARD_SERIAL}" \
--uuid "${UUID}" \ --uuid "${UUID}" \
--mac-address "${MAC_ADDRESS}" \ --mac-address "${MAC_ADDRESS}" \
--output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" || exit 1 \ --width "${WIDTH:-1920}" \
--height "${HEIGHT:-1080}" \
--output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \
; } \ ; } \
; case "$(file --brief /bootdisk)" in \ ; case "$(file --brief /bootdisk)" in \
QEMU\ QCOW2\ Image* ) export BOOTDISK=/bootdisk \ QEMU\ QCOW2\ Image* ) export BOOTDISK=/bootdisk \

View File

@ -3,13 +3,14 @@
# / __ \____ _____/ /_____ _____/ __ \/ ___/ |/ / # / __ \____ _____/ /_____ _____/ __ \/ ___/ |/ /
# / / / / __ \/ ___/ //_/ _ \/ ___/ / / /\__ \| / # / / / / __ \/ ___/ //_/ _ \/ ___/ / / /\__ \| /
# / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / | # / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / |
# /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| NAKED/SUPPLY_YOUR_OWN # /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| :NAKED
# #
# Title: Mac on Docker (Docker-OSX) [AUTOINSTALL] # Title: Docker-OSX (Mac on Docker)
# Author: Sick.Codes https://twitter.com/sickcodes # Author: Sick.Codes https://twitter.com/sickcodes
# Version: 4.0 # Version: 4.1
# License: GPLv3+ # License: GPLv3+
# Repository: https://github.com/sickcodes/Docker-OSX # Repository: https://github.com/sickcodes/Docker-OSX
# Website: https://sick.codes
# #
# This image won't run unless you supply a disk image using: # This image won't run unless you supply a disk image using:
# -v ${PWD}/mac_hdd_ng.img:/image # -v ${PWD}/mac_hdd_ng.img:/image
@ -122,21 +123,27 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS
; } \ ; } \
; [[ "${GENERATE_UNIQUE}" == true ]] && { \ ; [[ "${GENERATE_UNIQUE}" == true ]] && { \
./Docker-OSX/custom/generate-unique-machine-values.sh \ ./Docker-OSX/custom/generate-unique-machine-values.sh \
--count 1 \ --master-plist-url="${MASTER_PLIST_URL}" \
--tsv ./serial.tsv \ --count 1 \
--bootdisks \ --tsv ./serial.tsv \
--output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ --bootdisks \
--output-env "${ENV:=/env}" || exit 1 \ --width "${WIDTH:-1920}" \
--height "${HEIGHT:-1080}" \
--output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \
--output-env "${ENV:=/env}" \
; } \ ; } \
; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \
source "${ENV:=/env}" \ source "${ENV:=/env}" 2>/dev/null \
|| ./Docker-OSX/custom/generate-specific-bootdisk.sh \ ; ./Docker-OSX/custom/generate-specific-bootdisk.sh \
--master-plist-url="${MASTER_PLIST_URL}" \
--model "${DEVICE_MODEL}" \ --model "${DEVICE_MODEL}" \
--serial "${SERIAL}" \ --serial "${SERIAL}" \
--board-serial "${BOARD_SERIAL}" \ --board-serial "${BOARD_SERIAL}" \
--uuid "${UUID}" \ --uuid "${UUID}" \
--mac-address "${MAC_ADDRESS}" \ --mac-address "${MAC_ADDRESS}" \
--output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" || exit 1 \ --width "${WIDTH:-1920}" \
--height "${HEIGHT:-1080}" \
--output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \
; } \ ; } \
; case "$(file --brief /bootdisk)" in \ ; case "$(file --brief /bootdisk)" in \
QEMU\ QCOW2\ Image* ) export BOOTDISK=/bootdisk \ QEMU\ QCOW2\ Image* ) export BOOTDISK=/bootdisk \

137
README.md
View File

@ -493,6 +493,43 @@ sudo nohup dockerd &
sudo systemctl enable docker sudo systemctl enable docker
``` ```
# How to Forward Additional Ports from the guest.
This is how it visually looks:
`host:10023 <-> 10023:container:10023 <-> 80:guest`
```bash
On the host
```bash
docker run -it \
--device /dev/kvm \
-p 50922:10022 \
-e ADDITIONAL_PORTS='hostfwd=tcp::10023-:80,' \
-p 10023:10023 \
sickcodes/docker-osx:auto
```
Inside the container:
```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install nginx
sudo sed -i -e 's/8080/80/' /usr/local/etc/nginx/nginx.confcd
# sudo nginx -s stop
sudo nginx
```
nginx should appear on the host at port 10023.
You can string multiple statements, for example:
```bash
-e ADDITIONAL_PORTS='hostfwd=tcp::10023-:80,hostfwd=tcp::10043-:443,'
-p 10023:10023 \
-p 10043:10043 \
```
# How to Enable Network Forwarding # How to Enable Network Forwarding
Allow ipv4 forwarding for bridged networking connections: Allow ipv4 forwarding for bridged networking connections:
@ -706,11 +743,13 @@ For serial numbers, generate them in `./custom` OR make docker generate them at
At any time, verify your serial number before logging in iCloud, etc. At any time, verify your serial number before logging in iCloud, etc.
```bash ```bash
# this is a quick way to check your serial number via cli inside OSX
ioreg -l | grep IOPlatformSerialNumber ioreg -l | grep IOPlatformSerialNumber
# or from the host # or from the host
sshpass -p alpine ssh user@localhost -p 50922 'ioreg -l | grep IOPlatformSerialNumber' sshpass -p 'alpine' ssh user@localhost -p 50922 'ioreg -l | grep IOPlatformSerialNumber'
``` ```
# This example generates a random set of serial numbers at runtime, headlessly
```bash ```bash
# proof of concept only, generates random serial numbers, headlessly, and quits right after. # proof of concept only, generates random serial numbers, headlessly, and quits right after.
@ -724,6 +763,8 @@ docker run --rm -it \
sickcodes/docker-osx:auto sickcodes/docker-osx:auto
``` ```
# This example generates a specific set of serial numbers at runtime
```bash ```bash
# run the same as above 17gb auto image, with SSH, with nopicker, and save the bootdisk for later. # run the same as above 17gb auto image, with SSH, with nopicker, and save the bootdisk for later.
# you don't need to save the bootdisk IF you supply specific serial numbers! # you don't need to save the bootdisk IF you supply specific serial numbers!
@ -743,6 +784,7 @@ docker run -it \
sickcodes/docker-osx:auto sickcodes/docker-osx:auto
``` ```
### This example generates a specific set of serial numbers at runtime, with your existing image, at 1000x1000 display resolution.
```bash ```bash
# run an existing image in current directory, with a screen, with SSH, with nopicker, and save the bootdisk for later. # run an existing image in current directory, with a screen, with SSH, with nopicker, and save the bootdisk for later.
@ -762,6 +804,8 @@ docker run -it \
-e BOARD_SERIAL="C027251024NJG36UE" \ -e BOARD_SERIAL="C027251024NJG36UE" \
-e UUID="5CCB366D-9118-4C61-A00A-E5BAF3BED451" \ -e UUID="5CCB366D-9118-4C61-A00A-E5BAF3BED451" \
-e MAC_ADDRESS="A8:5C:2C:9A:46:2F" \ -e MAC_ADDRESS="A8:5C:2C:9A:46:2F" \
-e WIDTH=1000 \
-e HEIGHT=1000 \
-e BOOTDISK=/bootdisk \ -e BOOTDISK=/bootdisk \
-v "${PWD}/mynewbootdisk.qcow:/bootdisk" \ -v "${PWD}/mynewbootdisk.qcow:/bootdisk" \
-v "${PWD}/mac_hdd_ng.img:/image" \ -v "${PWD}/mac_hdd_ng.img:/image" \
@ -876,6 +920,97 @@ generate-specific-bootdisk.sh \
--output-bootdisk OpenCore-nopicker.qcow2 --output-bootdisk OpenCore-nopicker.qcow2
``` ```
# Change Resolution Docker-OSX - change resolution OpenCore OSX-KVM
The display resolution is controlled by this line:
https://github.com/sickcodes/Docker-OSX/blob/master/custom/config-nopicker-custom.plist#L819
Instead of mounting that disk, Docker-OSX will generate a new `OpenCore.qcow2` by using this one cool trick:
```bash
-e GENERATE_UNIQUE=true \
-e WIDTH=800 \
-e HEIGHT=600 \
```
To use `WIDTH`/`HEIGHT`, you must use with either `-e GENERATE_UNIQUE=true` or `-e GENERATE_SPECIFIC=true`.
It will take around 30 seconds longer to boot because it needs to make a new boot partition using `libguestfs`.
```bash
-e GENERATE_SPECIFIC=true \
-e WIDTH=1920 \
-e HEIGHT=1080 \
-e SERIAL="" \
-e BOARD_SERIAL="" \
-e UUID="" \
-e MAC_ADDRESS="" \
```
## Change Docker-OSX Resolution Examples
```bash
# using an image in your current directory
stat mac_hdd_ng.img
docker run -it \
--device /dev/kvm \
-p 50922:10022 \
-v "${PWD}/mac_hdd_ng.img:/image" \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e "DISPLAY=${DISPLAY:-:0.0}" \
-e GENERATE_SPECIFIC=true \
-e DEVICE_MODEL="iMacPro1,1" \
-e SERIAL="C02TW0WAHX87" \
-e BOARD_SERIAL="C027251024NJG36UE" \
-e UUID="5CCB366D-9118-4C61-A00A-E5BAF3BED451" \
-e MAC_ADDRESS="A8:5C:2C:9A:46:2F" \
-e MASTER_PLIST_URL=https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/custom/config-nopicker-custom.plist \
-e WIDTH=1600 \
-e HEIGHT=900 \
sickcodes/docker-osx:naked
```
```bash
# generating random serial numbers, using the DIY installer, along with the screen resolution changes.
docker run -it \
--device /dev/kvm \
-p 50922:10022 \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e "DISPLAY=${DISPLAY:-:0.0}" \
-e GENERATE_UNIQUE=true \
-e WIDTH=800 \
-e HEIGHT=600 \
sickcodes/docker-osx:latest
```
Here's a few other resolutions! If you resolution is invalid, it will default to 800x600.
```
-e WIDTH=800 \
-e HEIGHT=600 \
```
```
-e WIDTH=1280 \
-e HEIGHT=768 \
```
```
-e WIDTH=1600 \
-e HEIGHT=900 \
```
```
-e WIDTH=1920 \
-e HEIGHT=1080 \
```
```
-e WIDTH=2560 \
-e HEIGHT=1600 \
```
# Allow USB passthrough # Allow USB passthrough
The simplest way to do this is the following: The simplest way to do this is the following:

View File

@ -816,7 +816,7 @@
<key>ReplaceTabWithSpace</key> <key>ReplaceTabWithSpace</key>
<false/> <false/>
<key>Resolution</key> <key>Resolution</key>
<string>1920x1080@32</string> <string>{{WIDTH}}x{{HEIGHT}}@32</string>
<key>SanitiseClearScreen</key> <key>SanitiseClearScreen</key>
<false/> <false/>
<key>TextRenderer</key> <key>TextRenderer</key>

View File

@ -15,12 +15,19 @@ help_text="Usage: generate-specific-bootdisk.sh
General options: General options:
--model <string> Device model, e.g. 'iMacPro1,1' --model <string> Device model, e.g. 'iMacPro1,1'
--serial <filename> Device Serial number. --serial <filename> Device Serial number
--board-serial <filename> Board Serial number. --board-serial <filename> Board Serial number
--uuid <filename> SmUUID. --uuid <filename> SmUUID
--mac-address <string> Used to set the ROM value; lowercased and without a colon. --mac-address <string> Used to set the ROM value; lowercased and without a colon
--output-bootdisk <filename> Optionally change the bootdisk output filename. --width <string> Resolution x axis length in pixels (default 1920)
--custom-plist <filename> Optionally change the input plist. --height <string> Resolution y axis length in pixels (default 1080
--output-bootdisk <filename> Optionally change the bootdisk output filename
--master-plist-url <url> Specify an alternative master plist, via URL.
--custom-plist | --master-plist <filename>
Optionally change the input plist. Placeholders:
{{DEVICE_MODEL}}, {{SERIAL}}, {{BOARD_SERIAL}},
{{UUID}}, {{ROM}}, {{WIDTH}}, {{HEIGHT}}
--help, -h, help Display this help and exit --help, -h, help Display this help and exit
@ -31,7 +38,9 @@ Example:
--board-serial C027251024NJG36UE \ --board-serial C027251024NJG36UE \
--uuid 5CCB366D-9118-4C61-A00A-E5BAF3BED451 \ --uuid 5CCB366D-9118-4C61-A00A-E5BAF3BED451 \
--mac-address A8:5C:2C:9A:46:2F \ --mac-address A8:5C:2C:9A:46:2F \
--output-bootdisk OpenCore-nopicker.qcow2 --output-bootdisk OpenCore-nopicker.qcow2 \
--widht 1920 \
--height 1080
Author: Sick.Codes https://sick.codes/ Author: Sick.Codes https://sick.codes/
Project: https://github.com/sickcodes/Docker-OSX/ Project: https://github.com/sickcodes/Docker-OSX/
@ -97,6 +106,26 @@ while (( "$#" )); do
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=* ) --output-bootdisk=* )
export OUTPUT_QCOW="${1#*=}" export OUTPUT_QCOW="${1#*=}"
shift shift
@ -107,12 +136,33 @@ while (( "$#" )); do
shift shift
;; ;;
--master-plist-url=* )
export MASTER_PLIST_URL="${1#*=}"
shift
;;
--master-plist-url* )
export MASTER_PLIST_URL="${2}"
shift
shift
;;
--master-plist=* )
export MASTER_PLIST="${1#*=}"
shift
;;
--master-plist* )
export MASTER_PLIST="${2}"
shift
shift
;;
--custom-plist=* ) --custom-plist=* )
export INPUT_PLIST="${1#*=}" export MASTER_PLIST="${1#*=}"
shift shift
;; ;;
--custom-plist* ) --custom-plist* )
export INPUT_PLIST="${2}" export MASTER_PLIST="${2}"
shift shift
shift shift
;; ;;
@ -138,8 +188,23 @@ download_qcow_efi_folder () {
} }
generate_bootdisk () { generate_bootdisk () {
[[ -e ./config-nopicker-custom.plist ]] || wget https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/custom/config-nopicker-custom.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 AND a custom plist url. Use one or the other.'
elif [[ "${MASTER_PLIST_URL}" ]]; then
wget -O "${MASTER_PLIST:=./config-custom.plist}" "${MASTER_PLIST_URL}" \
|| { echo "Could not download ${MASTER_PLIST_URL}" && exit 1 ; }
else
MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/custom/config-nopicker-custom.plist'
wget -O "${MASTER_PLIST:=./config-nopicker-custom.plist}" "${MASTER_PLIST_URL}" \
|| { echo "Could not download ${MASTER_PLIST_URL}" && exit 1 ; }
fi
[[ -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 [[ -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
# plist required for bootdisks, so create anyway. # plist required for bootdisks, so create anyway.
if [[ "${DEVICE_MODEL}" ]] \ if [[ "${DEVICE_MODEL}" ]] \
&& [[ "${SERIAL}" ]] \ && [[ "${SERIAL}" ]] \
@ -153,7 +218,9 @@ generate_bootdisk () {
-e s/{{BOARD_SERIAL}}/"${BOARD_SERIAL}"/g \ -e s/{{BOARD_SERIAL}}/"${BOARD_SERIAL}"/g \
-e s/{{UUID}}/"${UUID}"/g \ -e s/{{UUID}}/"${UUID}"/g \
-e s/{{ROM}}/"${ROM}"/g \ -e s/{{ROM}}/"${ROM}"/g \
"${PLIST_MASTER}" > ./tmp.config.plist || exit 1 -e s/{{WIDTH}}/"${WIDTH:-1920}"/g \
-e s/{{HEIGHT}}/"${HEIGHT:-1080}"/g \
"${MASTER_PLIST}" > ./tmp.config.plist || exit 1
else else
cat <<EOF cat <<EOF
Error: one of the following values is missing: Error: one of the following values is missing:
@ -164,12 +231,15 @@ Error: one of the following values is missing:
--uuid "${UUID:-MISSING}" --uuid "${UUID:-MISSING}"
--mac-address "${MAC_ADDRESS:-MISSING}" --mac-address "${MAC_ADDRESS:-MISSING}"
--width "${WIDTH:-1920}"
--height "${HEIGHT:-1080}"
EOF EOF
exit 1 exit 1
fi fi
./opencore-image-ng.sh \ ./opencore-image-ng.sh \
--cfg "${INPUT_PLIST:-./tmp.config.plist}" \ --cfg "./tmp.config.plist" \
--img "${OUTPUT_QCOW:-./${SERIAL}.OpenCore-nopicker.qcow2}" || exit 1 --img "${OUTPUT_QCOW:-./${SERIAL}.OpenCore-nopicker.qcow2}" || exit 1
rm ./tmp.config.plist rm ./tmp.config.plist

View File

@ -21,6 +21,14 @@ General options:
--output-bootdisk <filename> Optionally change the bootdisk qcow output filename. Useless when count > 1. --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-env <filename> Optionally change the bootdisk env filename. Useless when count > 1.
--output-dir <directory> Optionally change the script output location. --output-dir <directory> Optionally change the script output location.
--width <string> Resolution x axis length in pixels (default 1920)
--height <string> Resolution y axis length in pixels (default 1080
--master-plist-url <url> Specify an alternative master plist, via URL.
--master-plist | --custom-plist <filename>
Optionally change the input plist. Placeholders:
{{DEVICE_MODEL}}, {{SERIAL}}, {{BOARD_SERIAL}},
{{UUID}}, {{ROM}}, {{WIDTH}}, {{HEIGHT}}
--help, -h, help Display this help and exit --help, -h, help Display this help and exit
--plists Create corresponding config.plists for each serial set. --plists Create corresponding config.plists for each serial set.
@ -52,7 +60,6 @@ Project: https://github.com/sickcodes/Docker-OSX/
" "
MACINFOPKG_VERSION=2.1.2 MACINFOPKG_VERSION=2.1.2
PLIST_MASTER=config-nopicker-custom.plist
# gather arguments # gather arguments
while (( "$#" )); do while (( "$#" )); do
@ -132,6 +139,60 @@ while (( "$#" )); do
shift shift
;; ;;
--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=* )
export MASTER_PLIST_URL="${1#*=}"
shift
;;
--master-plist-url* )
export MASTER_PLIST_URL="${2}"
shift
shift
;;
--master-plist=* )
export MASTER_PLIST="${1#*=}"
shift
;;
--master-plist* )
export MASTER_PLIST="${2}"
shift
shift
;;
--custom-plist=* )
export MASTER_PLIST="${1#*=}"
shift
;;
--custom-plist* )
export MASTER_PLIST="${2}"
shift
shift
;;
--plists ) --plists )
export CREATE_PLISTS=1 export CREATE_PLISTS=1
shift shift
@ -183,8 +244,22 @@ download_qcow_efi_folder () {
generate_serial_sets () { generate_serial_sets () {
[[ -e ./config-nopicker-custom.plist ]] || wget https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/custom/config-nopicker-custom.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 AND a custom plist url. Use one or the other.'
elif [[ "${MASTER_PLIST_URL}" ]]; then
wget -O "${MASTER_PLIST:=./config-custom.plist}" "${MASTER_PLIST_URL}" \
|| { echo "Could not download ${MASTER_PLIST_URL}" && exit 1 ; }
else
MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/custom/config-nopicker-custom.plist'
wget -O "${MASTER_PLIST:=./config-nopicker-custom.plist}" "${MASTER_PLIST_URL}" \
|| { echo "Could not download ${MASTER_PLIST_URL}" && exit 1 ; }
fi
[[ -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 [[ -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" mkdir -p "${OUTPUT_DIRECTORY}/envs"
export DATE_NOW="$(date +%F-%T)" export DATE_NOW="$(date +%F-%T)"
export DEVICE_MODEL="${DEVICE_MODEL:=iMacPro1,1}" export DEVICE_MODEL="${DEVICE_MODEL:=iMacPro1,1}"
@ -231,6 +306,8 @@ export SERIAL="${SERIAL}"
export BOARD_SERIAL="${BOARD_SERIAL}" export BOARD_SERIAL="${BOARD_SERIAL}"
export UUID="${UUID}" export UUID="${UUID}"
export MAC_ADDRESS="${MAC_ADDRESS}" export MAC_ADDRESS="${MAC_ADDRESS}"
export WIDTH="${WIDTH:=1920}"
export HEIGHT="${HEIGHT:=1080}"
EOF EOF
# plist required for bootdisks, so create anyway. # plist required for bootdisks, so create anyway.
@ -244,7 +321,9 @@ EOF
-e s/{{BOARD_SERIAL}}/"${BOARD_SERIAL}"/g \ -e s/{{BOARD_SERIAL}}/"${BOARD_SERIAL}"/g \
-e s/{{UUID}}/"${UUID}"/g \ -e s/{{UUID}}/"${UUID}"/g \
-e s/{{ROM}}/"${ROM}"/g \ -e s/{{ROM}}/"${ROM}"/g \
"${PLIST_MASTER}" > "${OUTPUT_DIRECTORY}/plists/${SERIAL}.config.plist" || exit 1 -e s/{{WIDTH}}/"${WIDTH}"/g \
-e s/{{HEIGHT}}/"${HEIGHT}"/g \
"${MASTER_PLIST}" > "${OUTPUT_DIRECTORY}/plists/${SERIAL}.config.plist" || exit 1
fi fi
if [[ "${CREATE_QCOWS}" ]]; then if [[ "${CREATE_QCOWS}" ]]; then