From 5d648e1b599faaab341b97dc286d5be91c831aab Mon Sep 17 00:00:00 2001 From: sickcodes Date: Mon, 1 Mar 2021 11:23:12 +0000 Subject: [PATCH 01/68] Switch default internet to vmxnet3 as there is no incompatability with services. --- Dockerfile | 6 +++--- README.md | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8033913..6fe698a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -226,7 +226,7 @@ RUN touch Launch.sh \ && tee -a Launch.sh <<< '-drive id=MacHDD,if=none,file=${IMAGE_PATH:-/home/arch/OSX-KVM/mac_hdd_ng.img},format=qcow2 \' \ && tee -a Launch.sh <<< '-device ide-hd,bus=sata.4,drive=MacHDD \' \ && tee -a Launch.sh <<< '-netdev user,id=net0,hostfwd=tcp::${INTERNAL_SSH_PORT:-10022}-:22,hostfwd=tcp::${SCREEN_SHARE_PORT:-5900}-:5900, \' \ - && tee -a Launch.sh <<< '-device ${NETWORKING:-e1000-82545em},netdev=net0,id=net0,mac=${MAC_ADDRESS:-52:54:00:09:49:17} \' \ + && tee -a Launch.sh <<< '-device ${NETWORKING:-vmxnet3},netdev=net0,id=net0,mac=${MAC_ADDRESS:-52:54:00:09:49:17} \' \ && tee -a Launch.sh <<< '-monitor stdio \' \ && tee -a Launch.sh <<< '-vga vmware \' \ && tee -a Launch.sh <<< '${EXTRA:-}' @@ -250,8 +250,8 @@ ENV ENV=/env ENV IMAGE_PATH=/home/arch/OSX-KVM/mac_hdd_ng.img -ENV NETWORKING=e1000-82545em -# ENV NETWORKING=vmxnet3 +# ENV NETWORKING=e1000-82545em +ENV NETWORKING=vmxnet3 ENV NOPICKER=false diff --git a/README.md b/README.md index 3daf0ee..2cc7799 100644 --- a/README.md +++ b/README.md @@ -577,12 +577,11 @@ sudo mv somedir/mac_hdd_ng.img . # Internet Speeds -### Slow internet but iMessage & iCloud compatability -`-e NETWORKING=e1000-82545em` - -### FAST internet but not compatable with iMessage & iCloud +### FAST internet `-e NETWORKING=vmxnet3` +### SLOW internet +`-e NETWORKING=e1000-82545em` # DESTROY: Wipe old images to free disk space From 5b060b8de24a027b10b61f9ad43c99fd2787bdc2 Mon Sep 17 00:00:00 2001 From: Edson Boldrini Date: Tue, 2 Mar 2021 07:20:09 -0300 Subject: [PATCH 02/68] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2cc7799..3a8b604 100644 --- a/README.md +++ b/README.md @@ -47,9 +47,9 @@ Thank you to @cephasara for this major contribution. ### There are 3 images: **latest**, **auto** and **naked**. -`sickcodes/docker-osx:latest` - [I want to try it out.](https://github.com/sickcodes/Docker-OSX#quick-start-175gb-pre-made-image) +`sickcodes/docker-osx:latest` - [I want to try it out.](https://github.com/sickcodes/Docker-OSX#quick-start-large-pre-made-image) -`sickcodes/docker-osx:latest` - [I want to use Docker-OSX to develop/secure Apps in Xcode (sign into Xcode, Transporter)](https://github.com/sickcodes/Docker-OSX#quick-start-docker-osx) +`sickcodes/docker-osx:latest` - [I want to use Docker-OSX to develop/secure Apps in Xcode (sign into Xcode, Transporter)](https://github.com/sickcodes/Docker-OSX#basic-quick-start-docker-osx) `sickcodes/docker-osx:naked` - [I want to use Docker-OSX in CI/CD (sign into Xcode, Transporter)](https://github.com/sickcodes/Docker-OSX#fully-headless-using-my-own-image-for-cicd) Create your personal image using `:latest`. And then pull your image out. And then use duplicate that image again & again for use in `:naked`. From 55f3fd00b1b8aa144355b65b73d0c2e0158ab845 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Tue, 2 Mar 2021 21:24:28 +0000 Subject: [PATCH 03/68] Add ADDITIONAL_PORTS, -e ADDITIONAL_PORTS='hostfwd=tcp::23-:23,' --- CHANGELOG.md | 1 + CREDITS.md | 1 + Dockerfile | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8d9df2..9157591 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ |Version|Date|Notes| |---|---|---| +| |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`| | |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`.| |3.2|2021-02-25|Add a script to generate unique machine serial numbers. Add a script to generate a bootdisk from given serial numbers. Add Linux for libguestfs which allows the docker container to make QEMU bootdisks with specific serial numbers.| diff --git a/CREDITS.md b/CREDITS.md index 82f579a..ae37ee1 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -56,3 +56,4 @@ These credits refer to the contributors to this repository: [@MrBenFTW](https://github.com/MrBenFTW) - Tempfix for arch #150 +[@edsonboldrini](https://github.com/edsonboldrini) - Update README.md #161 diff --git a/Dockerfile b/Dockerfile index 6fe698a..bff6570 100644 --- a/Dockerfile +++ b/Dockerfile @@ -202,6 +202,10 @@ ARG BRANCH=master ARG REPO='https://github.com/sickcodes/Docker-OSX.git' RUN git clone --branch "${BRANCH}" "${REPO}" +# env -e ADDITIONAL_PORTS with a comma +# for example, -e ADDITIONAL_PORTS=hostfwd=tcp::23-:23, +ENV ADDITIONAL_PORTS= + RUN touch Launch.sh \ && chmod +x ./Launch.sh \ && tee -a Launch.sh <<< '#!/bin/sh' \ @@ -225,7 +229,7 @@ RUN touch Launch.sh \ && tee -a Launch.sh <<< '-drive id=InstallMedia,if=none,file=/home/arch/OSX-KVM/BaseSystem.img,format=qcow2 \' \ && tee -a Launch.sh <<< '-drive id=MacHDD,if=none,file=${IMAGE_PATH:-/home/arch/OSX-KVM/mac_hdd_ng.img},format=qcow2 \' \ && tee -a Launch.sh <<< '-device ide-hd,bus=sata.4,drive=MacHDD \' \ - && tee -a Launch.sh <<< '-netdev user,id=net0,hostfwd=tcp::${INTERNAL_SSH_PORT:-10022}-:22,hostfwd=tcp::${SCREEN_SHARE_PORT:-5900}-:5900, \' \ + && tee -a Launch.sh <<< '-netdev user,id=net0,hostfwd=tcp::${INTERNAL_SSH_PORT:-10022}-:22,hostfwd=tcp::${SCREEN_SHARE_PORT:-5900}-:5900,${ADDITIONAL_PORTS} \' \ && tee -a Launch.sh <<< '-device ${NETWORKING:-vmxnet3},netdev=net0,id=net0,mac=${MAC_ADDRESS:-52:54:00:09:49:17} \' \ && tee -a Launch.sh <<< '-monitor stdio \' \ && tee -a Launch.sh <<< '-vga vmware \' \ From 5469cb8a582cc6354b45b2a4ddd9820ebeffa1c5 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Wed, 3 Mar 2021 16:54:45 +0000 Subject: [PATCH 04/68] Add WIDTH and HEIGHT environment variables --- CHANGELOG.md | 1 + Dockerfile | 29 ++++++--- README.md | 76 +++++++++++++++++++++++- custom/config-nopicker-custom.plist | 2 +- custom/generate-specific-bootdisk.sh | 43 +++++++++++--- custom/generate-unique-machine-values.sh | 27 +++++++++ 6 files changed, 162 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9157591..8396d7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ |Version|Date|Notes| |---|---|---| +| |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,'`| |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`.| diff --git a/Dockerfile b/Dockerfile index bff6570..8afebe3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -259,8 +259,19 @@ ENV NETWORKING=vmxnet3 ENV NOPICKER=false -ENV UNIQUE=false -# Boolean for generating a bootdisk with new serials. +# Boolean for generating a bootdisk with new random 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 VOLUME ["/tmp/.X11-unix"] @@ -296,11 +307,13 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS ; } \ ; [[ "${GENERATE_UNIQUE}" == true ]] && { \ ./Docker-OSX/custom/generate-unique-machine-values.sh \ - --count 1 \ - --tsv ./serial.tsv \ - --bootdisks \ - --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ - --output-env "${ENV:=/env}" || exit 1 \ + --count 1 \ + --tsv ./serial.tsv \ + --bootdisks \ + --width "${WIDTH:-1920}" \ + --height "${HEIGHT:-1080}" \ + --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ + --output-env "${ENV:=/env}" || exit 1 \ ; } \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ source "${ENV:=/env}" \ @@ -310,6 +323,8 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS --board-serial "${BOARD_SERIAL}" \ --uuid "${UUID}" \ --mac-address "${MAC_ADDRESS}" \ + --width "${WIDTH:-1920}" \ + --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" || exit 1 \ ; } \ ; case "$(file --brief /bootdisk)" in \ diff --git a/README.md b/README.md index 3a8b604..08cf699 100644 --- a/README.md +++ b/README.md @@ -493,6 +493,43 @@ sudo nohup dockerd & 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 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. ```bash +# this is a quick way to check your serial number via cli inside OSX ioreg -l | grep IOPlatformSerialNumber # 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 # 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 ``` +# This example generates a specific set of serial numbers at runtime + ```bash # 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! @@ -743,6 +784,7 @@ docker run -it \ sickcodes/docker-osx:auto ``` +# This example generates a specific set of serial numbers at runtime, with your existing image, at 1000x1000 display resolution. ```bash # 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 UUID="5CCB366D-9118-4C61-A00A-E5BAF3BED451" \ -e MAC_ADDRESS="A8:5C:2C:9A:46:2F" \ + -e WIDTH=1000 \ + -e HEIGHT=1000 \ -e BOOTDISK=/bootdisk \ -v "${PWD}/mynewbootdisk.qcow:/bootdisk" \ -v "${PWD}/mac_hdd_ng.img:/image" \ @@ -780,6 +824,36 @@ Or you can generate them inside the `./custom` folder. And then use: -e MAC_ADDRESS="" \ ``` +# Change Resolution Docker-OSX + +The display resolution is controlled by this line: + +https://github.com/sickcodes/Docker-OSX/blob/master/custom/config-nopicker-custom.plist#L819 + +However, you need to mount that disk. Boring! + +Instead, you can simply add the following to any image: + +```bash +-e GENERATE_UNIQUE=true \ +-e WIDTH=1920 \ +-e HEIGHT=1080 \ +``` + +It will take around 1 minute longer to boot because it will make a new boot partition. + +```bash +-e GENERATE_SPECIFIC=true \ +-e WIDTH=1920 \ +-e HEIGHT=1080 \ +-e SERIAL="" \ +-e BOARD_SERIAL="" \ +-e UUID="" \ +-e MAC_ADDRESS="" \ +``` + +Must be used with either `-e GENERATE_UNIQUE=true` or `-e GENERATE_SPECIFIC=true`. + #### Persistence from generating serial numbers is obviously ideal: ```bash diff --git a/custom/config-nopicker-custom.plist b/custom/config-nopicker-custom.plist index 6166234..aa60a39 100644 --- a/custom/config-nopicker-custom.plist +++ b/custom/config-nopicker-custom.plist @@ -816,7 +816,7 @@ ReplaceTabWithSpace Resolution - 1920x1080@32 + {{WIDTH}}x{{HEIGHT}}@32 SanitiseClearScreen TextRenderer diff --git a/custom/generate-specific-bootdisk.sh b/custom/generate-specific-bootdisk.sh index 76aff0c..d5450b8 100755 --- a/custom/generate-specific-bootdisk.sh +++ b/custom/generate-specific-bootdisk.sh @@ -15,12 +15,14 @@ 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. + --serial Device Serial number + --board-serial Board Serial number + --uuid SmUUID + --mac-address Used to set the ROM value; lowercased and without a colon + --width Resolution x axis length in pixels (default 1920) + --height Resolution y axis length in pixels (default 1080 + --output-bootdisk Optionally change the bootdisk output filename + --custom-plist Optionally change the input plist --help, -h, help Display this help and exit @@ -31,7 +33,9 @@ Example: --board-serial C027251024NJG36UE \ --uuid 5CCB366D-9118-4C61-A00A-E5BAF3BED451 \ --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/ Project: https://github.com/sickcodes/Docker-OSX/ @@ -97,6 +101,26 @@ while (( "$#" )); do 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 @@ -153,6 +177,8 @@ generate_bootdisk () { -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 \ "${PLIST_MASTER}" > ./tmp.config.plist || exit 1 else cat < 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. + --width Resolution x axis length in pixels (default 1920) + --height Resolution y axis length in pixels (default 1080 --help, -h, help Display this help and exit --plists Create corresponding config.plists for each serial set. @@ -132,6 +134,27 @@ while (( "$#" )); do shift ;; + --width=* ) + export WIDTH="${1#*=}" + shift + ;; + + --width* ) + export WIDTH="${2}" + shift + shift + ;; + + --height=* ) + export HEIGHT="${1#*=}" + shift + ;; + --height* ) + export HEIGHT="${2}" + shift + shift + ;; + --plists ) export CREATE_PLISTS=1 shift @@ -231,6 +254,8 @@ export SERIAL="${SERIAL}" export BOARD_SERIAL="${BOARD_SERIAL}" export UUID="${UUID}" export MAC_ADDRESS="${MAC_ADDRESS}" +export WIDTH="${WIDTH:=1920}" +export HEIGHT="${HEIGHT:=1080}" EOF # plist required for bootdisks, so create anyway. @@ -244,6 +269,8 @@ EOF -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 \ "${PLIST_MASTER}" > "${OUTPUT_DIRECTORY}/plists/${SERIAL}.config.plist" || exit 1 fi From 408248ae4f95f4c2760afa94bfb06d799c7317f8 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Thu, 4 Mar 2021 09:12:50 +0000 Subject: [PATCH 05/68] Missing WIDTH and HEIGHT from naked and auto Dockerfiles --- Dockerfile.auto | 14 +++++++++----- Dockerfile.naked | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Dockerfile.auto b/Dockerfile.auto index ca6e548..a5b03a8 100644 --- a/Dockerfile.auto +++ b/Dockerfile.auto @@ -152,11 +152,13 @@ CMD echo "${BOILERPLATE}" \ ; } \ ; [[ "${GENERATE_UNIQUE}" == true ]] && { \ ./Docker-OSX/custom/generate-unique-machine-values.sh \ - --count 1 \ - --tsv ./serial.tsv \ - --bootdisks \ - --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ - --output-env "${ENV:=/env}" || exit 1 \ + --count 1 \ + --tsv ./serial.tsv \ + --bootdisks \ + --width "${WIDTH:-1920}" \ + --height "${HEIGHT:-1080}" \ + --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ + --output-env "${ENV:=/env}" || exit 1 \ ; } \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ source "${ENV:=/env}" \ @@ -166,6 +168,8 @@ CMD echo "${BOILERPLATE}" \ --board-serial "${BOARD_SERIAL}" \ --uuid "${UUID}" \ --mac-address "${MAC_ADDRESS}" \ + --width "${WIDTH:-1920}" \ + --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" || exit 1 \ ; } \ ; case "$(file --brief /bootdisk)" in \ diff --git a/Dockerfile.naked b/Dockerfile.naked index 09db8a3..e2a2806 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -122,11 +122,13 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS ; } \ ; [[ "${GENERATE_UNIQUE}" == true ]] && { \ ./Docker-OSX/custom/generate-unique-machine-values.sh \ - --count 1 \ - --tsv ./serial.tsv \ - --bootdisks \ - --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ - --output-env "${ENV:=/env}" || exit 1 \ + --count 1 \ + --tsv ./serial.tsv \ + --bootdisks \ + --width "${WIDTH:-1920}" \ + --height "${HEIGHT:-1080}" \ + --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ + --output-env "${ENV:=/env}" || exit 1 \ ; } \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ source "${ENV:=/env}" \ @@ -136,6 +138,8 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS --board-serial "${BOARD_SERIAL}" \ --uuid "${UUID}" \ --mac-address "${MAC_ADDRESS}" \ + --width "${WIDTH:-1920}" \ + --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" || exit 1 \ ; } \ ; case "$(file --brief /bootdisk)" in \ From 3f4c0c6bd4d993e90fd66138521247a2014e70f2 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Thu, 4 Mar 2021 09:48:04 +0000 Subject: [PATCH 06/68] Add --custom-plist-url, --custom-plist or --master-plist to both serial generators. --- custom/generate-specific-bootdisk.sh | 53 +++++++++++++++++++--- custom/generate-unique-machine-values.sh | 58 ++++++++++++++++++++++-- 2 files changed, 102 insertions(+), 9 deletions(-) diff --git a/custom/generate-specific-bootdisk.sh b/custom/generate-specific-bootdisk.sh index d5450b8..1dadfe5 100755 --- a/custom/generate-specific-bootdisk.sh +++ b/custom/generate-specific-bootdisk.sh @@ -22,7 +22,12 @@ General options: --width Resolution x axis length in pixels (default 1920) --height Resolution y axis length in pixels (default 1080 --output-bootdisk Optionally change the bootdisk output filename - --custom-plist Optionally change the input plist + + --master-plist-url Specify an alternative master plist, via URL. + --custom-plist | --master-plist + Optionally change the input plist. Placeholders: + {{DEVICE_MODEL}}, {{SERIAL}}, {{BOARD_SERIAL}}, + {{UUID}}, {{ROM}}, {{WIDTH}}, {{HEIGHT}} --help, -h, help Display this help and exit @@ -131,12 +136,33 @@ while (( "$#" )); do 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 INPUT_PLIST="${1#*=}" + export MASTER_PLIST="${1#*=}" shift ;; --custom-plist* ) - export INPUT_PLIST="${2}" + export MASTER_PLIST="${2}" shift shift ;; @@ -162,8 +188,23 @@ download_qcow_efi_folder () { } 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}" ]]; + echo 'You specified both a custom plist file AND a custom plist url. Use one or the other.' + elif [[ "${MASTER_PLIST_URL}" ]]; + 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 + # plist required for bootdisks, so create anyway. if [[ "${DEVICE_MODEL}" ]] \ && [[ "${SERIAL}" ]] \ @@ -179,7 +220,7 @@ generate_bootdisk () { -e s/{{ROM}}/"${ROM}"/g \ -e s/{{WIDTH}}/"${WIDTH:-1920}"/g \ -e s/{{HEIGHT}}/"${HEIGHT:-1080}"/g \ - "${PLIST_MASTER}" > ./tmp.config.plist || exit 1 + "${MASTER_PLIST}" > ./tmp.config.plist || exit 1 else cat < Resolution x axis length in pixels (default 1920) --height Resolution y axis length in pixels (default 1080 + --master-plist-url Specify an alternative master plist, via URL. + --master-plist | --custom-plist + Optionally change the input plist. Placeholders: + {{DEVICE_MODEL}}, {{SERIAL}}, {{BOARD_SERIAL}}, + {{UUID}}, {{ROM}}, {{WIDTH}}, {{HEIGHT}} + --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. @@ -54,7 +60,6 @@ Project: https://github.com/sickcodes/Docker-OSX/ " MACINFOPKG_VERSION=2.1.2 -PLIST_MASTER=config-nopicker-custom.plist # gather arguments while (( "$#" )); do @@ -155,6 +160,39 @@ while (( "$#" )); do 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 ) export CREATE_PLISTS=1 shift @@ -206,8 +244,22 @@ download_qcow_efi_folder () { 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}" ]]; + echo 'You specified both a custom plist file AND a custom plist url. Use one or the other.' + elif [[ "${MASTER_PLIST_URL}" ]]; + 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 + mkdir -p "${OUTPUT_DIRECTORY}/envs" export DATE_NOW="$(date +%F-%T)" export DEVICE_MODEL="${DEVICE_MODEL:=iMacPro1,1}" @@ -271,7 +323,7 @@ EOF -e s/{{ROM}}/"${ROM}"/g \ -e s/{{WIDTH}}/"${WIDTH}"/g \ -e s/{{HEIGHT}}/"${HEIGHT}"/g \ - "${PLIST_MASTER}" > "${OUTPUT_DIRECTORY}/plists/${SERIAL}.config.plist" || exit 1 + "${MASTER_PLIST}" > "${OUTPUT_DIRECTORY}/plists/${SERIAL}.config.plist" || exit 1 fi if [[ "${CREATE_QCOWS}" ]]; then From 377c4e7cc5cdd785e965e13e15086c2326797b51 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Thu, 4 Mar 2021 09:52:45 +0000 Subject: [PATCH 07/68] Add -e MASTER_PLIST_URL to change the input config.plist at runtime. --- CHANGELOG.md | 1 + Dockerfile | 4 ++++ Dockerfile.auto | 2 ++ Dockerfile.naked | 2 ++ 4 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8396d7d..abc2d75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ |Version|Date|Notes| |---|---|---| +| |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,'`| |4.0|2021-02-27|Add big-sur support. Use `sickcodes/docker-osx:big-sur` or build using `--build-arg VERSION=11`| diff --git a/Dockerfile b/Dockerfile index 8afebe3..5539d62 100644 --- a/Dockerfile +++ b/Dockerfile @@ -273,6 +273,8 @@ ENV NOPICKER=false 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"] # check if /image is a disk image or a directory. This allows you to optionally use -v disk.img:/image @@ -307,6 +309,7 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS ; } \ ; [[ "${GENERATE_UNIQUE}" == true ]] && { \ ./Docker-OSX/custom/generate-unique-machine-values.sh \ + --master-plist-url="${MASTER_PLIST_URL}" \ --count 1 \ --tsv ./serial.tsv \ --bootdisks \ @@ -318,6 +321,7 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ source "${ENV:=/env}" \ || ./Docker-OSX/custom/generate-specific-bootdisk.sh \ + --master-plist-url="${MASTER_PLIST_URL}" \ --model "${DEVICE_MODEL}" \ --serial "${SERIAL}" \ --board-serial "${BOARD_SERIAL}" \ diff --git a/Dockerfile.auto b/Dockerfile.auto index a5b03a8..d203551 100644 --- a/Dockerfile.auto +++ b/Dockerfile.auto @@ -152,6 +152,7 @@ CMD echo "${BOILERPLATE}" \ ; } \ ; [[ "${GENERATE_UNIQUE}" == true ]] && { \ ./Docker-OSX/custom/generate-unique-machine-values.sh \ + --master-plist-url="${MASTER_PLIST_URL}" \ --count 1 \ --tsv ./serial.tsv \ --bootdisks \ @@ -163,6 +164,7 @@ CMD echo "${BOILERPLATE}" \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ source "${ENV:=/env}" \ || ./Docker-OSX/custom/generate-specific-bootdisk.sh \ + --master-plist-url="${MASTER_PLIST_URL}" \ --model "${DEVICE_MODEL}" \ --serial "${SERIAL}" \ --board-serial "${BOARD_SERIAL}" \ diff --git a/Dockerfile.naked b/Dockerfile.naked index e2a2806..a1a1de3 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -122,6 +122,7 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS ; } \ ; [[ "${GENERATE_UNIQUE}" == true ]] && { \ ./Docker-OSX/custom/generate-unique-machine-values.sh \ + --master-plist-url="${MASTER_PLIST_URL}" \ --count 1 \ --tsv ./serial.tsv \ --bootdisks \ @@ -133,6 +134,7 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ source "${ENV:=/env}" \ || ./Docker-OSX/custom/generate-specific-bootdisk.sh \ + --master-plist-url="${MASTER_PLIST_URL}" \ --model "${DEVICE_MODEL}" \ --serial "${SERIAL}" \ --board-serial "${BOARD_SERIAL}" \ From 84fc71722c1742c0f51fb4b89317717ae4a987df Mon Sep 17 00:00:00 2001 From: sickcodes Date: Thu, 4 Mar 2021 11:42:36 +0000 Subject: [PATCH 08/68] Syntax error: `elif` obviously needs a `; then` --- custom/generate-specific-bootdisk.sh | 4 ++-- custom/generate-unique-machine-values.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/custom/generate-specific-bootdisk.sh b/custom/generate-specific-bootdisk.sh index 1dadfe5..62e2005 100755 --- a/custom/generate-specific-bootdisk.sh +++ b/custom/generate-specific-bootdisk.sh @@ -191,9 +191,9 @@ generate_bootdisk () { if [[ "${MASTER_PLIST}" ]]; then [[ -e "${MASTER_PLIST}" ]] || echo "Could not find: ${MASTER_PLIST}" - elif [[ "${MASTER_PLIST}" ]] && [[ "${MASTER_PLIST_URL}" ]]; + 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}" ]]; + 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 diff --git a/custom/generate-unique-machine-values.sh b/custom/generate-unique-machine-values.sh index 811f4b5..0aee356 100755 --- a/custom/generate-unique-machine-values.sh +++ b/custom/generate-unique-machine-values.sh @@ -247,9 +247,9 @@ generate_serial_sets () { if [[ "${MASTER_PLIST}" ]]; then [[ -e "${MASTER_PLIST}" ]] || echo "Could not find: ${MASTER_PLIST}" - elif [[ "${MASTER_PLIST}" ]] && [[ "${MASTER_PLIST_URL}" ]]; + 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}" ]]; + 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 From 45a5f2c074de948eaef8d48bde2a3df9ce238289 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Thu, 4 Mar 2021 11:57:52 +0000 Subject: [PATCH 09/68] wget -O case sensitive, silence source /env errors. --- Dockerfile | 4 ++-- Dockerfile.auto | 4 ++-- Dockerfile.naked | 7 +++---- custom/generate-specific-bootdisk.sh | 4 ++-- custom/generate-unique-machine-values.sh | 4 ++-- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5539d62..9dba25d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -319,8 +319,8 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS --output-env "${ENV:=/env}" || exit 1 \ ; } \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ - source "${ENV:=/env}" \ - || ./Docker-OSX/custom/generate-specific-bootdisk.sh \ + source "${ENV:=/env}" 2>/dev/null \ + ; ./Docker-OSX/custom/generate-specific-bootdisk.sh \ --master-plist-url="${MASTER_PLIST_URL}" \ --model "${DEVICE_MODEL}" \ --serial "${SERIAL}" \ diff --git a/Dockerfile.auto b/Dockerfile.auto index d203551..b5ac7da 100644 --- a/Dockerfile.auto +++ b/Dockerfile.auto @@ -162,8 +162,8 @@ CMD echo "${BOILERPLATE}" \ --output-env "${ENV:=/env}" || exit 1 \ ; } \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ - source "${ENV:=/env}" \ - || ./Docker-OSX/custom/generate-specific-bootdisk.sh \ + source "${ENV:=/env}" 2>/dev/null \ + ; ./Docker-OSX/custom/generate-specific-bootdisk.sh \ --master-plist-url="${MASTER_PLIST_URL}" \ --model "${DEVICE_MODEL}" \ --serial "${SERIAL}" \ diff --git a/Dockerfile.naked b/Dockerfile.naked index a1a1de3..b0e0871 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -132,8 +132,8 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS --output-env "${ENV:=/env}" || exit 1 \ ; } \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ - source "${ENV:=/env}" \ - || ./Docker-OSX/custom/generate-specific-bootdisk.sh \ + source "${ENV:=/env}" 2>/dev/null \ + ; ./Docker-OSX/custom/generate-specific-bootdisk.sh \ --master-plist-url="${MASTER_PLIST_URL}" \ --model "${DEVICE_MODEL}" \ --serial "${SERIAL}" \ @@ -142,8 +142,7 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS --mac-address "${MAC_ADDRESS}" \ --width "${WIDTH:-1920}" \ --height "${HEIGHT:-1080}" \ - --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" || exit 1 \ - ; } \ + --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" ; case "$(file --brief /bootdisk)" in \ QEMU\ QCOW2\ Image* ) export BOOTDISK=/bootdisk \ ;; \ diff --git a/custom/generate-specific-bootdisk.sh b/custom/generate-specific-bootdisk.sh index 62e2005..9f56409 100755 --- a/custom/generate-specific-bootdisk.sh +++ b/custom/generate-specific-bootdisk.sh @@ -194,11 +194,11 @@ generate_bootdisk () { 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}" \ + 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}" \ + wget -O "./${MASTER_PLIST:=/config-nopicker-custom.plist}" "${MASTER_PLIST_URL}" \ || echo "Could not download ${MASTER_PLIST_URL}" && exit 1 fi diff --git a/custom/generate-unique-machine-values.sh b/custom/generate-unique-machine-values.sh index 0aee356..2eece98 100755 --- a/custom/generate-unique-machine-values.sh +++ b/custom/generate-unique-machine-values.sh @@ -250,11 +250,11 @@ generate_serial_sets () { 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}" \ + 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}" \ + wget -O "./${MASTER_PLIST:=/config-nopicker-custom.plist}" "${MASTER_PLIST_URL}" \ || echo "Could not download ${MASTER_PLIST_URL}" && exit 1 fi From e03f0737c3ce4428047808c367409396cfa9e7ff Mon Sep 17 00:00:00 2001 From: sickcodes Date: Thu, 4 Mar 2021 11:59:40 +0000 Subject: [PATCH 10/68] Fix `.//config-custom.plist` --- custom/generate-specific-bootdisk.sh | 4 ++-- custom/generate-unique-machine-values.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/custom/generate-specific-bootdisk.sh b/custom/generate-specific-bootdisk.sh index 9f56409..f407f3d 100755 --- a/custom/generate-specific-bootdisk.sh +++ b/custom/generate-specific-bootdisk.sh @@ -194,11 +194,11 @@ generate_bootdisk () { 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}" \ + 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}" \ + wget -O "${MASTER_PLIST:=./config-nopicker-custom.plist}" "${MASTER_PLIST_URL}" \ || echo "Could not download ${MASTER_PLIST_URL}" && exit 1 fi diff --git a/custom/generate-unique-machine-values.sh b/custom/generate-unique-machine-values.sh index 2eece98..f013898 100755 --- a/custom/generate-unique-machine-values.sh +++ b/custom/generate-unique-machine-values.sh @@ -250,11 +250,11 @@ generate_serial_sets () { 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}" \ + 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}" \ + wget -O "${MASTER_PLIST:=./config-nopicker-custom.plist}" "${MASTER_PLIST_URL}" \ || echo "Could not download ${MASTER_PLIST_URL}" && exit 1 fi From 4b278bc42c10c29fc8592d018bf2e59678cf8174 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Thu, 4 Mar 2021 12:05:41 +0000 Subject: [PATCH 11/68] Shift exits --- Dockerfile | 4 ++-- Dockerfile.auto | 4 ++-- Dockerfile.naked | 5 +++-- custom/generate-specific-bootdisk.sh | 4 ++-- custom/generate-unique-machine-values.sh | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9dba25d..61464b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -316,7 +316,7 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS --width "${WIDTH:-1920}" \ --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ - --output-env "${ENV:=/env}" || exit 1 \ + --output-env "${ENV:=/env}" \ ; } \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ source "${ENV:=/env}" 2>/dev/null \ @@ -329,7 +329,7 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS --mac-address "${MAC_ADDRESS}" \ --width "${WIDTH:-1920}" \ --height "${HEIGHT:-1080}" \ - --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" || exit 1 \ + --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ ; } \ ; case "$(file --brief /bootdisk)" in \ QEMU\ QCOW2\ Image* ) export BOOTDISK=/bootdisk \ diff --git a/Dockerfile.auto b/Dockerfile.auto index b5ac7da..1e0c84e 100644 --- a/Dockerfile.auto +++ b/Dockerfile.auto @@ -159,7 +159,7 @@ CMD echo "${BOILERPLATE}" \ --width "${WIDTH:-1920}" \ --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ - --output-env "${ENV:=/env}" || exit 1 \ + --output-env "${ENV:=/env}" \ ; } \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ source "${ENV:=/env}" 2>/dev/null \ @@ -172,7 +172,7 @@ CMD echo "${BOILERPLATE}" \ --mac-address "${MAC_ADDRESS}" \ --width "${WIDTH:-1920}" \ --height "${HEIGHT:-1080}" \ - --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" || exit 1 \ + --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ ; } \ ; case "$(file --brief /bootdisk)" in \ QEMU\ QCOW2\ Image* ) export BOOTDISK=/bootdisk \ diff --git a/Dockerfile.naked b/Dockerfile.naked index b0e0871..6ac5333 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -129,7 +129,7 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS --width "${WIDTH:-1920}" \ --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ - --output-env "${ENV:=/env}" || exit 1 \ + --output-env "${ENV:=/env}" \ ; } \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ source "${ENV:=/env}" 2>/dev/null \ @@ -142,7 +142,8 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS --mac-address "${MAC_ADDRESS}" \ --width "${WIDTH:-1920}" \ --height "${HEIGHT:-1080}" \ - --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" + --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ + ; } \ ; case "$(file --brief /bootdisk)" in \ QEMU\ QCOW2\ Image* ) export BOOTDISK=/bootdisk \ ;; \ diff --git a/custom/generate-specific-bootdisk.sh b/custom/generate-specific-bootdisk.sh index f407f3d..b847a50 100755 --- a/custom/generate-specific-bootdisk.sh +++ b/custom/generate-specific-bootdisk.sh @@ -195,11 +195,11 @@ generate_bootdisk () { 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 + || { 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 + || { echo "Could not download ${MASTER_PLIST_URL}" && exit 1 ; } fi diff --git a/custom/generate-unique-machine-values.sh b/custom/generate-unique-machine-values.sh index f013898..6ab15b8 100755 --- a/custom/generate-unique-machine-values.sh +++ b/custom/generate-unique-machine-values.sh @@ -251,11 +251,11 @@ generate_serial_sets () { 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 + || { 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 + || { 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 From 2077c3a45354ed6beb753afaed49d789d94a25b6 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Thu, 4 Mar 2021 13:22:13 +0000 Subject: [PATCH 12/68] v4.1 WIDTH/HEIGHT && move resolution README note --- CHANGELOG.md | 4 +- Dockerfile | 9 ++-- Dockerfile.auto | 9 ++-- Dockerfile.naked | 9 ++-- README.md | 123 +++++++++++++++++++++++++++++++++++------------ 5 files changed, 109 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abc2d75..5fc75bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ |Version|Date|Notes| |---|---|---| -| |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.| +|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,'`| |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`.| diff --git a/Dockerfile b/Dockerfile index 61464b8..756773d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,11 +5,12 @@ # / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / | # /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| # -# Repo: https://github.com/sickcodes/Docker-OSX/ -# Title: Mac on Docker (Docker-OSX) -# Author: Sick.Codes https://sick.codes/ -# Version: 4.0 +# Title: Docker-OSX (Mac on Docker) +# Author: Sick.Codes https://twitter.com/sickcodes +# Version: 4.1 # 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 # OpenCore support go to https://github.com/Leoyzen/KVM-Opencore diff --git a/Dockerfile.auto b/Dockerfile.auto index 1e0c84e..7586eee 100644 --- a/Dockerfile.auto +++ b/Dockerfile.auto @@ -3,13 +3,14 @@ # / __ \____ _____/ /_____ _____/ __ \/ ___/ |/ / # / / / / __ \/ ___/ //_/ _ \/ ___/ / / /\__ \| / # / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / | -# /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| AUTOINSTALL +# /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| :AUTO # -# Title: Mac on Docker (Docker-OSX) [AUTOINSTALL] -# Author: Sick.Codes https://twitter.com/sickcodes -# Version: 4.0 +# Title: Docker-OSX (Mac on Docker) +# Author: Sick.Codes https://twitter.com/sickcodes +# Version: 4.1 # License: GPLv3+ # Repository: https://github.com/sickcodes/Docker-OSX +# Website: https://sick.codes # # This Dockerfile is a pre-installed naked installation of Docker-OSX! # diff --git a/Dockerfile.naked b/Dockerfile.naked index 6ac5333..b8ffb3f 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -3,13 +3,14 @@ # / __ \____ _____/ /_____ _____/ __ \/ ___/ |/ / # / / / / __ \/ ___/ //_/ _ \/ ___/ / / /\__ \| / # / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / | -# /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| NAKED/SUPPLY_YOUR_OWN +# /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| :NAKED # -# Title: Mac on Docker (Docker-OSX) [AUTOINSTALL] -# Author: Sick.Codes https://twitter.com/sickcodes -# Version: 4.0 +# Title: Docker-OSX (Mac on Docker) [AUTOINSTALL] +# Author: Sick.Codes https://twitter.com/sickcodes +# Version: 4.1 # License: GPLv3+ # Repository: https://github.com/sickcodes/Docker-OSX +# Website: https://sick.codes # # This image won't run unless you supply a disk image using: # -v ${PWD}/mac_hdd_ng.img:/image diff --git a/README.md b/README.md index 08cf699..9a2c07c 100644 --- a/README.md +++ b/README.md @@ -784,7 +784,7 @@ docker run -it \ sickcodes/docker-osx:auto ``` -# This example generates a specific set of serial numbers at runtime, with your existing image, at 1000x1000 display resolution. +### This example generates a specific set of serial numbers at runtime, with your existing image, at 1000x1000 display resolution. ```bash # run an existing image in current directory, with a screen, with SSH, with nopicker, and save the bootdisk for later. @@ -824,36 +824,6 @@ Or you can generate them inside the `./custom` folder. And then use: -e MAC_ADDRESS="" \ ``` -# Change Resolution Docker-OSX - -The display resolution is controlled by this line: - -https://github.com/sickcodes/Docker-OSX/blob/master/custom/config-nopicker-custom.plist#L819 - -However, you need to mount that disk. Boring! - -Instead, you can simply add the following to any image: - -```bash --e GENERATE_UNIQUE=true \ --e WIDTH=1920 \ --e HEIGHT=1080 \ -``` - -It will take around 1 minute longer to boot because it will make a new boot partition. - -```bash --e GENERATE_SPECIFIC=true \ --e WIDTH=1920 \ --e HEIGHT=1080 \ --e SERIAL="" \ --e BOARD_SERIAL="" \ --e UUID="" \ --e MAC_ADDRESS="" \ -``` - -Must be used with either `-e GENERATE_UNIQUE=true` or `-e GENERATE_SPECIFIC=true`. - #### Persistence from generating serial numbers is obviously ideal: ```bash @@ -950,6 +920,97 @@ generate-specific-bootdisk.sh \ --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 The simplest way to do this is the following: From b2f6ac509c78387d250a59c666eae03e2dc65ef7 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Thu, 4 Mar 2021 13:27:12 +0000 Subject: [PATCH 13/68] Typo --- Dockerfile.naked | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.naked b/Dockerfile.naked index b8ffb3f..920a51f 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -5,7 +5,7 @@ # / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / | # /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| :NAKED # -# Title: Docker-OSX (Mac on Docker) [AUTOINSTALL] +# Title: Docker-OSX (Mac on Docker) # Author: Sick.Codes https://twitter.com/sickcodes # Version: 4.1 # License: GPLv3+ From 72d942763eb7f61cbca86672650a7538e4e08b7e Mon Sep 17 00:00:00 2001 From: sickcodes Date: Sat, 6 Mar 2021 17:21:14 +0000 Subject: [PATCH 14/68] Fix help. Change envs to --envs. Auto turn on envs, plists, bootdisks if setting their output file names --- custom/generate-unique-machine-values.sh | 166 ++++++++++++----------- 1 file changed, 88 insertions(+), 78 deletions(-) diff --git a/custom/generate-unique-machine-values.sh b/custom/generate-unique-machine-values.sh index 6ab15b8..0c006ba 100755 --- a/custom/generate-unique-machine-values.sh +++ b/custom/generate-unique-machine-values.sh @@ -11,55 +11,50 @@ # Version: 3.1 # License: GPLv3+ -help_text="Usage: generate-unique-machine-values.sh +help_text="Usage: ./generate-unique-machine-values.sh 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. - --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. - --width Resolution x axis length in pixels (default 1920) - --height Resolution y axis length in pixels (default 1080 - - --master-plist-url Specify an alternative master plist, via URL. - --master-plist | --custom-plist - Optionally change the input plist. Placeholders: - {{DEVICE_MODEL}}, {{SERIAL}}, {{BOARD_SERIAL}}, - {{UUID}}, {{ROM}}, {{WIDTH}}, {{HEIGHT}} - + --csv Optionally change the CSV output filename + --tsv Optionally change the TSV output filename + --output-dir Optionally change the script output location + --width Resolution x axis length in px, default 1920 + --height Resolution y axis length in px, default 1080 + --master-plist-url Specify an alternative master plist, via URL + --master-plist Optionally change the input plist + --custom-plist Same as --master-plist + --output-bootdisk Optionally change the bootdisk filename + --envs Create all corresponding sourcable envs + --plists Create all corresponding config.plists + --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 only ONE serial set: + --output-bootdisk Optionally change the bootdisk filename + --output-env 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 + ./generate-unique-machine-values.sh --count 1 --plists --bootdisks --envs - 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'. +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/ " MACINFOPKG_VERSION=2.1.2 +OPENCORE_IMAGE_MAKER_URL='https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/custom/opencore-image-ng.sh' # gather arguments while (( "$#" )); do @@ -110,7 +105,7 @@ while (( "$#" )); do ;; --output-bootdisk=* ) - export OUTPUT_QCOW="${1#*=}" + export OUTPUT_BOOTDISK="${1#*=}" shift ;; --output-bootdisk* ) @@ -198,7 +193,11 @@ while (( "$#" )); do shift ;; --bootdisks ) - export CREATE_QCOWS=1 + export CREATE_BOOTDISKS=1 + shift + ;; + --envs ) + export CREATE_ENVS=1 shift ;; @@ -245,38 +244,19 @@ download_qcow_efi_folder () { generate_serial_sets () { - 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 - - 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 + if [[ "${CSV_OUTPUT_FILENAME}" ]]; then [[ ${CSV_OUTPUT_FILENAME} ]] && export CSV_SERIAL_SETS_FILE="${CSV_OUTPUT_FILENAME}" + elif [[ "${TSV_OUTPUT_FILENAME}" ]]; then [[ ${TSV_OUTPUT_FILENAME} ]] && export TSV_SERIAL_SETS_FILE="${TSV_OUTPUT_FILENAME}" - else - export SERIAL_SETS_FILE="${OUTPUT_DIRECTORY}/serial_sets-${DATE_NOW}.csv" + else + export CSV_SERIAL_SETS_FILE="${OUTPUT_DIRECTORY}/serial_sets-${DATE_NOW}.csv" + 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... @@ -288,30 +268,54 @@ generate_serial_sets () { 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])" + [[ -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 + cat <> "${CSV_SERIAL_SETS_FILE}" +"${DEVICE_MODEL}","${SERIAL}","${BOARD_SERIAL}","${UUID}","${MAC_ADDRESS}","${WIDTH}","${HEIGHT}" +EOF # 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 + T=$'\t' + cat <> "${TSV_SERIAL_SETS_FILE}" +${DEVICE_MODEL}${T}${SERIAL}${T}${BOARD_SERIAL}${T}${UUID}${T}${MAC_ADDRESS}${T}${WIDTH}${T}${HEIGHT} +EOF - OUTPUT_ENV_FILE="${OUTPUT_ENV:-"${OUTPUT_DIRECTORY}/envs/${SERIAL}.env.sh"}" - touch "${OUTPUT_ENV_FILE}" - cat < "${OUTPUT_ENV_FILE}" + # make envs if --envs, but also if you set the env filename it will switch on by itself + if [[ "${CREATE_ENVS}" ]] || [[ "${OUTPUT_ENV}" ]]; then + mkdir -p "${OUTPUT_DIRECTORY}/envs" + OUTPUT_ENV_FILE="${OUTPUT_ENV:-"${OUTPUT_DIRECTORY}/envs/${SERIAL}.env.sh"}" + touch "${OUTPUT_ENV_FILE}" + cat < "${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:=1920}" -export HEIGHT="${HEIGHT:=1080}" +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 AND a custom plist URL. Only use one of those options.' + 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 + mkdir -p "${OUTPUT_DIRECTORY}/plists" source "${OUTPUT_ENV_FILE}" ROM_VALUE="${MAC_ADDRESS//\:/}" @@ -326,11 +330,15 @@ EOF "${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 @@ -341,12 +349,14 @@ EOF [[ -e "${TSV_SERIAL_SETS_FILE}" ]] && \ cat <(printf "DEVICE_MODEL\tSERIAL\tBOARD_SERIAL\tUUID\tMAC_ADDRESS\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 < Date: Sat, 6 Mar 2021 17:48:15 +0000 Subject: [PATCH 15/68] Fix bootdisk not getting written to persistent file when using NOPICKER=true. NOPICKER=true is overridden by a custom plist now anyway. --- CHANGELOG.md | 1 + Dockerfile | 2 +- Dockerfile.auto | 2 +- Dockerfile.naked | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fc75bf..5e4dc56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ |Version|Date|Notes| |---|---|---| +| |2021-03-06|Change envs to require --envs. Automatically enable --envs if --output-env is used. Same for plists, bootdisks. Fix help ugliness and sanity of generate serial scripts. Fix bootdisk not getting written to persistent file when using NOPICKER=true. NOPICKER=true is overridden by a custom plist now anyway.| |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,'`| diff --git a/Dockerfile b/Dockerfile index 756773d..552f449 100644 --- a/Dockerfile +++ b/Dockerfile @@ -306,7 +306,7 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS esac \ ; [[ "${NOPICKER}" == true ]] && { \ sed -i '/^.*InstallMedia.*/d' Launch.sh \ - && export BOOTDISK=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2 \ + && export BOOTDISK="${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2}" \ ; } \ ; [[ "${GENERATE_UNIQUE}" == true ]] && { \ ./Docker-OSX/custom/generate-unique-machine-values.sh \ diff --git a/Dockerfile.auto b/Dockerfile.auto index 7586eee..4b186f4 100644 --- a/Dockerfile.auto +++ b/Dockerfile.auto @@ -149,7 +149,7 @@ CMD echo "${BOILERPLATE}" \ ; sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" 2>/dev/null || true \ ; [[ "${NOPICKER}" == true ]] && { \ sed -i '/^.*InstallMedia.*/d' Launch.sh \ - && export BOOTDISK=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2 \ + && export BOOTDISK="${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2}" \ ; } \ ; [[ "${GENERATE_UNIQUE}" == true ]] && { \ ./Docker-OSX/custom/generate-unique-machine-values.sh \ diff --git a/Dockerfile.naked b/Dockerfile.naked index 920a51f..28290a4 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -119,7 +119,7 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS ; } \ ; [[ "${NOPICKER}" == true ]] && { \ sed -i '/^.*InstallMedia.*/d' Launch.sh \ - && export BOOTDISK=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2 \ + && export BOOTDISK="${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2}" \ ; } \ ; [[ "${GENERATE_UNIQUE}" == true ]] && { \ ./Docker-OSX/custom/generate-unique-machine-values.sh \ From 7d6e5b30d872a3e8fdc65099ed691dadabc46220 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Sat, 6 Mar 2021 17:59:03 +0000 Subject: [PATCH 16/68] Remove useless case statements. Allow -e HEADLESS=true as human readable alternative to -e DISPLAY=:99. --- CHANGELOG.md | 2 +- Dockerfile | 12 ------------ Dockerfile.auto | 17 ++++------------- Dockerfile.naked | 10 +++------- 4 files changed, 8 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e4dc56..ec5dc2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ |Version|Date|Notes| |---|---|---| -| |2021-03-06|Change envs to require --envs. Automatically enable --envs if --output-env is used. Same for plists, bootdisks. Fix help ugliness and sanity of generate serial scripts. Fix bootdisk not getting written to persistent file when using NOPICKER=true. NOPICKER=true is overridden by a custom plist now anyway.| +| |2021-03-06|Change envs to require --envs. Automatically enable --envs if --output-env is used. Same for plists, bootdisks. Fix help ugliness and sanity of generate serial scripts. Fix bootdisk not getting written to persistent file when using NOPICKER=true. NOPICKER=true is overridden by a custom plist now anyway. Remove useless case statements. Allow -e HEADLESS=true as human readable alternative to -e DISPLAY=:99.| |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,'`| diff --git a/Dockerfile b/Dockerfile index 552f449..099fa61 100644 --- a/Dockerfile +++ b/Dockerfile @@ -298,12 +298,6 @@ VOLUME ["/tmp/.X11-unix"] # And the default serial numbers CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" 2>/dev/null || true \ - ; case "$(file --brief /image)" in \ - QEMU\ QCOW2\ Image* ) export IMAGE_PATH=/image \ - ;; \ - directory* ) export IMAGE_PATH=/home/arch/OSX-KVM/mac_hdd_ng.img \ - ;; \ - esac \ ; [[ "${NOPICKER}" == true ]] && { \ sed -i '/^.*InstallMedia.*/d' Launch.sh \ && export BOOTDISK="${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2}" \ @@ -332,12 +326,6 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ ; } \ - ; case "$(file --brief /bootdisk)" in \ - QEMU\ QCOW2\ Image* ) export BOOTDISK=/bootdisk \ - ;; \ - directory* ) export BOOTDISK=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2 \ - ;; \ - esac \ ; ./enable-ssh.sh && envsubst < ./Launch.sh | bash # virt-manager mode: eta son diff --git a/Dockerfile.auto b/Dockerfile.auto index 4b186f4..90bb432 100644 --- a/Dockerfile.auto +++ b/Dockerfile.auto @@ -133,6 +133,8 @@ ENV BOOTDISK=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2 ENV DISPLAY=:99 +ENV HEADLESS=false + ENV ENV=/env ENV IMAGE_PATH=/home/arch/OSX-KVM/mac_hdd_ng.img @@ -175,21 +177,10 @@ CMD echo "${BOILERPLATE}" \ --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ ; } \ - ; case "$(file --brief /bootdisk)" in \ - QEMU\ QCOW2\ Image* ) export BOOTDISK=/bootdisk \ - ;; \ - directory* ) export BOOTDISK=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2 \ - ;; \ - esac \ - ; [[ "${DISPLAY}" = ':99' ]] && { \ + ; { [[ "${DISPLAY}" = ':99' ]] || [[ "${HEADLESS}" == true ]] ; } && { \ nohup Xvfb :99 -screen 0 1920x1080x16 \ - & until [[ "$(xrandr --query 2>/dev/null)" ]]; do sleep 0.1 ; done \ + & until [[ "$(xrandr --query 2>/dev/null)" ]]; do sleep 1 ; done \ ; } \ - ; echo "Checking whether /image is a directory or a QEMU disk." \ - ; case "$(file --brief /image)" in \ - QEMU*) export IMAGE_PATH=/image;; \ - directory*) export IMAGE_PATH=/home/arch/OSX-KVM/mac_hdd_ng.img;; \ - esac \ ; stat "${IMAGE_PATH}" \ ; echo "Large image is being copied between layers, please wait a minute..." \ ; ./enable-ssh.sh \ diff --git a/Dockerfile.naked b/Dockerfile.naked index 28290a4..f002781 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -106,6 +106,8 @@ ENV BOOTDISK=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2 ENV DISPLAY=:99 +ENV HEADLESS=false + ENV ENV=/env ENV IMAGE_PATH=/image @@ -113,7 +115,7 @@ ENV IMAGE_PATH=/image ENV NOPICKER=true CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" 2>/dev/null || true \ - ; [[ "${DISPLAY}" = ':99' ]] && { \ + ; { [[ "${DISPLAY}" = ':99' ]] || [[ "${HEADLESS}" == true ]] ; } && { \ nohup Xvfb :99 -screen 0 1920x1080x16 \ & until [[ "$(xrandr --query 2>/dev/null)" ]]; do sleep 1 ; done \ ; } \ @@ -145,10 +147,4 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ ; } \ - ; case "$(file --brief /bootdisk)" in \ - QEMU\ QCOW2\ Image* ) export BOOTDISK=/bootdisk \ - ;; \ - directory* ) export BOOTDISK=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2 \ - ;; \ - esac \ ; ./enable-ssh.sh && envsubst < ./Launch.sh | bash From 7382df8fa1fbc922827981a4cfd03c03b7888fb3 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Sat, 6 Mar 2021 19:18:23 +0000 Subject: [PATCH 17/68] Fix BOOTDISK expected logic --- Dockerfile | 11 +++++------ Dockerfile.auto | 5 +++-- Dockerfile.naked | 9 +++++---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 099fa61..f5cba65 100644 --- a/Dockerfile +++ b/Dockerfile @@ -247,7 +247,7 @@ USER arch ENV USER arch -ENV BOOTDISK=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2 +ENV BOOTDISK ENV DISPLAY=:0.0 @@ -258,8 +258,6 @@ ENV IMAGE_PATH=/home/arch/OSX-KVM/mac_hdd_ng.img # ENV NETWORKING=e1000-82545em ENV NETWORKING=vmxnet3 -ENV NOPICKER=false - # Boolean for generating a bootdisk with new random serials. ENV GENERATE_UNIQUE=false @@ -300,8 +298,9 @@ VOLUME ["/tmp/.X11-unix"] CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" 2>/dev/null || true \ ; [[ "${NOPICKER}" == true ]] && { \ sed -i '/^.*InstallMedia.*/d' Launch.sh \ - && export BOOTDISK="${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2}" \ + && export BOOTDISK="${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2}" \ ; } \ + || export BOOTDISK="${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ ; [[ "${GENERATE_UNIQUE}" == true ]] && { \ ./Docker-OSX/custom/generate-unique-machine-values.sh \ --master-plist-url="${MASTER_PLIST_URL}" \ @@ -310,7 +309,7 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS --bootdisks \ --width "${WIDTH:-1920}" \ --height "${HEIGHT:-1080}" \ - --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ + --output-bootdisk "${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ --output-env "${ENV:=/env}" \ ; } \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ @@ -324,7 +323,7 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS --mac-address "${MAC_ADDRESS}" \ --width "${WIDTH:-1920}" \ --height "${HEIGHT:-1080}" \ - --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ + --output-bootdisk "${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ ; } \ ; ./enable-ssh.sh && envsubst < ./Launch.sh | bash diff --git a/Dockerfile.auto b/Dockerfile.auto index 90bb432..3ea721d 100644 --- a/Dockerfile.auto +++ b/Dockerfile.auto @@ -129,7 +129,7 @@ RUN if [[ "${COMPLETE}" ]]; then \ && wget ${WGET_OPTIONS} -O /home/arch/OSX-KVM/mac_hdd_ng.img "${IMAGE_URL}" \ ; fi -ENV BOOTDISK=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2 +ENV BOOTDISK ENV DISPLAY=:99 @@ -151,8 +151,9 @@ CMD echo "${BOILERPLATE}" \ ; sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" 2>/dev/null || true \ ; [[ "${NOPICKER}" == true ]] && { \ sed -i '/^.*InstallMedia.*/d' Launch.sh \ - && export BOOTDISK="${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2}" \ + && export BOOTDISK="${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2}" \ ; } \ + || export BOOTDISK="${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ ; [[ "${GENERATE_UNIQUE}" == true ]] && { \ ./Docker-OSX/custom/generate-unique-machine-values.sh \ --master-plist-url="${MASTER_PLIST_URL}" \ diff --git a/Dockerfile.naked b/Dockerfile.naked index f002781..f0d0075 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -102,7 +102,7 @@ RUN mkdir -p ~/.ssh \ && tee -a ~/.ssh/config <<< ' StrictHostKeyChecking no' \ && tee -a ~/.ssh/config <<< ' UserKnownHostsFile=/dev/null' -ENV BOOTDISK=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2 +ENV BOOTDISK ENV DISPLAY=:99 @@ -121,8 +121,9 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS ; } \ ; [[ "${NOPICKER}" == true ]] && { \ sed -i '/^.*InstallMedia.*/d' Launch.sh \ - && export BOOTDISK="${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2}" \ + && export BOOTDISK="${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2}" \ ; } \ + || export BOOTDISK="${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ ; [[ "${GENERATE_UNIQUE}" == true ]] && { \ ./Docker-OSX/custom/generate-unique-machine-values.sh \ --master-plist-url="${MASTER_PLIST_URL}" \ @@ -131,7 +132,7 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS --bootdisks \ --width "${WIDTH:-1920}" \ --height "${HEIGHT:-1080}" \ - --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ + --output-bootdisk "${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ --output-env "${ENV:=/env}" \ ; } \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ @@ -145,6 +146,6 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS --mac-address "${MAC_ADDRESS}" \ --width "${WIDTH:-1920}" \ --height "${HEIGHT:-1080}" \ - --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ + --output-bootdisk "${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ ; } \ ; ./enable-ssh.sh && envsubst < ./Launch.sh | bash From c2916fd48748ff15dbb8cb79cc9b5655e4d509eb Mon Sep 17 00:00:00 2001 From: sickcodes Date: Sat, 6 Mar 2021 19:25:26 +0000 Subject: [PATCH 18/68] Dockerfile syntax error. --- Dockerfile | 2 +- Dockerfile.auto | 2 +- Dockerfile.naked | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index f5cba65..72f249e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -247,7 +247,7 @@ USER arch ENV USER arch -ENV BOOTDISK +ENV BOOTDISK= ENV DISPLAY=:0.0 diff --git a/Dockerfile.auto b/Dockerfile.auto index 3ea721d..a9cb6a5 100644 --- a/Dockerfile.auto +++ b/Dockerfile.auto @@ -129,7 +129,7 @@ RUN if [[ "${COMPLETE}" ]]; then \ && wget ${WGET_OPTIONS} -O /home/arch/OSX-KVM/mac_hdd_ng.img "${IMAGE_URL}" \ ; fi -ENV BOOTDISK +ENV BOOTDISK= ENV DISPLAY=:99 diff --git a/Dockerfile.naked b/Dockerfile.naked index f0d0075..44fa0e4 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -102,7 +102,7 @@ RUN mkdir -p ~/.ssh \ && tee -a ~/.ssh/config <<< ' StrictHostKeyChecking no' \ && tee -a ~/.ssh/config <<< ' UserKnownHostsFile=/dev/null' -ENV BOOTDISK +ENV BOOTDISK= ENV DISPLAY=:99 From ab9761adb743713646c537f464514b3e0eba46de Mon Sep 17 00:00:00 2001 From: sickcodes Date: Tue, 9 Mar 2021 08:44:58 +0000 Subject: [PATCH 19/68] Add https://github.com/sickcodes/osx-serial-generator.git as a submodule to replace ./custom --- .gitmodules | 3 + README.md | 52 +- custom | 1 + custom/config-nopicker-custom.plist | 885 ----------------------- custom/generate-specific-bootdisk.sh | 254 ------- custom/generate-unique-machine-values.sh | 376 ---------- custom/opencore-image-ng.sh | 164 ----- osx-serial-generator | 1 + 8 files changed, 31 insertions(+), 1705 deletions(-) create mode 100644 .gitmodules create mode 120000 custom delete mode 100644 custom/config-nopicker-custom.plist delete mode 100755 custom/generate-specific-bootdisk.sh delete mode 100755 custom/generate-unique-machine-values.sh delete mode 100755 custom/opencore-image-ng.sh create mode 160000 osx-serial-generator diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..66e60a1 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "osx-serial-generator"] + path = osx-serial-generator + url = https://github.com/sickcodes/osx-serial-generator.git diff --git a/README.md b/README.md index 9a2c07c..6b328d5 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,32 @@ Thank you to @cephasara for this major contribution. #### Follow [@sickcodes on Twitter](https://twitter.com/sickcodes) for updates or feature requests! +# Basic Quick Start Docker-OSX + +```bash + +docker pull sickcodes/docker-osx:latest + +# Catalina +docker run -it \ + --device /dev/kvm \ + -p 50922:10022 \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e "DISPLAY=${DISPLAY:-:0.0}" \ + sickcodes/docker-osx:latest + +# Big Sur +docker run -it \ + --device /dev/kvm \ + -p 50922:10022 \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e "DISPLAY=${DISPLAY:-:0.0}" \ + sickcodes/docker-osx:big-sur + +# Wait 2-3 minutes until you see the logo. + +``` + # How to use ### There are 3 images: **latest**, **auto** and **naked**. @@ -80,32 +106,6 @@ Use `docker commit`, copy the ID, and then `docker start ID` [Pull out the .img file](https://github.com/sickcodes/Docker-OSX#backup-the-disk-wheres-my-disk), and then use that [.img file with :naked](https://github.com/sickcodes/Docker-OSX#quick-start-own-image-naked-container-image) -# Basic Quick Start Docker-OSX - -```bash - -docker pull sickcodes/docker-osx:latest - -# catalina -docker run -it \ - --device /dev/kvm \ - -p 50922:10022 \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - -e "DISPLAY=${DISPLAY:-:0.0}" \ - sickcodes/docker-osx:latest - -# big sur -docker run -it \ - --device /dev/kvm \ - -p 50922:10022 \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - -e "DISPLAY=${DISPLAY:-:0.0}" \ - sickcodes/docker-osx:big-sur - -# Wait 2-3 minutes until you see the logo. - -``` - # Quick Start Large Pre-Made Image Current large image size: 17.5GB diff --git a/custom b/custom new file mode 120000 index 0000000..07ee287 --- /dev/null +++ b/custom @@ -0,0 +1 @@ +osx-serial-generator/ \ No newline at end of file diff --git a/custom/config-nopicker-custom.plist b/custom/config-nopicker-custom.plist deleted file mode 100644 index aa60a39..0000000 --- a/custom/config-nopicker-custom.plist +++ /dev/null @@ -1,885 +0,0 @@ - - - - - - - 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}} - ROM - - {{ROM}} - - SpoofVendor - - SystemProductName - {{DEVICE_MODEL}} - SystemSerialNumber - {{SERIAL}} - SystemUUID - {{UUID}} - - 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 - {{WIDTH}}x{{HEIGHT}}@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-specific-bootdisk.sh b/custom/generate-specific-bootdisk.sh deleted file mode 100755 index b847a50..0000000 --- a/custom/generate-specific-bootdisk.sh +++ /dev/null @@ -1,254 +0,0 @@ -#!/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 - --width Resolution x axis length in pixels (default 1920) - --height Resolution y axis length in pixels (default 1080 - --output-bootdisk Optionally change the bootdisk output filename - - --master-plist-url Specify an alternative master plist, via URL. - --custom-plist | --master-plist - Optionally change the input plist. Placeholders: - {{DEVICE_MODEL}}, {{SERIAL}}, {{BOARD_SERIAL}}, - {{UUID}}, {{ROM}}, {{WIDTH}}, {{HEIGHT}} - - --help, -h, help Display this help and exit - -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 \ - --widht 1920 \ - --height 1080 - -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="${1#*=}" - shift - ;; - --serial* ) - export SERIAL="${2}" - shift - shift - ;; - - --board-serial=* ) - export BOARD_SERIAL="${1#*=}" - shift - ;; - --board-serial* ) - export BOARD_SERIAL="${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 - ;; - - --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 - ;; - - --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 - ;; - - *) - 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 () { - - 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 - - # plist required for bootdisks, so create anyway. - 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 \ - -e s/{{WIDTH}}/"${WIDTH:-1920}"/g \ - -e s/{{HEIGHT}}/"${HEIGHT:-1080}"/g \ - "${MASTER_PLIST}" > ./tmp.config.plist || exit 1 - else - cat < startup.nsh -} - - -generate_serial_sets () { - - - - if [[ "${CSV_OUTPUT_FILENAME}" ]]; then - [[ ${CSV_OUTPUT_FILENAME} ]] && export CSV_SERIAL_SETS_FILE="${CSV_OUTPUT_FILENAME}" - elif [[ "${TSV_OUTPUT_FILENAME}" ]]; then - [[ ${TSV_OUTPUT_FILENAME} ]] && export TSV_SERIAL_SETS_FILE="${TSV_OUTPUT_FILENAME}" - else - export CSV_SERIAL_SETS_FILE="${OUTPUT_DIRECTORY}/serial_sets-${DATE_NOW}.csv" - export TSV_SERIAL_SETS_FILE="${OUTPUT_DIRECTORY}/serial_sets-${DATE_NOW}.tsv" - fi - - ./macserial \ - --num "${SERIAL_SET_COUNT}" \ - --model "${DEVICE_MODEL}" \ - | while IFS='\ \|\ ' read -r SERIAL BOARD_SERIAL; do - # make a uuid... - UUID="$(uuidgen)" - UUID="${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])" - - [[ -z "${WIDTH}" ]] && WIDTH=1920 - [[ -z "${HEIGHT}" ]] && HEIGHT=1080 - - # append to csv file - cat <> "${CSV_SERIAL_SETS_FILE}" -"${DEVICE_MODEL}","${SERIAL}","${BOARD_SERIAL}","${UUID}","${MAC_ADDRESS}","${WIDTH}","${HEIGHT}" -EOF - - # append to tsv file - T=$'\t' - cat <> "${TSV_SERIAL_SETS_FILE}" -${DEVICE_MODEL}${T}${SERIAL}${T}${BOARD_SERIAL}${T}${UUID}${T}${MAC_ADDRESS}${T}${WIDTH}${T}${HEIGHT} -EOF - - # make envs if --envs, but also if you set the env filename it will switch on by itself - if [[ "${CREATE_ENVS}" ]] || [[ "${OUTPUT_ENV}" ]]; then - mkdir -p "${OUTPUT_DIRECTORY}/envs" - OUTPUT_ENV_FILE="${OUTPUT_ENV:-"${OUTPUT_DIRECTORY}/envs/${SERIAL}.env.sh"}" - touch "${OUTPUT_ENV_FILE}" - cat < "${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_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 AND a custom plist URL. Only use one of those options.' - 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 - - 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 \ - -e s/{{WIDTH}}/"${WIDTH}"/g \ - -e s/{{HEIGHT}}/"${HEIGHT}"/g \ - "${MASTER_PLIST}" > "${OUTPUT_DIRECTORY}/plists/${SERIAL}.config.plist" || exit 1 - fi - - # 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_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 "${TSV_SERIAL_SETS_FILE}" ]] && \ - cat <(printf "DEVICE_MODEL\tSERIAL\tBOARD_SERIAL\tUUID\tMAC_ADDRESS\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 </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 -} - -# 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 - -###################################################################### -# 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 diff --git a/osx-serial-generator b/osx-serial-generator new file mode 160000 index 0000000..c7cc676 --- /dev/null +++ b/osx-serial-generator @@ -0,0 +1 @@ +Subproject commit c7cc676ce11010cfe08d9a7d0e79f65536777ab4 From 38c84714eea447d92e94ca03e0cd67f39f7066f9 Mon Sep 17 00:00:00 2001 From: sickcodes <65906298+sickcodes@users.noreply.github.com> Date: Tue, 9 Mar 2021 12:13:08 +0000 Subject: [PATCH 20/68] Update issue templates --- .github/ISSUE_TEMPLATE/a.md | 24 ++++++++++++++++++++++++ .github/ISSUE_TEMPLATE/issue-template.md | 24 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/a.md create mode 100644 .github/ISSUE_TEMPLATE/issue-template.md diff --git a/.github/ISSUE_TEMPLATE/a.md b/.github/ISSUE_TEMPLATE/a.md new file mode 100644 index 0000000..7ce9fd3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/a.md @@ -0,0 +1,24 @@ +--- +name: '' +about: '' +title: '' +labels: '' +assignees: '' + +--- + +# OS related issued, please help us identify the issue by posting the output of this +uname -a \ +; echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs \ +; grep NAME /etc/os-release \ +; df -h . \ +; qemu-system-x86_64 --version \ +; libvirtd --version \ +; free -mh \ +; nproc \ +; egrep -c '(svm|vmx)' /proc/cpuinfo \ +; ls -lha /dev/kvm \ +; ls -lha /tmp/.X11-unix/ \ +; ps aux | grep dockerd \ +; docker ps | grep osx \ +; grep "docker\|kvm\|virt" /etc/group diff --git a/.github/ISSUE_TEMPLATE/issue-template.md b/.github/ISSUE_TEMPLATE/issue-template.md new file mode 100644 index 0000000..90f72e3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/issue-template.md @@ -0,0 +1,24 @@ +--- +name: Issue Template +about: A template for issues. +title: '' +labels: '' +assignees: '' + +--- + +# OS related issued, please help us identify the issue by posting the output of this +uname -a \ +; echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs \ +; grep NAME /etc/os-release \ +; df -h . \ +; qemu-system-x86_64 --version \ +; libvirtd --version \ +; free -mh \ +; nproc \ +; egrep -c '(svm|vmx)' /proc/cpuinfo \ +; ls -lha /dev/kvm \ +; ls -lha /tmp/.X11-unix/ \ +; ps aux | grep dockerd \ +; docker ps | grep osx \ +; grep "docker\|kvm\|virt" /etc/group From d6b86a604aa0e49caf4dd4fb56ece337a3372f83 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Tue, 9 Mar 2021 16:38:34 +0000 Subject: [PATCH 21/68] osx-serial-generator submodule update --- osx-serial-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osx-serial-generator b/osx-serial-generator index c7cc676..5e2d228 160000 --- a/osx-serial-generator +++ b/osx-serial-generator @@ -1 +1 @@ -Subproject commit c7cc676ce11010cfe08d9a7d0e79f65536777ab4 +Subproject commit 5e2d228b630202b36c2443a8850607013d31c071 From 5a71e1975692f153e3022a8a2c877d82e32cd6f6 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Tue, 9 Mar 2021 16:55:18 +0000 Subject: [PATCH 22/68] ./custom is now ./osx-serial-generator via submodule. Submodule inits. --- Dockerfile | 8 ++++---- Dockerfile.auto | 6 +++--- Dockerfile.naked | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 72f249e..57f81f8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -126,7 +126,7 @@ RUN tee -a sshd_config <<< 'AllowTcpForwarding yes' \ USER arch # download OSX-KVM -RUN git clone --depth 1 https://github.com/kholia/OSX-KVM.git /home/arch/OSX-KVM +RUN git clone --recurse-submodules --depth 1 https://github.com/kholia/OSX-KVM.git /home/arch/OSX-KVM # enable ssh # docker exec .... ./enable-ssh.sh @@ -201,7 +201,7 @@ RUN if [[ "${LINUX}" == true ]]; then \ # optional --build-arg to change branches for testing ARG BRANCH=master ARG REPO='https://github.com/sickcodes/Docker-OSX.git' -RUN git clone --branch "${BRANCH}" "${REPO}" +RUN git clone --recurse-submodules --depth 1 --branch "${BRANCH}" "${REPO}" # env -e ADDITIONAL_PORTS with a comma # for example, -e ADDITIONAL_PORTS=hostfwd=tcp::23-:23, @@ -302,7 +302,7 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS ; } \ || export BOOTDISK="${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ ; [[ "${GENERATE_UNIQUE}" == true ]] && { \ - ./Docker-OSX/custom/generate-unique-machine-values.sh \ + ./Docker-OSX/osx-serial-generator/generate-unique-machine-values.sh \ --master-plist-url="${MASTER_PLIST_URL}" \ --count 1 \ --tsv ./serial.tsv \ @@ -314,7 +314,7 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS ; } \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ source "${ENV:=/env}" 2>/dev/null \ - ; ./Docker-OSX/custom/generate-specific-bootdisk.sh \ + ; ./Docker-OSX/osx-serial-generator/generate-specific-bootdisk.sh \ --master-plist-url="${MASTER_PLIST_URL}" \ --model "${DEVICE_MODEL}" \ --serial "${SERIAL}" \ diff --git a/Dockerfile.auto b/Dockerfile.auto index a9cb6a5..65efef8 100644 --- a/Dockerfile.auto +++ b/Dockerfile.auto @@ -79,7 +79,7 @@ RUN patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst \ RUN pacman -Syu xorg-server-xvfb wget xterm xorg-xhost xorg-xrandr sshpass --noconfirm \ && if [[ "${SCROT}" ]]; then \ pacman -Syu scrot base-devel --noconfirm \ - && git clone https://github.com/stolk/imcat.git \ + && git clone --recurse-submodules --depth 1 https://github.com/stolk/imcat.git \ && cd imcat \ && make \ && sudo cp imcat /usr/bin/imcat \ @@ -155,7 +155,7 @@ CMD echo "${BOILERPLATE}" \ ; } \ || export BOOTDISK="${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ ; [[ "${GENERATE_UNIQUE}" == true ]] && { \ - ./Docker-OSX/custom/generate-unique-machine-values.sh \ + ./Docker-OSX/osx-serial-generator/generate-unique-machine-values.sh \ --master-plist-url="${MASTER_PLIST_URL}" \ --count 1 \ --tsv ./serial.tsv \ @@ -167,7 +167,7 @@ CMD echo "${BOILERPLATE}" \ ; } \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ source "${ENV:=/env}" 2>/dev/null \ - ; ./Docker-OSX/custom/generate-specific-bootdisk.sh \ + ; ./Docker-OSX/osx-serial-generator/generate-specific-bootdisk.sh \ --master-plist-url="${MASTER_PLIST_URL}" \ --model "${DEVICE_MODEL}" \ --serial "${SERIAL}" \ diff --git a/Dockerfile.naked b/Dockerfile.naked index 44fa0e4..bf006d7 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -68,7 +68,7 @@ ARG SCROT RUN pacman -Syu xorg-server-xvfb wget xterm xorg-xhost xorg-xrandr sshpass --noconfirm \ && if [[ "${SCROT}" ]]; then \ pacman -Syu scrot base-devel --noconfirm \ - && git clone https://github.com/stolk/imcat.git \ + && git clone --recurse-submodules --depth 1 https://github.com/stolk/imcat.git \ && cd imcat \ && make \ && sudo cp imcat /usr/bin/imcat \ @@ -125,7 +125,7 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS ; } \ || export BOOTDISK="${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ ; [[ "${GENERATE_UNIQUE}" == true ]] && { \ - ./Docker-OSX/custom/generate-unique-machine-values.sh \ + ./Docker-OSX/osx-serial-generator/generate-unique-machine-values.sh \ --master-plist-url="${MASTER_PLIST_URL}" \ --count 1 \ --tsv ./serial.tsv \ @@ -137,7 +137,7 @@ CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDIS ; } \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ source "${ENV:=/env}" 2>/dev/null \ - ; ./Docker-OSX/custom/generate-specific-bootdisk.sh \ + ; ./Docker-OSX/osx-serial-generator/generate-specific-bootdisk.sh \ --master-plist-url="${MASTER_PLIST_URL}" \ --model "${DEVICE_MODEL}" \ --serial "${SERIAL}" \ From 0bce4b044f26988d3f80747b649c67cf39f329eb Mon Sep 17 00:00:00 2001 From: sickcodes Date: Tue, 9 Mar 2021 17:52:21 +0000 Subject: [PATCH 23/68] osx-serial-generator submodule update --- osx-serial-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osx-serial-generator b/osx-serial-generator index 5e2d228..0149015 160000 --- a/osx-serial-generator +++ b/osx-serial-generator @@ -1 +1 @@ -Subproject commit 5e2d228b630202b36c2443a8850607013d31c071 +Subproject commit 0149015547a26b991fc6035972dae75357dc68aa From 9fffacde9abd5f377a7b150517372c0b67d6516e Mon Sep 17 00:00:00 2001 From: sickcodes Date: Tue, 9 Mar 2021 19:29:38 +0000 Subject: [PATCH 24/68] Incorrect link update --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 57f81f8..a795f3f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -272,7 +272,7 @@ ENV NOPICKER=false ENV WIDTH=1920 ENV HEIGHT=1080 -ENV MASTER_PLIST_URL="https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/custom/config-nopicker-custom.plist" +ENV MASTER_PLIST_URL="https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-nopicker-custom.plist" VOLUME ["/tmp/.X11-unix"] From 8cd84276a3d84a6747549505b5cbfde0c718ac3d Mon Sep 17 00:00:00 2001 From: sickcodes Date: Tue, 9 Mar 2021 20:00:40 +0000 Subject: [PATCH 25/68] Add temporary folder for hardlinks ./custom --- custom | 1 - custom/README.md | 8 + custom/config-nopicker-custom.plist | 884 +++++++++++++++++++++++ custom/generate-specific-bootdisk.sh | 285 ++++++++ custom/generate-unique-machine-values.sh | 391 ++++++++++ custom/opencore-image-ng.sh | 164 +++++ 6 files changed, 1732 insertions(+), 1 deletion(-) delete mode 120000 custom create mode 100644 custom/README.md create mode 100644 custom/config-nopicker-custom.plist create mode 100755 custom/generate-specific-bootdisk.sh create mode 100755 custom/generate-unique-machine-values.sh create mode 100755 custom/opencore-image-ng.sh diff --git a/custom b/custom deleted file mode 120000 index 07ee287..0000000 --- a/custom +++ /dev/null @@ -1 +0,0 @@ -osx-serial-generator/ \ No newline at end of file diff --git a/custom/README.md b/custom/README.md new file mode 100644 index 0000000..7014c1d --- /dev/null +++ b/custom/README.md @@ -0,0 +1,8 @@ +# 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 new file mode 100644 index 0000000..6602df5 --- /dev/null +++ b/custom/config-nopicker-custom.plist @@ -0,0 +1,884 @@ + + + + + + + + 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}} + ROM + {{ROM}} + SpoofVendor + + SystemProductName + {{DEVICE_MODEL}} + SystemSerialNumber + {{SERIAL}} + SystemUUID + {{UUID}} + + 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 + {{WIDTH}}x{{HEIGHT}}@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-specific-bootdisk.sh b/custom/generate-specific-bootdisk.sh new file mode 100755 index 0000000..89ecad7 --- /dev/null +++ b/custom/generate-specific-bootdisk.sh @@ -0,0 +1,285 @@ +#!/bin/bash +# ___ _____ __ ___ _ _ ___ _ +# / _ \/ __\ \/ / / __| ___ _ _(_)__ _| | / __|___ _ _ ___ _ _ __ _| |_ ___ _ _ +# | (_) \__ \> < \__ \/ -_) '_| / _` | | | (_ / -_) ' \/ -_) '_/ _` | _/ _ \ '_| +# \___/|___/_/\_\ |___/\___|_| |_\__,_|_| \___\___|_||_\___|_| \__,_|\__\___/_| +# +# Repo: https://github.com/sickcodes/osx-serial-generator/ +# Title: OSX Serial Generator +# Author: Sick.Codes https://sick.codes/ +# Version: 3.1 +# License: GPLv3+ + +set -e + +help_text="Usage: ./generate-specific-bootdisk.sh + +Required options: + --model Device model, e.g. 'iMacPro1,1' + --serial Device Serial number + --board-serial Main Logic Board Serial number (MLB) + --uuid SMBIOS UUID (SmUUID) + --mac-address Used for both the MAC address and to set ROM + ROM is lowercased sans any colons +Optional options: + --width Resolution x axis length in px, default 1920 + --height Resolution y axis length in px, default 1080 + --input-plist-url Specify an alternative master plist, via URL + --master-plist-url Same as above. + --custom-plist Optionally change the input plist. + --master-plist Same as above. + --output-bootdisk Optionally change the bootdisk filename + --output-plist 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 \\ + --width 1920 \\ + --height 1080 + +Author: Sick.Codes https://sick.codes/ +Project: https://github.com/sickcodes/osx-serial-generator/ +License: GPLv3+ +" + +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 + 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="${1#*=}" + shift + ;; + + --serial* ) + export SERIAL="${2}" + shift + shift + ;; + + --board-serial=* ) + export BOARD_SERIAL="${1#*=}" + shift + ;; + + --board-serial* ) + export BOARD_SERIAL="${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 + ;; + + --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 + ;; + + --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 + ;; + + --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 ${1}. Running with default values..." + shift + ;; + esac +done + + +download_qcow_efi_folder () { + + 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 -ra "${EFI_FOLDER}" . + + mkdir -p ./EFI/OC/Resources + + # copy Apple drivers into EFI/OC/Resources + cp -a "${RESOURCES_FOLDER}"/* ./EFI/OC/Resources +} + +generate_bootdisk () { + + # 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 + 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 \ + -e s/\{\{WIDTH\}\}/"${WIDTH:-1920}"/g \ + -e s/\{\{HEIGHT\}\}/"${HEIGHT:-1080}"/g \ + "${MASTER_PLIST}" > ./tmp.config.plist || exit 1 + else + cat < < \__ \/ -_) '_| / _` | | | (_ / -_) ' \/ -_) '_/ _` | _/ _ \ '_| +# \___/|___/_/\_\ |___/\___|_| |_\__,_|_| \___\___|_||_\___|_| \__,_|\__\___/_| +# +# Repo: https://github.com/sickcodes/osx-serial-generator/ +# Title: OSX Serial Generator +# Author: Sick.Codes https://sick.codes/ +# Version: 3.1 +# License: GPLv3+ + +set -e + +help_text="Usage: ./generate-unique-machine-values.sh + +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 + --tsv Optionally change the TSV output filename + --output-dir Optionally change the script output location + --width Resolution x axis length in px, default 1920 + --height Resolution y axis length in px, default 1080 + --input-plist-url Specify an alternative master plist, via URL + --master-plist-url Same as above. + --custom-plist Optionally change the input plist. + --master-plist Same as above. + --output-bootdisk 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 + +Additional options only if you are creating ONE serial set: + --output-bootdisk Optionally change the bootdisk filename + --output-env 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 --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/osx-serial-generator/ +License: GPLv3+ +" + +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 + 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 + ;; + + --tsv=* ) + export TSV_OUTPUT_FILENAME="${1#*=}" + shift + ;; + + --tsv* ) + export TSV_OUTPUT_FILENAME="${2}" + shift + shift + ;; + + --output-dir=* ) + export OUTPUT_DIRECTORY="${1#*=}" + shift + ;; + + --output-dir* ) + export OUTPUT_DIRECTORY="${2}" + shift + shift + ;; + + --output-bootdisk=* ) + export OUTPUT_BOOTDISK="${1#*=}" + shift + ;; + + --output-bootdisk* ) + export OUTPUT_BOOTDISK="${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 + ;; + + --model* | -m* ) + export DEVICE_MODEL="${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 + ;; + + --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 + ;; + + --create-bootdisks | --bootdisks ) + export CREATE_BOOTDISKS=1 + shift + ;; + + --create-envs | --envs ) + export CREATE_ENVS=1 + shift + ;; + + *) + echo "Invalid option. Running with default values..." + shift + ;; + esac +done + + +build_mac_serial () { + [ -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 +} + +download_qcow_efi_folder () { + + 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 -ra "${EFI_FOLDER}" . + + mkdir -p ./EFI/OC/Resources + + # copy Apple drivers into EFI/OC/Resources + cp -a "${RESOURCES_FOLDER}"/* ./EFI/OC/Resources +} + + +generate_serial_sets () { + + + + if [ "${CSV_OUTPUT_FILENAME}" ]; then + [ "${CSV_OUTPUT_FILENAME}" ] && export CSV_SERIAL_SETS_FILE="${CSV_OUTPUT_FILENAME}" + else + 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 + + + ./macserial \ + --num "${SERIAL_SET_COUNT}" \ + --model "${DEVICE_MODEL}" \ + | while IFS='\ \|\ ' read -r SERIAL BOARD_SERIAL; do + # make a uuid... + UUID="$(uuidgen)" + UUID="${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])" + + [ -z "${WIDTH}" ] && WIDTH=1920 + [ -z "${HEIGHT}" ] && HEIGHT=1080 + + # append to csv file + cat <> "${CSV_SERIAL_SETS_FILE}" +"${DEVICE_MODEL}","${SERIAL}","${BOARD_SERIAL}","${UUID}","${MAC_ADDRESS}","${WIDTH}","${HEIGHT}" +EOF + echo "Wrote CSV to: ${CSV_SERIAL_SETS_FILE}" + + # append to tsv file + T=$'\t' + cat <> "${TSV_SERIAL_SETS_FILE}" +${DEVICE_MODEL}${T}${SERIAL}${T}${BOARD_SERIAL}${T}${UUID}${T}${MAC_ADDRESS}${T}${WIDTH}${T}${HEIGHT} +EOF + echo "Wrote CSV 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 < "${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_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 \ + -e s/\{\{WIDTH\}\}/"${WIDTH}"/g \ + -e s/\{\{HEIGHT\}\}/"${HEIGHT}"/g \ + "${MASTER_PLIST}" > "${OUTPUT_DIRECTORY}/plists/${SERIAL}.config.plist" || exit 1 + fi + + # 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_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,WIDTH,HEIGHT") "${CSV_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 </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 +} + +# disabled by @sickcodes 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 + +###################################################################### +# 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 From e4c0b642004c0d47e4fe28749e851a27815809ba Mon Sep 17 00:00:00 2001 From: sickcodes Date: Tue, 9 Mar 2021 20:34:09 +0000 Subject: [PATCH 26/68] FIRST: sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" --- Dockerfile | 3 ++- Dockerfile.auto | 3 ++- Dockerfile.naked | 3 ++- custom/README.md | 1 - 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index a795f3f..e078fb0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -295,7 +295,8 @@ VOLUME ["/tmp/.X11-unix"] # the default serial numbers are already contained in ./OpenCore-Catalina/OpenCore.qcow2 # And the default serial numbers -CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" 2>/dev/null || true \ +CMD sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true \ + ; sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true \ ; [[ "${NOPICKER}" == true ]] && { \ sed -i '/^.*InstallMedia.*/d' Launch.sh \ && export BOOTDISK="${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2}" \ diff --git a/Dockerfile.auto b/Dockerfile.auto index 65efef8..c5d199f 100644 --- a/Dockerfile.auto +++ b/Dockerfile.auto @@ -148,7 +148,8 @@ ENV BOILERPLATE="By using this Dockerfile, you hereby agree that you are a secur CMD echo "${BOILERPLATE}" \ ; [[ "${TERMS_OF_USE}" = i_agree ]] || exit 1 \ ; echo "Disk is being copied between layers... Please wait a minute..." \ - ; sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" 2>/dev/null || true \ + ; sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true \ + ; sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true \ ; [[ "${NOPICKER}" == true ]] && { \ sed -i '/^.*InstallMedia.*/d' Launch.sh \ && export BOOTDISK="${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2}" \ diff --git a/Dockerfile.naked b/Dockerfile.naked index bf006d7..3df45d2 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -114,7 +114,8 @@ ENV IMAGE_PATH=/image ENV NOPICKER=true -CMD sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" 2>/dev/null || true \ +CMD sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true \ + ; sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true \ ; { [[ "${DISPLAY}" = ':99' ]] || [[ "${HEADLESS}" == true ]] ; } && { \ nohup Xvfb :99 -screen 0 1920x1080x16 \ & until [[ "$(xrandr --query 2>/dev/null)" ]]; do sleep 1 ; done \ diff --git a/custom/README.md b/custom/README.md index 7014c1d..92bb97d 100644 --- a/custom/README.md +++ b/custom/README.md @@ -2,7 +2,6 @@ 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 From 1d52a5a106ef5699a27009dd802fb900809c5fec Mon Sep 17 00:00:00 2001 From: sickcodes Date: Tue, 9 Mar 2021 22:06:35 +0000 Subject: [PATCH 27/68] Fix redundant documentation --- README.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6b328d5..b62365f 100644 --- a/README.md +++ b/README.md @@ -787,12 +787,12 @@ docker run -it \ ### This example generates a specific set of serial numbers at runtime, with your existing image, at 1000x1000 display resolution. ```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. stat mac_hdd_ng.img # make sure you have an image if you're using :naked -touch ./mynewbootdisk.qcow docker run -it \ + -v "${PWD}/mac_hdd_ng.img:/image" \ --device /dev/kvm \ -e "DISPLAY=${DISPLAY:-:0.0}" \ -v /tmp/.X11-unix:/tmp/.X11-unix \ @@ -806,9 +806,6 @@ docker run -it \ -e MAC_ADDRESS="A8:5C:2C:9A:46:2F" \ -e WIDTH=1000 \ -e HEIGHT=1000 \ - -e BOOTDISK=/bootdisk \ - -v "${PWD}/mynewbootdisk.qcow:/bootdisk" \ - -v "${PWD}/mac_hdd_ng.img:/image" \ sickcodes/docker-osx:naked ``` @@ -829,10 +826,9 @@ Or you can generate them inside the `./custom` folder. And then use: ```bash stat mac_hdd_ng_testing.img -touch ./output.qcow touch ./output.env -# generate fresh random serial numbers, with a screen, using my own image, and save the bootdisk AND env file with my new serial numbers for later. +# generate fresh random serial numbers, with a screen, using your own image, and save env file with your new serial numbers for later. docker run -it \ --device /dev/kvm \ @@ -843,8 +839,6 @@ docker run -it \ -e GENERATE_UNIQUE=true \ -e GENERATE_SPECIFIC=true \ -e DEVICE_MODEL="iMacPro1,1" \ - -e BOOTDISK=/bootdisk \ - -v "${PWD}/output.qcow:/bootdisk" \ -v "${PWD}/output.env:/env" \ -v "${PWD}/mac_hdd_ng_testing.img:/image" \ sickcodes/docker-osx:naked From b57d94c2e1b91e7a8225eab65ad70f277a270c2b Mon Sep 17 00:00:00 2001 From: sickcodes <65906298+sickcodes@users.noreply.github.com> Date: Wed, 10 Mar 2021 22:23:31 +0000 Subject: [PATCH 28/68] Update issue-template.md --- .github/ISSUE_TEMPLATE/issue-template.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ISSUE_TEMPLATE/issue-template.md b/.github/ISSUE_TEMPLATE/issue-template.md index 90f72e3..695733e 100644 --- a/.github/ISSUE_TEMPLATE/issue-template.md +++ b/.github/ISSUE_TEMPLATE/issue-template.md @@ -9,6 +9,7 @@ assignees: '' # OS related issued, please help us identify the issue by posting the output of this uname -a \ +; echo "${DISPLAY}" \ ; echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs \ ; grep NAME /etc/os-release \ ; df -h . \ From 2295eef68fb180d9021bb50b8244cdead3c1531d Mon Sep 17 00:00:00 2001 From: sickcodes Date: Fri, 12 Mar 2021 17:58:33 +0000 Subject: [PATCH 29/68] How to mount additional disks inside OSX --- README.md | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b62365f..43cc9c1 100644 --- a/README.md +++ b/README.md @@ -85,17 +85,17 @@ Create your personal image using `:latest`. And then pull your image out. And th `sickcodes/docker-osx:naked` - [I need iMessage/iCloud for security research.](https://github.com/sickcodes/Docker-OSX#serial-numbers) #### I need a screen. -**KEEP** these two lines are in your command. Works in ANY of the machines: +**KEEP** these two lines are in your command. Works in `auto` & `naked` machines: ```dockerfile -v /tmp/.X11-unix:/tmp/.X11-unix \ -e "DISPLAY=${DISPLAY:-:0.0}" \ ``` #### I need headless. -**REMOVE** these two lines from ANY of the machines: +**REMOVE** these two lines from `auto` or `naked` machines: ```dockerfile - -v /tmp/.X11-unix:/tmp/.X11-unix \ - -e "DISPLAY=${DISPLAY:-:0.0}" \ + # -v /tmp/.X11-unix:/tmp/.X11-unix \ + # -e "DISPLAY=${DISPLAY:-:0.0}" \ ``` #### I have used it already, and want to copy this image. @@ -768,7 +768,6 @@ docker run --rm -it \ ```bash # 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! -touch ./C02TW0WAHX87.qcow docker run -it \ --device /dev/kvm \ @@ -1005,6 +1004,39 @@ Here's a few other resolutions! If you resolution is invalid, it will default to -e HEIGHT=1600 \ ``` +# Mount a disk inside OSX from the host + +Pass the disk into the container as a volume and then pass the disk again into QEMU command line extras with. + +Use the `config-custom.plist` because you probably want to see the boot menu, otherwise omit the first line: + +```bash +DISK_TWO="${PWD}/mount_me.img" +``` +```dockerfile +-e MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist' \ +-v "${DISK_TWO}:/disktwo" \ +-e EXTRA='-device ide-hd,bus=sata.5,drive=DISK-TWO -drive id=DISK-TWO,if=none,file=/disktwo,format=qcow2' \ +``` + +Example: + +```bash +OSX_IMAGE="${PWD}/mac_hdd_ng_xcode_bigsur.img" +DISK_TWO="${PWD}/mount_me.img" + +docker run -it \ + --device /dev/kvm \ + -e "DISPLAY=${DISPLAY:-:0.0}" \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist' \ + -v "${OSX_IMAGE}":/image \ + -v "${DISK_TWO}":/disktwo \ + -e EXTRA='-device ide-hd,bus=sata.5,drive=DISK-TWO -drive id=DISK-TWO,if=none,file=/disktwo,format=qcow2' \ + sickcodes/docker-osx:naked +``` + + # Allow USB passthrough The simplest way to do this is the following: From 5fc2b8b26307a81e66e9aae957315c18685f2fa7 Mon Sep 17 00:00:00 2001 From: sickcodes <65906298+sickcodes@users.noreply.github.com> Date: Sun, 14 Mar 2021 09:55:22 +0000 Subject: [PATCH 30/68] Update issue templates --- .../{a.md => issue-running-docker-osx.md} | 6 ++++-- .github/ISSUE_TEMPLATE/open-an-issue.md | 10 ++++++++++ .github/ISSUE_TEMPLATE/other-issues.md | 10 ++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) rename .github/ISSUE_TEMPLATE/{a.md => issue-running-docker-osx.md} (77%) create mode 100644 .github/ISSUE_TEMPLATE/open-an-issue.md create mode 100644 .github/ISSUE_TEMPLATE/other-issues.md diff --git a/.github/ISSUE_TEMPLATE/a.md b/.github/ISSUE_TEMPLATE/issue-running-docker-osx.md similarity index 77% rename from .github/ISSUE_TEMPLATE/a.md rename to .github/ISSUE_TEMPLATE/issue-running-docker-osx.md index 7ce9fd3..1d266c3 100644 --- a/.github/ISSUE_TEMPLATE/a.md +++ b/.github/ISSUE_TEMPLATE/issue-running-docker-osx.md @@ -1,6 +1,7 @@ --- -name: '' -about: '' +name: Issue Running Docker-OSX +about: OS related issued, please help us identify the issue by posting the output + of this title: '' labels: '' assignees: '' @@ -9,6 +10,7 @@ assignees: '' # OS related issued, please help us identify the issue by posting the output of this uname -a \ +; echo "${DISPLAY}" \ ; echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs \ ; grep NAME /etc/os-release \ ; df -h . \ diff --git a/.github/ISSUE_TEMPLATE/open-an-issue.md b/.github/ISSUE_TEMPLATE/open-an-issue.md new file mode 100644 index 0000000..a6a1892 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/open-an-issue.md @@ -0,0 +1,10 @@ +--- +name: Open an Issue +about: About anything! +title: '' +labels: '' +assignees: '' + +--- + + diff --git a/.github/ISSUE_TEMPLATE/other-issues.md b/.github/ISSUE_TEMPLATE/other-issues.md new file mode 100644 index 0000000..952b94a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/other-issues.md @@ -0,0 +1,10 @@ +--- +name: Other Issues +about: Open an Issue +title: '' +labels: '' +assignees: '' + +--- + + From 5657d4230a9277b4f26406b9e6564893d1ebbeca Mon Sep 17 00:00:00 2001 From: sickcodes Date: Sun, 14 Mar 2021 09:59:30 +0000 Subject: [PATCH 31/68] Update issue templates --- .github/ISSUE_TEMPLATE/issue-template.md | 25 ------------------------ .github/ISSUE_TEMPLATE/other-issues.md | 10 ---------- 2 files changed, 35 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/issue-template.md delete mode 100644 .github/ISSUE_TEMPLATE/other-issues.md diff --git a/.github/ISSUE_TEMPLATE/issue-template.md b/.github/ISSUE_TEMPLATE/issue-template.md deleted file mode 100644 index 695733e..0000000 --- a/.github/ISSUE_TEMPLATE/issue-template.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -name: Issue Template -about: A template for issues. -title: '' -labels: '' -assignees: '' - ---- - -# OS related issued, please help us identify the issue by posting the output of this -uname -a \ -; echo "${DISPLAY}" \ -; echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs \ -; grep NAME /etc/os-release \ -; df -h . \ -; qemu-system-x86_64 --version \ -; libvirtd --version \ -; free -mh \ -; nproc \ -; egrep -c '(svm|vmx)' /proc/cpuinfo \ -; ls -lha /dev/kvm \ -; ls -lha /tmp/.X11-unix/ \ -; ps aux | grep dockerd \ -; docker ps | grep osx \ -; grep "docker\|kvm\|virt" /etc/group diff --git a/.github/ISSUE_TEMPLATE/other-issues.md b/.github/ISSUE_TEMPLATE/other-issues.md deleted file mode 100644 index 952b94a..0000000 --- a/.github/ISSUE_TEMPLATE/other-issues.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -name: Other Issues -about: Open an Issue -title: '' -labels: '' -assignees: '' - ---- - - From 502457528a91bbe1f872eb6de5ab59c53d9d9183 Mon Sep 17 00:00:00 2001 From: sickcodes <65906298+sickcodes@users.noreply.github.com> Date: Sun, 14 Mar 2021 12:10:14 +0000 Subject: [PATCH 32/68] Propose RAM default to 2G instead of 8G Alternative, calc at runtime? Perhaps ``` -e RAM=auto \ ``` ``` RAM=${RAM:-$(("$(head -n1 /proc/meminfo | tr -dc '[:digit:]') / 900000"))}000 \ exec qemu-system-x86_64 -m ${RAM} \ ``` --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e078fb0..7f0f242 100644 --- a/Dockerfile +++ b/Dockerfile @@ -213,7 +213,7 @@ RUN touch Launch.sh \ && tee -a Launch.sh <<< 'set -eu' \ && tee -a Launch.sh <<< 'sudo chown $(id -u):$(id -g) /dev/kvm 2>/dev/null || true' \ && tee -a Launch.sh <<< 'sudo chown -R $(id -u):$(id -g) /dev/snd 2>/dev/null || true' \ - && tee -a Launch.sh <<< 'exec qemu-system-x86_64 -m ${RAM:-8}000 \' \ + && tee -a Launch.sh <<< 'exec qemu-system-x86_64 -m ${RAM:-2}000 \' \ && tee -a Launch.sh <<< '-cpu Penryn,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+pcid,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check \' \ && tee -a Launch.sh <<< '-machine q35,accel=kvm:tcg \' \ && tee -a Launch.sh <<< '-smp ${CPU_STRING:-${SMP:-4},cores=${CORES:-4}} \' \ From 79a2c102877aa89655086b067a685df1f2dfb131 Mon Sep 17 00:00:00 2001 From: TheHackerCoding <29006605+TheHackerCoding@users.noreply.github.com> Date: Mon, 15 Mar 2021 07:39:17 -0400 Subject: [PATCH 33/68] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 43cc9c1..2d5344f 100644 --- a/README.md +++ b/README.md @@ -857,7 +857,7 @@ _`ROM` is just the lowercased mac address, without `:` between each word._ You can tell the container to generate them for you using `-e GENERATE_UNIQUE=true` -Or tell the container to use specific ones using `-e GENERATE_UNIQUE=true` +Or tell the container to use specific ones using `-e GENERATE_SPECIFIC=true` ```bash -e GENERATE_SPECIFIC=true \ From 413b09df93ef25c4f2a1e82fa60e9dc49dc7afbe Mon Sep 17 00:00:00 2001 From: sickcodes Date: Wed, 17 Mar 2021 20:27:39 +0000 Subject: [PATCH 34/68] Use RAM=max or RAM=half to suit all machines, dynamically. --- CHANGELOG.md | 1 + Dockerfile | 9 ++++++++- README.md | 6 ++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec5dc2f..440d321 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ |Version|Date|Notes| |---|---|---| +| |2021-03-17|Add RAM=max and RAM=half to dynamically select ram at runtime (DEFAULT).| | |2021-03-06|Change envs to require --envs. Automatically enable --envs if --output-env is used. Same for plists, bootdisks. Fix help ugliness and sanity of generate serial scripts. Fix bootdisk not getting written to persistent file when using NOPICKER=true. NOPICKER=true is overridden by a custom plist now anyway. Remove useless case statements. Allow -e HEADLESS=true as human readable alternative to -e DISPLAY=:99.| |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.| diff --git a/Dockerfile b/Dockerfile index 7f0f242..5be3862 100644 --- a/Dockerfile +++ b/Dockerfile @@ -207,13 +207,20 @@ RUN git clone --recurse-submodules --depth 1 --branch "${BRANCH}" "${REPO}" # for example, -e ADDITIONAL_PORTS=hostfwd=tcp::23-:23, ENV ADDITIONAL_PORTS= +# dynamic RAM options for runtime +ENV RAM=max +# ENV RAM=half + RUN touch Launch.sh \ && chmod +x ./Launch.sh \ && tee -a Launch.sh <<< '#!/bin/sh' \ && tee -a Launch.sh <<< 'set -eu' \ && tee -a Launch.sh <<< 'sudo chown $(id -u):$(id -g) /dev/kvm 2>/dev/null || true' \ && tee -a Launch.sh <<< 'sudo chown -R $(id -u):$(id -g) /dev/snd 2>/dev/null || true' \ - && tee -a Launch.sh <<< 'exec qemu-system-x86_64 -m ${RAM:-2}000 \' \ + && tee -a Launch.sh <<< '[[ "${RAM}" = max ]] && export RAM="$(("$(head -n1 /proc/meminfo | tr -dc "[:digit:]") / 900000"))"' \ + && tee -a Launch.sh <<< '[[ "${RAM}" = half ]] && export RAM="$(("$(head -n1 /proc/meminfo | tr -dc "[:digit:]") / 2000000"))"' \ + && tee -a Launch.sh <<< 'sudo chown -R $(id -u):$(id -g) /dev/snd 2>/dev/null || true' \ + && tee -a Launch.sh <<< 'exec qemu-system-x86_64 -m ${RAM:2-}000 \' \ && tee -a Launch.sh <<< '-cpu Penryn,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+pcid,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check \' \ && tee -a Launch.sh <<< '-machine q35,accel=kvm:tcg \' \ && tee -a Launch.sh <<< '-smp ${CPU_STRING:-${SMP:-4},cores=${CORES:-4}} \' \ diff --git a/README.md b/README.md index 2d5344f..d7746c5 100644 --- a/README.md +++ b/README.md @@ -182,9 +182,12 @@ docker start -i containerid This is my favourite container. You can supply an existing disk image as a docker command line argument. +Pull images out using `sudo find /var/lib/docker -size +10G | grep mac_hdd_ng.img` + Supply your own local image with `-v "${PWD}/mac_hdd_ng.img:/image"` and use `sickcodes/docker-osx:naked` -- Naked image is for booting any existing .img file. +- Naked image is for booting any existing .img file, e.g in the current working directory (`$PWD`) + - By default, this image has a variable called `NOPICKER` which is `"true"`. This skips the disk selection menu. Use `-e NOPICKER=false` or any other string than the word `true` to enter the boot menu. This lets you use other disks instead of skipping the boot menu, e.g. recovery disk or disk utility. ```bash @@ -298,7 +301,6 @@ docker run -it \ docker run -it \ --device /dev/kvm \ --device /dev/snd \ - -e RAM=4 \ -p 50922:10022 \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -e "DISPLAY=${DISPLAY:-:0.0}" \ From 57e8d0c06dfcbe4ab2b08ea9f2e626a46dcc11e2 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Wed, 17 Mar 2021 20:58:11 +0000 Subject: [PATCH 35/68] Typo: Use RAM=max or RAM=half to suit all machines, dynamically. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5be3862..d6e4370 100644 --- a/Dockerfile +++ b/Dockerfile @@ -220,7 +220,7 @@ RUN touch Launch.sh \ && tee -a Launch.sh <<< '[[ "${RAM}" = max ]] && export RAM="$(("$(head -n1 /proc/meminfo | tr -dc "[:digit:]") / 900000"))"' \ && tee -a Launch.sh <<< '[[ "${RAM}" = half ]] && export RAM="$(("$(head -n1 /proc/meminfo | tr -dc "[:digit:]") / 2000000"))"' \ && tee -a Launch.sh <<< 'sudo chown -R $(id -u):$(id -g) /dev/snd 2>/dev/null || true' \ - && tee -a Launch.sh <<< 'exec qemu-system-x86_64 -m ${RAM:2-}000 \' \ + && tee -a Launch.sh <<< 'exec qemu-system-x86_64 -m ${RAM:-2}000 \' \ && tee -a Launch.sh <<< '-cpu Penryn,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+pcid,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check \' \ && tee -a Launch.sh <<< '-machine q35,accel=kvm:tcg \' \ && tee -a Launch.sh <<< '-smp ${CPU_STRING:-${SMP:-4},cores=${CORES:-4}} \' \ From d4b8a0f2be50c06ab3dffed0bba35da948df4ceb Mon Sep 17 00:00:00 2001 From: sickcodes Date: Wed, 17 Mar 2021 21:20:31 +0000 Subject: [PATCH 36/68] Fix RAM math error for -e RAM=max --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d6e4370..0ab8338 100644 --- a/Dockerfile +++ b/Dockerfile @@ -217,7 +217,7 @@ RUN touch Launch.sh \ && tee -a Launch.sh <<< 'set -eu' \ && tee -a Launch.sh <<< 'sudo chown $(id -u):$(id -g) /dev/kvm 2>/dev/null || true' \ && tee -a Launch.sh <<< 'sudo chown -R $(id -u):$(id -g) /dev/snd 2>/dev/null || true' \ - && tee -a Launch.sh <<< '[[ "${RAM}" = max ]] && export RAM="$(("$(head -n1 /proc/meminfo | tr -dc "[:digit:]") / 900000"))"' \ + && tee -a Launch.sh <<< '[[ "${RAM}" = max ]] && export RAM="$(("$(head -n1 /proc/meminfo | tr -dc "[:digit:]") / 1000000"))"' \ && tee -a Launch.sh <<< '[[ "${RAM}" = half ]] && export RAM="$(("$(head -n1 /proc/meminfo | tr -dc "[:digit:]") / 2000000"))"' \ && tee -a Launch.sh <<< 'sudo chown -R $(id -u):$(id -g) /dev/snd 2>/dev/null || true' \ && tee -a Launch.sh <<< 'exec qemu-system-x86_64 -m ${RAM:-2}000 \' \ From f6e0bfa202b4cc7d8cea50bb98b0655125a3a0cb Mon Sep 17 00:00:00 2001 From: sickcodes <65906298+sickcodes@users.noreply.github.com> Date: Fri, 19 Mar 2021 19:34:05 +0000 Subject: [PATCH 37/68] Default RAM=3 Fixes https://github.com/sickcodes/Docker-OSX/issues/207 --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0ab8338..cc75ddd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -208,7 +208,8 @@ RUN git clone --recurse-submodules --depth 1 --branch "${BRANCH}" "${REPO}" ENV ADDITIONAL_PORTS= # dynamic RAM options for runtime -ENV RAM=max +ENV RAM=3 +# ENV RAM=max # ENV RAM=half RUN touch Launch.sh \ From a494e3e56438cbc2d0602c0d7f35394e85372c60 Mon Sep 17 00:00:00 2001 From: Panagiotis Vasilopoulos Date: Fri, 19 Mar 2021 10:25:27 +0200 Subject: [PATCH 38/68] Improved README --- README.md | 179 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 94 insertions(+), 85 deletions(-) diff --git a/README.md b/README.md index d7746c5..e2108aa 100644 --- a/README.md +++ b/README.md @@ -1,52 +1,72 @@ -# Docker-OSX -## [Follow @sickcodes on Twitter](https://twitter.com/sickcodes) +# Docker-OSX · [Follow @sickcodes on Twitter](https://twitter.com/sickcodes) -![Running mac osx in a docker container](/running-mac-inside-docker-qemu.png?raw=true "OSX KVM DOCKER") +![Running Mac OS X in a Docker container](/running-mac-inside-docker-qemu.png?raw=true "OSX KVM DOCKER") -Run Mac in a Docker container! Run near native OSX-KVM in Docker! X11 Forwarding! iMessage security research! +Run Mac OS X in Docker with near-native performance! X11 Forwarding! iMessage security research! -Author: Sick.Codes https://sick.codes/ & https://twitter.com/sickcodes +## Author -Documentation: everything is on this page! +This project is maintained by [Sick.Codes](https://sick.codes/) [(Twitter)](https://twitter.com/sickcodes) -### PR & Contributor Credits +Additional credits can be found here: https://github.com/sickcodes/Docker-OSX/blob/master/CREDITS.md -https://github.com/sickcodes/Docker-OSX/blob/master/CREDITS.md +Additionally, comprehensive list of all contributors can be found here: https://github.com/sickcodes/Docker-OSX/graphs/contributors -Docker Hub: https://hub.docker.com/r/sickcodes/docker-osx +Special thanks to [@kholia](https://twitter.com/kholia) for maintaining the upstream project, which Docker-OSX is built on top of: [OSX-KVM](https://github.com/kholia/OSX-KVM) -- sickcodes/docker-osx:latest - base recovery image (10) +## Docker -- sickcodes/docker-osx:big-sur - base recovery image (11) +Images built on top of the contents of this repository are also available on **Docker Hub** for convenience: https://hub.docker.com/r/sickcodes/docker-osx -- sickcodes/docker-osx:naked - supply your own .img file +A comprehensive list of the available Docker images and their intended purpose can be found in the [Instructions](README.md#Instructions) -- sickcodes/docker-osx:auto - 17.5GB image boot to OSX shell +## Kubernetes -## Professional Support Available! +Docker-OSX supports Kubernetes. -Small questions & issues: open an issue! +Kubernetes Helm Chart & Documentation can be found under the [helm directory](helm/README.md) -For big projects, DM on Twitter [@sickcodes on Twitter](https://twitter.com/sickcodes) or write to us at https://sick.codes/contact. - -- Enterprise support, Business support, or casual support. -- Custom images, custom scripts, consulting (per hour available!) -- One-on-one with you, or your development team. - -## Kubernetes Support - -Kubernetes Helm Chart & Documentation [available at ./helm](https://github.com/sickcodes/Docker-OSX/tree/master/helm) - -Thank you to @cephasara for this major contribution. +Thanks [cephasara](https://github.com/cephasara) for contributing this major contribution. [![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/docker-osx)](https://artifacthub.io/packages/search?repo=docker-osx) -#### Follow [@sickcodes on Twitter](https://twitter.com/sickcodes) for updates or feature requests! +## Support -# Basic Quick Start Docker-OSX +### Small questions & issues + +Feel free to open an [issue](https://github.com/sickcodes/Docker-OSX/issues/new/choose), should you come across minor issues with running Docker-OSX or have any questions. + +#### Resolved issues + +Before you open an issue, however, please check the [closed issues](https://github.com/sickcodes/Docker-OSX/issues?q=is%3Aissue+is%3Aclosed) and confirm that you're using the latest version of this repository — your issues may have already been resolved! + +### Features requests and updates + +Follow [@sickcodes](https://twitter.com/sickcodes)! + +### Professional support + +For more sophisticated endeavours, we offer the following support services: + +- Enterprise support, business support, or casual support. +- Custom images, custom scripts, consulting (per hour available!) +- One-on-one conversations with you or your development team. + +In case you're interested, contact [@sickcodes on Twitter](https://twitter.com/sickcodes) or click [here](https://sick.codes/contact). + +## License/Contributing + +Docker-OSX is licensed under the [GPL v3](LICENSE). Contributions are welcomed and immensely appreciated. + +## Disclaimer + +Product names, logos, brands and other trademarks referred to within this project are the property of their respective trademark holders. These trademark holders are not affiliated with our repository in any capacity. They do not sponsor or endorse our materials. + +## Instructions + +#### Quick Start ```bash - docker pull sickcodes/docker-osx:latest # Catalina @@ -65,67 +85,69 @@ docker run -it \ -e "DISPLAY=${DISPLAY:-:0.0}" \ sickcodes/docker-osx:big-sur -# Wait 2-3 minutes until you see the logo. - +# Wait 2-3 minutes until the logo appears. ``` -# How to use +### Container images -### There are 3 images: **latest**, **auto** and **naked**. +There are three different Docker images available, which are suitable for different purposes: **latest**, **auto** and **naked**. -`sickcodes/docker-osx:latest` - [I want to try it out.](https://github.com/sickcodes/Docker-OSX#quick-start-large-pre-made-image) +- `sickcodes/docker-osx:latest` - [I just want to try it out.](https://github.com/sickcodes/Docker-OSX#quick-start-large-pre-made-image) +- `sickcodes/docker-osx:latest` - [I want to use Docker-OSX to develop/secure apps in Xcode (sign into Xcode, Transporter)](https://github.com/sickcodes/Docker-OSX#basic-quick-start-docker-osx) +- `sickcodes/docker-osx:naked` - [I want to use Docker-OSX for CI/CD-related purposes (sign into Xcode, Transporter)](https://github.com/sickcodes/Docker-OSX#fully-headless-using-my-own-image-for-cicd) -`sickcodes/docker-osx:latest` - [I want to use Docker-OSX to develop/secure Apps in Xcode (sign into Xcode, Transporter)](https://github.com/sickcodes/Docker-OSX#basic-quick-start-docker-osx) +Create your personal image using `:latest`. Then, extract the image. Afterwards, you will be able to duplicate that image and import it to the `:naked` container, in order to revert the container to a previous state repeatedly. -`sickcodes/docker-osx:naked` - [I want to use Docker-OSX in CI/CD (sign into Xcode, Transporter)](https://github.com/sickcodes/Docker-OSX#fully-headless-using-my-own-image-for-cicd) -Create your personal image using `:latest`. And then pull your image out. And then use duplicate that image again & again for use in `:naked`. +- `sickcodes/docker-osx:auto` - [I'm only interested in using the command line. (Useful for compiling software or using Homebrew headlessly).](https://github.com/sickcodes/Docker-OSX#pre-built-image-arbitrary-command-line-arguments) +- `sickcodes/docker-osx:naked` - [I need iMessage/iCloud for security research.](https://github.com/sickcodes/Docker-OSX#serial-numbers) -`sickcodes/docker-osx:auto` - [I want to boot into command line only. (compile software, homebrew headless).](https://github.com/sickcodes/Docker-OSX#pre-built-image-arbitrary-command-line-arguments) +#### I need video output. -`sickcodes/docker-osx:naked` - [I need iMessage/iCloud for security research.](https://github.com/sickcodes/Docker-OSX#serial-numbers) +The Quick Start command should work out of the box, provided that you keep the following lines. Works in `auto` & `naked` machines: -#### I need a screen. -**KEEP** these two lines are in your command. Works in `auto` & `naked` machines: ```dockerfile -v /tmp/.X11-unix:/tmp/.X11-unix \ -e "DISPLAY=${DISPLAY:-:0.0}" \ ``` -#### I need headless. -**REMOVE** these two lines from `auto` or `naked` machines: +#### I need to use Docker-OSX headlessly. + +In that case, **remove** the two lines in your command: + ```dockerfile # -v /tmp/.X11-unix:/tmp/.X11-unix \ # -e "DISPLAY=${DISPLAY:-:0.0}" \ ``` -#### I have used it already, and want to copy this image. -Use `docker commit`, copy the ID, and then `docker start ID` +#### I have used Docker-OSX before and wish to extract my Mac OS X image. -**OR** +Use `docker commit`, copy the ID, and then run `docker start `. -[Pull out the .img file](https://github.com/sickcodes/Docker-OSX#backup-the-disk-wheres-my-disk), and then use that [.img file with :naked](https://github.com/sickcodes/Docker-OSX#quick-start-own-image-naked-container-image) +**Alternatively:** +[Extract the .img file](https://github.com/sickcodes/Docker-OSX#backup-the-disk-wheres-my-disk), and then use that [.img file with :naked](https://github.com/sickcodes/Docker-OSX#quick-start-own-image-naked-container-image) -# Quick Start Large Pre-Made Image +# Technical details -Current large image size: 17.5GB +**Current large image size:** 17.5GB -This starts a container with an existing installation. This special auto image was made by @sickcodes: +The images (excluding `:naked`) launch a container with an existing installation with a couple of premade configurations. This special image was developed by [Sick.Codes](https://sick.codes): - SSH enabled - username is `user` - password is `alpine` -- auto-updates off +- auto-updates are disabled -You will need around *50GB* of space to run this image: half for the base image + half for your runtime image. +## Requirements + +You will need around *50 GB* of space to run this image: half for the base image + half for your runtime image. If you run out of space, you can delete all your old Docker images/history/cache by simply deleting `/var/lib/docker`, and restarting `dockerd`. ```bash - docker pull sickcodes/docker-osx:auto -# boot directly into a real OSX shell with no display (Xvfb) [HEADLESS] +# boot directly into a real OS X shell with no display (Xvfb) [HEADLESS] docker run -it \ --device /dev/kvm \ -p 50922:10022 \ @@ -138,7 +160,7 @@ docker run -it \ docker pull sickcodes/docker-osx:auto -# boot directly into a real OSX shell with a visual display [NOT HEADLESS] +# boot directly into a real OS X shell with a visual display [NOT HEADLESS] docker run -it \ --device /dev/kvm \ -p 50922:10022 \ @@ -147,13 +169,13 @@ docker run -it \ sickcodes/docker-osx:auto ``` + ### Pre-built Image + Arbitrary Command Line Arguments. ```bash - docker pull sickcodes/docker-osx:auto -# boot to OSX shell + display + specify commands to run inside OSX! +# boot to OS X shell + display + specify commands to run inside OS X! docker run -it \ --device /dev/kvm \ -p 50922:10022 \ @@ -163,22 +185,21 @@ docker run -it \ sickcodes/docker-osx:auto # Boots in a minute or two! - ``` + ### Restart an auto container -Containers that use `sickcodes/docker-osx:auto` can be stopped at started. +Containers that use `sickcodes/docker-osx:auto` can be stopped while being started. ```bash # find last container docker ps -a # docker start old container with -i for interactive -docker start -i containerid - +docker start -i ``` -# Quick Start Own Image (naked container image) +### Quick Start Own Image (naked container image) This is my favourite container. You can supply an existing disk image as a docker command line argument. @@ -212,10 +233,9 @@ docker run -it \ -e "DISPLAY=${DISPLAY:-:0.0}" \ -e "NOPICKER=false" \ sickcodes/docker-osx:naked - ``` -### Fully Headless, using my own image, for CI/CD +### Fully Headless, using a custom image, for CI/CD ```bash # run your own image headless + SSH @@ -227,12 +247,13 @@ docker run -it \ ``` # Features In Docker-OSX v4 + - `sickcodes/docker-osx:big-sur` - original base recovery image for latest OS (safe) - Serial number generators. [See below or ./custom](https://github.com/sickcodes/Docker-OSX/tree/master/custom) -- Full auto mode: boot straight to OSX shell and even run commands as runtime arguments! +- Full auto mode: boot straight to OS X shell and even run commands as runtime arguments! - `sickcodes/docker-osx:latest` - original base recovery image (safe) - `sickcodes/docker-osx:naked` - supply your own .img file (safe) -- `sickcodes/docker-osx:auto` - Large docker image that boots to OSX shell (must trust @sickcodes) +- `sickcodes/docker-osx:auto` - Large docker image that boots to OS X shell (must trust @sickcodes) - Supply your own image using `-v "${PWD}/disk.img:/image"` - Kubernetes Helm Chart. [See ./helm](https://github.com/sickcodes/Docker-OSX/tree/master/helm) - [OSX-KVM](https://github.com/kholia/OSX-KVM) inside a Docker container! @@ -243,19 +264,7 @@ docker run -it \ - Create an ARMY of the same exact container using `docker commit` - Xfvb headless mode -### All Pull Requests Welcome! - -Docker-OSX is a GPLv3+ Dockerfile and we need contributors just like you :) - -Upstream: https://github.com/kholia/OSX-KVM && the great guy [@kholia](https://twitter.com/kholia) - -Upstream Credits (OSX-KVM project) among many others: https://github.com/kholia/OSX-KVM/blob/master/CREDITS.md - -# Download The Image for sickcodes/docker-osx:naked - -This is the current automated image. Username is `user`, passsword is `alpine`, SSH is on, and auto-updates are off. - -If the download is slow, just get the image from `docker pull sickcodes/docker-osx:auto` and find it in `/var/lib/docker`. +# Download the image manually ```bash wget https://images2.sick.codes/mac_hdd_ng_auto.img @@ -295,7 +304,7 @@ docker run -it \ ``` -# Run but allow SSH into OSX (Original Version)! +# Run but enable SSH in OS X (Original Version)! ```bash docker run -it \ @@ -306,12 +315,12 @@ docker run -it \ -e "DISPLAY=${DISPLAY:-:0.0}" \ sickcodes/docker-osx:latest -# turn on SSH after you've installed OSX in the "Sharing" settings. +# turn on SSH after you've installed OS X in the "Sharing" settings. ssh fullname@localhost -p 50922 ``` -# Autoboot into OSX after you've installed everything +# Autoboot into OS X after you've installed everything You can use `-e NOPICKER=true`. @@ -602,7 +611,7 @@ docker cp oldcontainerid:/home/arch/OSX-KVM/mac_hdd_ng.img . Or if you lost your container, find it with this: ```bash -# fast way, find 10 gigabyte OSX disks hiding in your docker container storage +# fast way, find 10 gigabyte OS X disks hiding in your docker container storage sudo find /var/lib/docker -size +10G | grep mac_hdd_ng.img # you can move (mv) it somewhere, using cp can take loads of disk space @@ -745,7 +754,7 @@ 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. ```bash -# this is a quick way to check your serial number via cli inside OSX +# this is a quick way to check your serial number via cli inside OS X ioreg -l | grep IOPlatformSerialNumber # or from the host @@ -1006,7 +1015,7 @@ Here's a few other resolutions! If you resolution is invalid, it will default to -e HEIGHT=1600 \ ``` -# Mount a disk inside OSX from the host +# Mount a disk inside OS X from the host Pass the disk into the container as a volume and then pass the disk again into QEMU command line extras with. From 43c65b5430aed4ffd287c66480bd123b713eb767 Mon Sep 17 00:00:00 2001 From: Panagiotis Vasilopoulos Date: Sat, 20 Mar 2021 11:00:43 +0200 Subject: [PATCH 39/68] Improved systemd-related instructions --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e2108aa..ac143ec 100644 --- a/README.md +++ b/README.md @@ -360,14 +360,12 @@ sudo apt install qemu qemu-kvm libvirt-clients libvirt-daemon-system bridge-util sudo yum install libvirt qemu-kvm # then run -sudo systemctl enable libvirtd.service -sudo systemctl enable virtlogd.service +sudo systemctl enable --now libvirtd +sudo systemctl enable --now virtlogd echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs sudo modprobe kvm - -# reboot ``` # Start the same container later (persistent disk) @@ -501,7 +499,7 @@ sudo dockerd sudo nohup dockerd & # or enable it in systemd -sudo systemctl enable docker +sudo systemctl enable --now docker ``` # How to Forward Additional Ports from the guest. From 37ed54da3d15ba35586f02aab901c0c604e10094 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Sun, 21 Mar 2021 21:11:40 +0000 Subject: [PATCH 40/68] Update docker start commands (drop back into shell using docker start -ai ) and CREDITS.md --- CREDITS.md | 6 ++++++ README.md | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CREDITS.md b/CREDITS.md index ae37ee1..0dcb0cf 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -57,3 +57,9 @@ These credits refer to the contributors to this repository: [@MrBenFTW](https://github.com/MrBenFTW) - Tempfix for arch #150 [@edsonboldrini](https://github.com/edsonboldrini) - Update README.md #161 + +[@TheHackerCoding](https://github.com/TheHackerCoding) - Typo in README.md #194 + +[@panos](https://github.com/panos) - Improved README #212 + +[@ggjulio](https://github.com/ggjulio) - Restarting an "auto" container #216 diff --git a/README.md b/README.md index ac143ec..d96ef55 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ In that case, **remove** the two lines in your command: #### I have used Docker-OSX before and wish to extract my Mac OS X image. -Use `docker commit`, copy the ID, and then run `docker start `. +Use `docker commit`, copy the ID, and then run `docker start -ai `. **Alternatively:** @@ -195,8 +195,8 @@ Containers that use `sickcodes/docker-osx:auto` can be stopped while being start # find last container docker ps -a -# docker start old container with -i for interactive -docker start -i +# docker start old container with -i for interactive, -a for attach STDIN/STDOUT +docker start -ai -i ``` ### Quick Start Own Image (naked container image) @@ -381,7 +381,7 @@ If you don't run this you will have a new image every time. docker ps --all # docker start the container ID -docker start abc123xyz567 +docker start -ai abc123xyz567 # if you have many containers, you can try automate it with filters like this # docker ps --all --filter "ancestor=sickcodes/docker-osx" From 7ea2b8ec48f0cb91e2b61aeba18736bca2eb92b9 Mon Sep 17 00:00:00 2001 From: Panagiotis Vasilopoulos Date: Mon, 22 Mar 2021 13:20:09 +0200 Subject: [PATCH 41/68] Made further improvements to the README --- README.md | 405 +++++++++++++++++++++++------------------------------- 1 file changed, 175 insertions(+), 230 deletions(-) diff --git a/README.md b/README.md index d96ef55..e0409dc 100644 --- a/README.md +++ b/README.md @@ -6,25 +6,53 @@ Run Mac OS X in Docker with near-native performance! X11 Forwarding! iMessage se ## Author -This project is maintained by [Sick.Codes](https://sick.codes/) [(Twitter)](https://twitter.com/sickcodes) +This project is maintained by [Sick.Codes](https://sick.codes/). [(Twitter)](https://twitter.com/sickcodes) Additional credits can be found here: https://github.com/sickcodes/Docker-OSX/blob/master/CREDITS.md Additionally, comprehensive list of all contributors can be found here: https://github.com/sickcodes/Docker-OSX/graphs/contributors -Special thanks to [@kholia](https://twitter.com/kholia) for maintaining the upstream project, which Docker-OSX is built on top of: [OSX-KVM](https://github.com/kholia/OSX-KVM) +Special thanks to [@kholia](https://twitter.com/kholia) for maintaining the upstream project, which Docker-OSX is built on top of: [OSX-KVM](https://github.com/kholia/OSX-KVM). + +## Technical details + +**Current large image size:** 17.5GB + +The images (excluding `:naked`) launch a container with an existing installation with a couple of premade configurations. This special image was developed by [Sick.Codes](https://sick.codes): + +- username: `user`, password: `alpine` +- ssh enabled (`localhost:50922`) +- vnc enabled (`localhost:8888`) +- auto-updates disabled +- serial number generators! +- x11 forwarding is enabled +- runs on top of QEMU + KVM +- supports big sur, custom images, xfvb headless mode +- you can clone your container with `docker commit` + +### Requirements + +- at least 50 GBs (half for the base image, half for your runtime image +- virtualization should be enabled in your bios settings +- a kvm-capable host + +### To be done + +- documentation for security researchers +- gpu acceleration +- support for virt-manager ## Docker Images built on top of the contents of this repository are also available on **Docker Hub** for convenience: https://hub.docker.com/r/sickcodes/docker-osx -A comprehensive list of the available Docker images and their intended purpose can be found in the [Instructions](README.md#Instructions) +A comprehensive list of the available Docker images and their intended purpose can be found in the [Instructions](README.md#Instructions). ## Kubernetes Docker-OSX supports Kubernetes. -Kubernetes Helm Chart & Documentation can be found under the [helm directory](helm/README.md) +Kubernetes Helm Chart & Documentation can be found under the [helm directory](helm/README.md). Thanks [cephasara](https://github.com/cephasara) for contributing this major contribution. @@ -40,7 +68,7 @@ Feel free to open an [issue](https://github.com/sickcodes/Docker-OSX/issues/new/ Before you open an issue, however, please check the [closed issues](https://github.com/sickcodes/Docker-OSX/issues?q=is%3Aissue+is%3Aclosed) and confirm that you're using the latest version of this repository — your issues may have already been resolved! -### Features requests and updates +### Feature requests and updates Follow [@sickcodes](https://twitter.com/sickcodes)! @@ -58,6 +86,10 @@ In case you're interested, contact [@sickcodes on Twitter](https://twitter.com/s Docker-OSX is licensed under the [GPL v3](LICENSE). Contributions are welcomed and immensely appreciated. +### Other cool Docker/QEMU based projects + +- [Run iOS in a Docker container with Docker-eyeOS](https://github.com/sickcodes/Docker-eyeOS) - [https://github.com/sickcodes/Docker-eyeOS](https://github.com/sickcodes/Docker-eyeOS) + ## Disclaimer Product names, logos, brands and other trademarks referred to within this project are the property of their respective trademark holders. These trademark holders are not affiliated with our repository in any capacity. They do not sponsor or endorse our materials. @@ -127,22 +159,11 @@ Use `docker commit`, copy the ID, and then run `docker start -ai ``` -### Quick Start Own Image (naked container image) +### Quick Start your own image (naked container image) -This is my favourite container. You can supply an existing disk image as a docker command line argument. +This is my favourite container. You can supply an existing disk image as a Docker command line argument. -Pull images out using `sudo find /var/lib/docker -size +10G | grep mac_hdd_ng.img` +- Pull images out using `sudo find /var/lib/docker -size +10G | grep mac_hdd_ng.img` -Supply your own local image with `-v "${PWD}/mac_hdd_ng.img:/image"` and use `sickcodes/docker-osx:naked` +- Supply your own local image with the command argument `-v "${PWD}/mac_hdd_ng.img:/image"` and use `sickcodes/docker-osx:naked` when instructing Docker to create your container. -- Naked image is for booting any existing .img file, e.g in the current working directory (`$PWD`) - -- By default, this image has a variable called `NOPICKER` which is `"true"`. This skips the disk selection menu. Use `-e NOPICKER=false` or any other string than the word `true` to enter the boot menu. This lets you use other disks instead of skipping the boot menu, e.g. recovery disk or disk utility. + - Naked image is for booting any existing .img file, e.g in the current working directory (`$PWD`) + - By default, this image has a variable called `NOPICKER` which is `"true"`. This skips the disk selection menu. Use `-e NOPICKER=false` or any other string than the word `true` to enter the boot menu. + + This lets you use other disks instead of skipping the boot menu, e.g. recovery disk or disk utility. ```bash docker pull sickcodes/docker-osx:naked @@ -235,55 +284,7 @@ docker run -it \ sickcodes/docker-osx:naked ``` -### Fully Headless, using a custom image, for CI/CD - -```bash -# run your own image headless + SSH -docker run -it \ - --device /dev/kvm \ - -p 50922:10022 \ - -v "${PWD}/mac_hdd_ng.img:/image" \ - sickcodes/docker-osx:naked -``` - -# Features In Docker-OSX v4 - -- `sickcodes/docker-osx:big-sur` - original base recovery image for latest OS (safe) -- Serial number generators. [See below or ./custom](https://github.com/sickcodes/Docker-OSX/tree/master/custom) -- Full auto mode: boot straight to OS X shell and even run commands as runtime arguments! -- `sickcodes/docker-osx:latest` - original base recovery image (safe) -- `sickcodes/docker-osx:naked` - supply your own .img file (safe) -- `sickcodes/docker-osx:auto` - Large docker image that boots to OS X shell (must trust @sickcodes) -- Supply your own image using `-v "${PWD}/disk.img:/image"` -- Kubernetes Helm Chart. [See ./helm](https://github.com/sickcodes/Docker-OSX/tree/master/helm) -- [OSX-KVM](https://github.com/kholia/OSX-KVM) inside a Docker container! -- X11 Forwarding -- SSH on `localhost:50922` -- QEMU + KVM! -- VNC version on `localhost:8888` [vnc version is inside a separate directory, there are security risks involved with using VNC, see insid the Dockerfile](https://github.com/sickcodes/Docker-OSX/blob/master/vnc-version/Dockerfile) -- Create an ARMY of the same exact container using `docker commit` -- Xfvb headless mode - -# Download the image manually - -```bash -wget https://images2.sick.codes/mac_hdd_ng_auto.img - -docker run -it \ - --device /dev/kvm \ - -p 50922:10022 \ - -v "${PWD}/mac_hdd_ng_auto.img:/image" \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - -e "DISPLAY=${DISPLAY:-:0.0}" \ - sickcodes/docker-osx:naked - -``` - -### Other cool Docker-QEMU based projects: - -[Run iOS in a Docker with Docker-eyeOS](https://github.com/sickcodes/Docker-eyeOS) - [https://github.com/sickcodes/Docker-eyeOS](https://github.com/sickcodes/Docker-eyeOS) - -# Run Docker-OSX (Original Version) +### Run the original version of Docker-OSX ```bash @@ -296,12 +297,9 @@ docker run -it \ -e "DISPLAY=${DISPLAY:-:0.0}" \ sickcodes/docker-osx:latest -# press ctrl G if your mouse gets stuck - +# press CTRL + G if your mouse gets stuck # scroll down to troubleshooting if you have problems - # need more RAM and SSH on localhost -p 50922? - ``` # Run but enable SSH in OS X (Original Version)! @@ -316,11 +314,10 @@ docker run -it \ sickcodes/docker-osx:latest # turn on SSH after you've installed OS X in the "Sharing" settings. -ssh fullname@localhost -p 50922 - +ssh user@localhost -p 50922 ``` -# Autoboot into OS X after you've installed everything +### Autoboot into OS X after you've installed everything You can use `-e NOPICKER=true`. @@ -422,9 +419,12 @@ docker run \ newImageName ``` -# Troubleshooting +## Troubleshooting + +### LibGTK - Permission denied + +Thanks [@raoulh](https://github.com/raoulh) and [@arsham](https://github.com/arsham) for contributing this section. -libgtk permissions denied error, thanks @raoulh + @arsham ```bash echo $DISPLAY @@ -442,7 +442,9 @@ xhost + ``` -PulseAudio for sound (note neither [AppleALC](https://github.com/acidanthera/AppleALC) and varying [`alcid`](https://dortania.github.io/OpenCore-Post-Install/universal/audio.html) or [VoodooHDA-OC](https://github.com/chris1111/VoodooHDA-OC) have [codec support](https://osy.gitbook.io/hac-mini-guide/details/hda-fix#hda-codec) though [IORegistryExplorer](https://github.com/vulgo/IORegistryExplorer) does show the controller component working): +### Use PulseAudio for sound + +Note: [AppleALC](https://github.com/acidanthera/AppleALC), [`alcid`](https://dortania.github.io/OpenCore-Post-Install/universal/audio.html) and [VoodooHDA-OC](https://github.com/chris1111/VoodooHDA-OC) do not have [codec support](https://osy.gitbook.io/hac-mini-guide/details/hda-fix#hda-codec). However, [IORegistryExplorer](https://github.com/vulgo/IORegistryExplorer) does show the controller component working. ```bash docker run \ @@ -453,7 +455,8 @@ docker run \ sickcodes/docker-osx ``` -PulseAudio debugging: +#### PulseAudio debugging + ```bash docker run \ --device /dev/kvm \ @@ -464,7 +467,9 @@ docker run \ sickcodes/docker-osx pactl list ``` -Alternative run, thanks @roryrjb +#### Alternative soltuion + +Thanks [@roryrjb](https://github.com/roryrjb) for contributing this section. ```bash docker run \ @@ -477,39 +482,43 @@ docker run \ sickcodes/docker-osx ``` -Check if your hardware virt is on +### Routine checks + +#### Confirm that your CPU supports virtualization ```bash egrep -c '(svm|vmx)' /proc/cpuinfo ``` -Try adding yourself to the docker group +#### Try adding yourself to the docker group ```bash sudo usermod -aG docker "${USER}" ``` -Turn on docker daemon +#### Enable docker daemon ```bash -# run ad hoc +# enable it in systemd +sudo systemctl enable --now docker + +# or run ad hoc sudo dockerd # or daemonize it sudo nohup dockerd & - -# or enable it in systemd -sudo systemctl enable --now docker ``` -# How to Forward Additional Ports from the guest. +#### Forward additional ports (nginx) -This is how it visually looks: +It's possible to forward additional ports depending on your needs. In this example, we're going to use Mac OS X to host nginx in a way that looks like this: -`host:10023 <-> 10023:container:10023 <-> 80:guest` +``` +host:10023 <-> 10023:container:10023 <-> 80:guest +``` + +On the host machine, you should run: -```bash -On the host ```bash docker run -it \ --device /dev/kvm \ @@ -519,7 +528,8 @@ docker run -it \ sickcodes/docker-osx:auto ``` -Inside the container: +In a Terminal session running the container, you should run: + ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" @@ -529,9 +539,9 @@ sudo sed -i -e 's/8080/80/' /usr/local/etc/nginx/nginx.confcd sudo nginx ``` -nginx should appear on the host at port 10023. +**nginx should now be reachable on the port 10023.** -You can string multiple statements, for example: +Additionally, you can string multiple statements, for example: ```bash -e ADDITIONAL_PORTS='hostfwd=tcp::10023-:80,hostfwd=tcp::10043-:443,' @@ -539,13 +549,11 @@ You can string multiple statements, for example: -p 10043:10043 \ ``` -# How to Enable Network Forwarding +### Enable IPv4 forwarding for bridged network connections -Allow ipv4 forwarding for bridged networking connections: +This is not required for LOCAL installations and may [cause the host to leak your IP, even if you're using a VPN in the container](https://sick.codes/cve-2020-15590/). -This is not required for LOCAL installations and may cause containers behind [VPN's to leak host IP](https://sick.codes/cve-2020-15590/). - -If you are connecting to a REMOTE Docker-OSX, e.g. a "Mac Mini" in a datacenter, then this may boost networking: +However, if you're trying to connect to an instance of Docker-OSX remotely (e.g. an instance of Docker-OSX hosted in a datacenter), this may improve your performance: ```bash # enable for current session @@ -560,36 +568,15 @@ sudo tee -a /etc/sysctl.conf < Date: Tue, 23 Mar 2021 09:53:17 +0000 Subject: [PATCH 42/68] Add more secure VNC password generation. Update osx-serial-generator submodule. Acknowledge OpenCore bootloader usage. --- CREDITS.md | 8 ++++++-- README.md | 10 ++++++++-- osx-serial-generator | 2 +- vnc-version/Dockerfile | 4 ++-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/CREDITS.md b/CREDITS.md index 0dcb0cf..5f6bf40 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -1,8 +1,12 @@ # Credits -The upstream credits are available at [@Kholia](https://github.com/Kholia)'s repo https://github.com/kholia/OSX-KVM/blob/master/CREDITS.md +## Upstream Acknowledgements: -These credits refer to the contributors to this repository: +This project uses OSX-KVM from https://github.com/kholia/OSX-KVM/ and fully appreciates the work done by [@Kholia](https://github.com/Kholia) and all the contributors who are listed: [https://github.com/kholia/OSX-KVM/blob/master/CREDITS.md](https://github.com/kholia/OSX-KVM/blob/master/CREDITS.md) + +This project now uses the fantastic OpenCore bootloader from the community OpenCore project: https://github.com/acidanthera/OpenCorePkg. You can join their [Subreddit here](https://www.reddit.com/r/hackintosh/)! + +## These credits refer to the contributors to this repository: [@GreeFine](https://github.com/GreeFine) - Readme Typo #9 diff --git a/README.md b/README.md index d96ef55..1409723 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,10 @@ Additionally, comprehensive list of all contributors can be found here: https:// Special thanks to [@kholia](https://twitter.com/kholia) for maintaining the upstream project, which Docker-OSX is built on top of: [OSX-KVM](https://github.com/kholia/OSX-KVM) +Big thanks to the OpenCore team over at: https://github.com/acidanthera/OpenCorePkg. Their well-maintained bootloader provides much of the great functionality that Docker-OSX users enjoy :) + +If you like this project, consider contributing upstream! + ## Docker Images built on top of the contents of this repository are also available on **Docker Hub** for convenience: https://hub.docker.com/r/sickcodes/docker-osx @@ -56,11 +60,13 @@ In case you're interested, contact [@sickcodes on Twitter](https://twitter.com/s ## License/Contributing -Docker-OSX is licensed under the [GPL v3](LICENSE). Contributions are welcomed and immensely appreciated. +Docker-OSX is licensed under the [GPL v3+](LICENSE). Contributions are welcomed and immensely appreciated. You are in-fact permitted to use Docker-OSX as a tool to create proprietary software. ## Disclaimer -Product names, logos, brands and other trademarks referred to within this project are the property of their respective trademark holders. These trademark holders are not affiliated with our repository in any capacity. They do not sponsor or endorse our materials. +If you are serious about Apple Security, and possibly finding 6-figure bug bounties within the Apple Bug Bounty Program, then you're in the right place! Further notes: [Is Hackintosh, OSX-KVM, or Docker-OSX legal?](https://sick.codes/is-hackintosh-osx-kvm-or-docker-osx-legal/). + +Product names, logos, brands and other trademarks referred to within this project are the property of their respective trademark holders. These trademark holders are not affiliated with our repository in any capacity. They do not sponsor or endorse this project in any way. ## Instructions diff --git a/osx-serial-generator b/osx-serial-generator index 0149015..1d7425a 160000 --- a/osx-serial-generator +++ b/osx-serial-generator @@ -1 +1 @@ -Subproject commit 0149015547a26b991fc6035972dae75357dc68aa +Subproject commit 1d7425a7fa929423d965334cd78e9c75aeff2ad0 diff --git a/vnc-version/Dockerfile b/vnc-version/Dockerfile index bea056d..5995142 100644 --- a/vnc-version/Dockerfile +++ b/vnc-version/Dockerfile @@ -7,7 +7,7 @@ # # Title: Mac on Docker (Docker-OSX) [VNC EDITION] # Author: Sick.Codes https://sick.codes/ -# Version: 3.0 +# Version: 3.1 # License: GPLv3+ # # All credits for OSX-KVM and the rest at Kholia's repo: https://github.com/kholia/osx-kvm @@ -113,7 +113,7 @@ RUN cat vnc.sh Launch.sh > Launch_custom.sh RUN chmod +x Launch_custom.sh -RUN tee vncpasswd_file <<< "${VNC_PASSWORD:=$(openssl rand -hex 4)}" +RUN tee vncpasswd_file <<< "${VNC_PASSWORD:="$(tr -dc '[:graph:]' ${HOME}/.vnc/passwd RUN chmod 600 ~/.vnc/passwd From 9e7342f9662e7a958df90d0cbab53b15067dc2ff Mon Sep 17 00:00:00 2001 From: sickcodes Date: Wed, 24 Mar 2021 13:40:16 +0000 Subject: [PATCH 43/68] Add all ENV variables to each dockerfile for readability. Add RAM allocation buffer and cache drop bug fix. Add kvm and libvirt groups. Add IMAGE_FORMAT=qcow2 to allow IMAGE_FORMAT=raw too. --- CHANGELOG.md | 2 ++ Dockerfile | 42 +++++++++++++++++------------- Dockerfile.auto | 39 +++++++++++++++++++++++---- Dockerfile.naked | 30 ++++++++++++++++++++- README.md | 68 +++++++++++++++++++++++++++++++++++++----------- 5 files changed, 142 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 440d321..fc2c562 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ |Version|Date|Notes| |---|---|---| +|4.2|2021-03-24|Add all ENV variables to each dockerfile for readability. Add RAM allocation buffer and cache drop bug fix. Add kvm and libvirt groups. Add `IMAGE_FORMAT=qcow2` to allow `IMAGE_FORMAT=raw` too.| +| |2021-03-19|Use RAM=3 as the default RAM allocation. Add instructions to clear buff/cache.| | |2021-03-17|Add RAM=max and RAM=half to dynamically select ram at runtime (DEFAULT).| | |2021-03-06|Change envs to require --envs. Automatically enable --envs if --output-env is used. Same for plists, bootdisks. Fix help ugliness and sanity of generate serial scripts. Fix bootdisk not getting written to persistent file when using NOPICKER=true. NOPICKER=true is overridden by a custom plist now anyway. Remove useless case statements. Allow -e HEADLESS=true as human readable alternative to -e DISPLAY=:99.| |4.1|2021-03-04|Add `-e MASTER_PLIST_URL` to all images to allow using your own remote plist.| diff --git a/Dockerfile b/Dockerfile index cc75ddd..5f247df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ # # Title: Docker-OSX (Mac on Docker) # Author: Sick.Codes https://twitter.com/sickcodes -# Version: 4.1 +# Version: 4.2 # License: GPLv3+ # Repository: https://github.com/sickcodes/Docker-OSX # Website: https://sick.codes @@ -203,15 +203,6 @@ ARG BRANCH=master ARG REPO='https://github.com/sickcodes/Docker-OSX.git' RUN git clone --recurse-submodules --depth 1 --branch "${BRANCH}" "${REPO}" -# env -e ADDITIONAL_PORTS with a comma -# for example, -e ADDITIONAL_PORTS=hostfwd=tcp::23-:23, -ENV ADDITIONAL_PORTS= - -# dynamic RAM options for runtime -ENV RAM=3 -# ENV RAM=max -# ENV RAM=half - RUN touch Launch.sh \ && chmod +x ./Launch.sh \ && tee -a Launch.sh <<< '#!/bin/sh' \ @@ -223,7 +214,7 @@ RUN touch Launch.sh \ && tee -a Launch.sh <<< 'sudo chown -R $(id -u):$(id -g) /dev/snd 2>/dev/null || true' \ && tee -a Launch.sh <<< 'exec qemu-system-x86_64 -m ${RAM:-2}000 \' \ && tee -a Launch.sh <<< '-cpu Penryn,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+pcid,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check \' \ - && tee -a Launch.sh <<< '-machine q35,accel=kvm:tcg \' \ + && tee -a Launch.sh <<< '-machine q35,${KVM:-"accel=kvm:tcg"} \' \ && tee -a Launch.sh <<< '-smp ${CPU_STRING:-${SMP:-4},cores=${CORES:-4}} \' \ && tee -a Launch.sh <<< '-usb -device usb-kbd -device usb-tablet \' \ && tee -a Launch.sh <<< '-device isa-applesmc,osk=ourhardworkbythesewordsguardedpleasedontsteal\(c\)AppleComputerInc \' \ @@ -236,7 +227,7 @@ RUN touch Launch.sh \ && tee -a Launch.sh <<< '-device ide-hd,bus=sata.2,drive=OpenCoreBoot \' \ && tee -a Launch.sh <<< '-device ide-hd,bus=sata.3,drive=InstallMedia \' \ && tee -a Launch.sh <<< '-drive id=InstallMedia,if=none,file=/home/arch/OSX-KVM/BaseSystem.img,format=qcow2 \' \ - && tee -a Launch.sh <<< '-drive id=MacHDD,if=none,file=${IMAGE_PATH:-/home/arch/OSX-KVM/mac_hdd_ng.img},format=qcow2 \' \ + && tee -a Launch.sh <<< '-drive id=MacHDD,if=none,file=${IMAGE_PATH:-/home/arch/OSX-KVM/mac_hdd_ng.img},format=${IMAGE_FORMAT:-qcow2} \' \ && tee -a Launch.sh <<< '-device ide-hd,bus=sata.4,drive=MacHDD \' \ && tee -a Launch.sh <<< '-netdev user,id=net0,hostfwd=tcp::${INTERNAL_SSH_PORT:-10022}-:22,hostfwd=tcp::${SCREEN_SHARE_PORT:-5900}-:5900,${ADDITIONAL_PORTS} \' \ && tee -a Launch.sh <<< '-device ${NETWORKING:-vmxnet3},netdev=net0,id=net0,mac=${MAC_ADDRESS:-52:54:00:09:49:17} \' \ @@ -255,32 +246,47 @@ USER arch ENV USER arch +#### SPECIAL RUNTIME ARGUMENTS BELOW + +# env -e ADDITIONAL_PORTS with a comma +# for example, -e ADDITIONAL_PORTS=hostfwd=tcp::23-:23, +ENV ADDITIONAL_PORTS= + ENV BOOTDISK= ENV DISPLAY=:0.0 ENV ENV=/env -ENV IMAGE_PATH=/home/arch/OSX-KVM/mac_hdd_ng.img - -# ENV NETWORKING=e1000-82545em -ENV NETWORKING=vmxnet3 - # Boolean for generating a bootdisk with new random serials. ENV GENERATE_UNIQUE=false # Boolean for generating a bootdisk with specific serials. ENV GENERATE_SPECIFIC=false +ENV IMAGE_PATH=/home/arch/OSX-KVM/mac_hdd_ng.img +ENV IMAGE_FORMAT=qcow2 + +ENV KVM='accel=kvm:tcg' + +ENV MASTER_PLIST_URL="https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-nopicker-custom.plist" + +# ENV NETWORKING=e1000-82545em +ENV NETWORKING=vmxnet3 + # boolean for skipping the disk selection menu at in the boot process ENV NOPICKER=false +# dynamic RAM options for runtime +ENV RAM=3 +# ENV RAM=max +# ENV RAM=half + # 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/osx-serial-generator/master/config-nopicker-custom.plist" VOLUME ["/tmp/.X11-unix"] diff --git a/Dockerfile.auto b/Dockerfile.auto index c5d199f..ff7d5e6 100644 --- a/Dockerfile.auto +++ b/Dockerfile.auto @@ -7,7 +7,7 @@ # # Title: Docker-OSX (Mac on Docker) # Author: Sick.Codes https://twitter.com/sickcodes -# Version: 4.1 +# Version: 4.2 # License: GPLv3+ # Repository: https://github.com/sickcodes/Docker-OSX # Website: https://sick.codes @@ -115,20 +115,25 @@ RUN mkdir -p ~/.ssh \ ARG COMPLETE=true -# Feel free to take a copy of this image and then host it internally -ARG IMAGE_URL='https://images2.sick.codes/mac_hdd_ng_auto.img' - # use the COMPLETE arg, for a complete image, ready to boot. # otherwise use your own image: -v "$PWD/disk.img":/image ARG WGET_OPTIONS= # ARG WGET_OPTIONS='--no-verbose' +# Feel free to take a copy of this image and then host it internally +ARG IMAGE_URL='https://images.sick.codes/mac_hdd_ng_auto.img' +# ARG IMAGE_URL='https://images.sick.codes/mac_hdd_ng_auto_big_sur.img' + RUN if [[ "${COMPLETE}" ]]; then \ - echo "Downloading 20GB+ image... This step might take a while... Press Ctrl+C if you want to abort." \ + echo "Downloading 20GB image... This step might take a while... Press Ctrl+C if you want to abort." \ ; rm -f /home/arch/OSX-KVM/mac_hdd_ng.img \ && wget ${WGET_OPTIONS} -O /home/arch/OSX-KVM/mac_hdd_ng.img "${IMAGE_URL}" \ ; fi +#### SPECIAL RUNTIME ARGUMENTS BELOW + +ENV ADDITIONAL_PORTS= + ENV BOOTDISK= ENV DISPLAY=:99 @@ -137,10 +142,34 @@ ENV HEADLESS=false ENV ENV=/env +# Boolean for generating a bootdisk with new random serials. +ENV GENERATE_UNIQUE=false + +# Boolean for generating a bootdisk with specific serials. +ENV GENERATE_SPECIFIC=false + ENV IMAGE_PATH=/home/arch/OSX-KVM/mac_hdd_ng.img +ENV IMAGE_FORMAT=qcow2 + +ENV KVM='accel=kvm:tcg' + +# ENV MASTER_PLIST_URL="https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist" + +# ENV NETWORKING=e1000-82545em +ENV NETWORKING=vmxnet3 ENV NOPICKER=true +# dynamic RAM options for runtime +ENV RAM=3 +# ENV RAM=max +# ENV RAM=half + +# 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 TERMS_OF_USE=i_agree ENV BOILERPLATE="By using this Dockerfile, you hereby agree that you are a security reseacher or developer and agree to use this Dockerfile to make the world a safer place. Examples include: making your apps safer, finding your mobile phone, compiling security products, etc. You understand that Docker-OSX is an Open Source project, which is released to the public under the GNU Pulic License version 3 and above. You acknowledge that the Open Source project is absolutely unaffiliated with any third party, in any form whatsoever. Any trademarks or intelectual property which happen to be mentioned anywhere in or around the project are owned by their respective owners. By using this Dockerfile, you agree to agree to the EULA of each piece of upstream or downstream software. The following code is released for the sole purpose of security research, under the GNU Public License version 3. If you are concerned about the licensing, please note that this project is not AGPL. A copy of the license is available online: https://github.com/sickcodes/Docker-OSX/blob/master/LICENSE. In order to use the following Dockerfile you must read and understand the terms. Once you have read the terms, use the -e TERMS_OF_USE=i_agree or -e TERMS_OF_USE=i_disagree" diff --git a/Dockerfile.naked b/Dockerfile.naked index 3df45d2..734ea1d 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -7,7 +7,7 @@ # # Title: Docker-OSX (Mac on Docker) # Author: Sick.Codes https://twitter.com/sickcodes -# Version: 4.1 +# Version: 4.2 # License: GPLv3+ # Repository: https://github.com/sickcodes/Docker-OSX # Website: https://sick.codes @@ -102,6 +102,10 @@ RUN mkdir -p ~/.ssh \ && tee -a ~/.ssh/config <<< ' StrictHostKeyChecking no' \ && tee -a ~/.ssh/config <<< ' UserKnownHostsFile=/dev/null' +#### SPECIAL RUNTIME ARGUMENTS BELOW + +ENV ADDITIONAL_PORTS= + ENV BOOTDISK= ENV DISPLAY=:99 @@ -110,10 +114,34 @@ ENV HEADLESS=false ENV ENV=/env +# Boolean for generating a bootdisk with new random serials. +ENV GENERATE_UNIQUE=false + +# Boolean for generating a bootdisk with specific serials. +ENV GENERATE_SPECIFIC=false + ENV IMAGE_PATH=/image +ENV IMAGE_FORMAT=qcow2 + +ENV KVM='accel=kvm:tcg' + +# ENV MASTER_PLIST_URL="https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist" + +# ENV NETWORKING=e1000-82545em +ENV NETWORKING=vmxnet3 ENV NOPICKER=true +# dynamic RAM options for runtime +ENV RAM=3 +# ENV RAM=max +# ENV RAM=half + +# 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 + CMD sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true \ ; sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true \ ; { [[ "${DISPLAY}" = ':99' ]] || [[ "${HEADLESS}" == true ]] ; } && { \ diff --git a/README.md b/README.md index 1409723..75df715 100644 --- a/README.md +++ b/README.md @@ -430,7 +430,11 @@ docker run \ # Troubleshooting -libgtk permissions denied error, thanks @raoulh + @arsham +Big thank you to our contributors who have worked out almost every conceivable issue so far! + +[https://github.com/sickcodes/Docker-OSX/blob/master/CREDITS.md](https://github.com/sickcodes/Docker-OSX/blob/master/CREDITS.md) + +#### libgtk permissions denied error ```bash echo $DISPLAY @@ -447,6 +451,38 @@ sudo yum install xorg-x11-server-utils xhost + ``` +#### RAM over-allocation Error +Cause by trying to allocate more ram to the container than you currently have available for allocation: `cannot set up guest memory 'pc.ram': Cannot allocate memory`. + +For example: + +```console +[user@hostname ~]$ free -mh + total used free shared buff/cache available +Mem: 30Gi 3.5Gi 7.0Gi 728Mi 20Gi 26Gi +Swap: 11Gi 0B 11Gi +``` + +In the example above, the `buff/cache` already contains 20 Gigabytes of allocated RAM. + +Clear the buffer and the cache: + +```bash +sudo tee /proc/sys/vm/drop_caches <<< 3 +``` + +Now check the ram again: + +```console +[user@hostname ~]$ free -mh + total used free shared buff/cache available +Mem: 30Gi 3.3Gi 26Gi 697Mi 1.5Gi 26Gi +Swap: 11Gi 0B 11Gi +``` + +Of course you cannot allocate more RAM that your have. The default is 3 Gigabytes: `-e RAM=3`. + +#### PulseAudio PulseAudio for sound (note neither [AppleALC](https://github.com/acidanthera/AppleALC) and varying [`alcid`](https://dortania.github.io/OpenCore-Post-Install/universal/audio.html) or [VoodooHDA-OC](https://github.com/chris1111/VoodooHDA-OC) have [codec support](https://osy.gitbook.io/hac-mini-guide/details/hda-fix#hda-codec) though [IORegistryExplorer](https://github.com/vulgo/IORegistryExplorer) does show the controller component working): @@ -470,31 +506,33 @@ docker run \ sickcodes/docker-osx pactl list ``` -Alternative run, thanks @roryrjb +#### Nested Hardware Virtualization + +Check if your PC has hardware virtualization enabled: ```bash -docker run \ - --privileged \ - --net host \ - --cap-add=ALL \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - -v /dev:/dev \ - -v /lib/modules:/lib/modules \ - sickcodes/docker-osx -``` +sudo tee /sys/module/kvm/parameters/ignore_msrs <<< 1 -Check if your hardware virt is on - -```bash egrep -c '(svm|vmx)' /proc/cpuinfo ``` -Try adding yourself to the docker group +#### Add yourself to the Docker group, KVM group, libvirt group. + +If you use `sudo dockerd` or dockerd is controlled by systemd/systemctl, then you must be in the Docker group: + +To add yourself to the docker group: ```bash sudo usermod -aG docker "${USER}" ``` +and for the rest: + +```bash +sudo usermod -aG libvirt "${USER}" +sudo usermod -aG kvm "${USER}" +``` + Turn on docker daemon ```bash From 27cd8247eeb2c293a3a61005e05e7540ebf95caa Mon Sep 17 00:00:00 2001 From: sickcodes Date: Wed, 24 Mar 2021 18:14:05 +0000 Subject: [PATCH 44/68] Substitution if not null only --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5f247df..b559bb8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -214,7 +214,7 @@ RUN touch Launch.sh \ && tee -a Launch.sh <<< 'sudo chown -R $(id -u):$(id -g) /dev/snd 2>/dev/null || true' \ && tee -a Launch.sh <<< 'exec qemu-system-x86_64 -m ${RAM:-2}000 \' \ && tee -a Launch.sh <<< '-cpu Penryn,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+pcid,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check \' \ - && tee -a Launch.sh <<< '-machine q35,${KVM:-"accel=kvm:tcg"} \' \ + && tee -a Launch.sh <<< '-machine q35,${KVM-"accel=kvm:tcg"} \' \ && tee -a Launch.sh <<< '-smp ${CPU_STRING:-${SMP:-4},cores=${CORES:-4}} \' \ && tee -a Launch.sh <<< '-usb -device usb-kbd -device usb-tablet \' \ && tee -a Launch.sh <<< '-device isa-applesmc,osk=ourhardworkbythesewordsguardedpleasedontsteal\(c\)AppleComputerInc \' \ From 2414f466d0c6fd142734630c8206137695233575 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Wed, 24 Mar 2021 21:16:03 +0000 Subject: [PATCH 45/68] Enable interactive QEMU. Remove envsubst since we are already using bash. Add -x flag --- CHANGELOG.md | 1 + Dockerfile | 8 ++++---- Dockerfile.auto | 2 +- Dockerfile.naked | 2 +- README.md | 42 ++++++++++++++++++++++++++++++++++++++++-- 5 files changed, 47 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc2c562..dcc665f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ |Version|Date|Notes| |---|---|---| +|4.3|2021-03-24|Enable interactive QEMU again. Remove envsubst since we are already using bash... Add set -x flag| |4.2|2021-03-24|Add all ENV variables to each dockerfile for readability. Add RAM allocation buffer and cache drop bug fix. Add kvm and libvirt groups. Add `IMAGE_FORMAT=qcow2` to allow `IMAGE_FORMAT=raw` too.| | |2021-03-19|Use RAM=3 as the default RAM allocation. Add instructions to clear buff/cache.| | |2021-03-17|Add RAM=max and RAM=half to dynamically select ram at runtime (DEFAULT).| diff --git a/Dockerfile b/Dockerfile index b559bb8..9330937 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ # # Title: Docker-OSX (Mac on Docker) # Author: Sick.Codes https://twitter.com/sickcodes -# Version: 4.2 +# Version: 4.3 # License: GPLv3+ # Repository: https://github.com/sickcodes/Docker-OSX # Website: https://sick.codes @@ -205,8 +205,8 @@ RUN git clone --recurse-submodules --depth 1 --branch "${BRANCH}" "${REPO}" RUN touch Launch.sh \ && chmod +x ./Launch.sh \ - && tee -a Launch.sh <<< '#!/bin/sh' \ - && tee -a Launch.sh <<< 'set -eu' \ + && tee -a Launch.sh <<< '#!/bin/bash' \ + && tee -a Launch.sh <<< 'set -eux' \ && tee -a Launch.sh <<< 'sudo chown $(id -u):$(id -g) /dev/kvm 2>/dev/null || true' \ && tee -a Launch.sh <<< 'sudo chown -R $(id -u):$(id -g) /dev/snd 2>/dev/null || true' \ && tee -a Launch.sh <<< '[[ "${RAM}" = max ]] && export RAM="$(("$(head -n1 /proc/meminfo | tr -dc "[:digit:]") / 1000000"))"' \ @@ -340,7 +340,7 @@ CMD sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ ; } \ - ; ./enable-ssh.sh && envsubst < ./Launch.sh | bash + ; ./enable-ssh.sh && ./Launch.sh # virt-manager mode: eta son # CMD virsh define <(envsubst < Docker-OSX.xml) && virt-manager || virt-manager diff --git a/Dockerfile.auto b/Dockerfile.auto index ff7d5e6..8175e3e 100644 --- a/Dockerfile.auto +++ b/Dockerfile.auto @@ -7,7 +7,7 @@ # # Title: Docker-OSX (Mac on Docker) # Author: Sick.Codes https://twitter.com/sickcodes -# Version: 4.2 +# Version: 4.3 # License: GPLv3+ # Repository: https://github.com/sickcodes/Docker-OSX # Website: https://sick.codes diff --git a/Dockerfile.naked b/Dockerfile.naked index 734ea1d..6a5e397 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -7,7 +7,7 @@ # # Title: Docker-OSX (Mac on Docker) # Author: Sick.Codes https://twitter.com/sickcodes -# Version: 4.2 +# Version: 4.3 # License: GPLv3+ # Repository: https://github.com/sickcodes/Docker-OSX # Website: https://sick.codes diff --git a/README.md b/README.md index 75df715..84baac7 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ docker run -it \ -e "DISPLAY=${DISPLAY:-:0.0}" \ sickcodes/docker-osx:latest +docker pull sickcodes/docker-osx:big-sur # Big Sur docker run -it \ --device /dev/kvm \ @@ -111,7 +112,7 @@ Create your personal image using `:latest`. Then, extract the image. Afterwards, The Quick Start command should work out of the box, provided that you keep the following lines. Works in `auto` & `naked` machines: -```dockerfile +``` -v /tmp/.X11-unix:/tmp/.X11-unix \ -e "DISPLAY=${DISPLAY:-:0.0}" \ ``` @@ -120,11 +121,48 @@ The Quick Start command should work out of the box, provided that you keep the f In that case, **remove** the two lines in your command: -```dockerfile +``` # -v /tmp/.X11-unix:/tmp/.X11-unix \ # -e "DISPLAY=${DISPLAY:-:0.0}" \ ``` +#### I need VNC to a Remote Host (Secure) + +Now you can direct connect VNC to any image! + +Add the following line: + +`-e EXTRA="-display none -vnc 0.0.0.0:99,password"` + +In the Docker terminal, press `enter` until you see `(qemu)`. + +Type `change vnc password` + +`ip n` will usually show the container IP first. + +Port is `5999`. + +Now VNC connect using the Docker container IP, for example `172.17.0.2:5999` + +You can also find the container IP: `docker inspect | jq -r '.[0].NetworkSettings.IPAddress'` + +Remote VNC over SSH: `ssh -N root@1.1.1.1 -L 5999:172.17.0.2:5999`, where `1.1.1.1` is your remote server IP and `172.17.0.2` is your LAN container IP. + +#### I need VNC on localhost (Local use only!) + +##### VNC Insecure + +**NOT TLS/HTTPS Encrypted at all!** +``` +-p 5999:5999 +-e EXTRA="-display none -vnc 0.0.0.0:99,password" +``` +VNC Connect to `localhost:5999`. + +Or `ssh -N root@1.1.1.1 -L 5999:127.0.0.1:5999`, where `1.1.1.1` is your remote server IP. + +(Note: if you close port 5999 and use the SSH tunnel, this becomes secure.) + #### I have used Docker-OSX before and wish to extract my Mac OS X image. Use `docker commit`, copy the ID, and then run `docker start -ai `. From d4ffc1f2f315f2953085ee4fee182bc39ad0c26a Mon Sep 17 00:00:00 2001 From: sickcodes Date: Thu, 25 Mar 2021 13:59:59 +0000 Subject: [PATCH 46/68] Restore fetch-macOS.py from OSX-KVM previous --- Dockerfile | 4 +- fetch-macOS.py | 447 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 450 insertions(+), 1 deletion(-) create mode 100755 fetch-macOS.py diff --git a/Dockerfile b/Dockerfile index 9330937..74c6cb3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -165,6 +165,8 @@ RUN patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst \ WORKDIR /home/arch/OSX-KVM +RUN wget https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/fetch-macOS.py + RUN [[ "${VERSION%%.*}" -lt 11 ]] && { python fetch-macOS.py --version "${VERSION}" \ && qemu-img convert BaseSystem.dmg -O qcow2 -p -c BaseSystem.img \ && qemu-img create -f qcow2 mac_hdd_ng.img "${SIZE}" \ @@ -340,7 +342,7 @@ CMD sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ ; } \ - ; ./enable-ssh.sh && ./Launch.sh + ; ./enable-ssh.sh && /bin/bash -c ./Launch.sh # virt-manager mode: eta son # CMD virsh define <(envsubst < Docker-OSX.xml) && virt-manager || virt-manager diff --git a/fetch-macOS.py b/fetch-macOS.py new file mode 100755 index 0000000..f4d7e36 --- /dev/null +++ b/fetch-macOS.py @@ -0,0 +1,447 @@ +#!/usr/bin/env python3 +# encoding: utf-8 +# +# https://github.com/munki/macadmin-scripts/blob/master/installinstallmacos.py +# +# Copyright 2017 Greg Neagle. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Thanks to Tim Sutton for ideas, suggestions, and sample code. +# +# Updated in May of 2019 by Dhiru Kholia. + +'''installinstallmacos.py +A tool to download the parts for an Install macOS app from Apple's +softwareupdate servers and install a functioning Install macOS app onto an +empty disk image''' + +# https://github.com/foxlet/macOS-Simple-KVM/blob/master/tools/FetchMacOS/fetch-macos.py +# is pretty similar. + + +# Bad hack +import warnings + +warnings.filterwarnings("ignore", category=DeprecationWarning) + +import os +import gzip +import argparse +import plistlib +import subprocess + +from xml.dom import minidom +from xml.parsers.expat import ExpatError + + +import sys + +if sys.version_info[0] < 3: + import urlparse as urlstuff +else: + import urllib.parse as urlstuff +# Quick fix for python 3.9 and above +if sys.version_info[0] == 3 and sys.version_info[1] >= 9: + from types import MethodType + + def readPlist(self,filepath): + with open(filepath, 'rb') as f: + p = plistlib._PlistParser(dict) + rootObject = p.parse(f) + return rootObject + # adding the method readPlist() to plistlib + plistlib.readPlist = MethodType(readPlist, plistlib) + +# https://github.com/foxlet/macOS-Simple-KVM/blob/master/tools/FetchMacOS/fetch-macos.py (unused) +# https://github.com/munki/macadmin-scripts +catalogs = { + "CustomerSeed": "https://swscan.apple.com/content/catalogs/others/index-10.16customerseed-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog", + "DeveloperSeed": "https://swscan.apple.com/content/catalogs/others/index-10.16seed-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog", + "PublicSeed": "https://swscan.apple.com/content/catalogs/others/index-10.16beta-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog", + "PublicRelease": "https://swscan.apple.com/content/catalogs/others/index-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog", + "20": "https://swscan.apple.com/content/catalogs/others/index-11-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog" +} + + +def get_default_catalog(): + '''Returns the default softwareupdate catalog for the current OS''' + return catalogs["20"] + # return catalogs["PublicRelease"] + # return catalogs["DeveloperSeed"] + + +class ReplicationError(Exception): + '''A custom error when replication fails''' + pass + + +def cmd_exists(cmd): + return subprocess.call("type " + cmd, shell=True, + stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0 + + +def replicate_url(full_url, + root_dir='/tmp', + show_progress=False, + ignore_cache=False, + attempt_resume=False, installer=False, product_title=""): + '''Downloads a URL and stores it in the same relative path on our + filesystem. Returns a path to the replicated file.''' + + # hack + print("[+] Fetching %s" % full_url) + if installer and "BaseSystem.dmg" not in full_url and "Big Sur" not in product_title: + return + if "Big Sur" in product_title and "InstallAssistant.pkg" not in full_url: + return + attempt_resume = True + # path = urllib.parse.urlsplit(full_url)[2] + path = urlstuff.urlsplit(full_url)[2] + relative_url = path.lstrip('/') + relative_url = os.path.normpath(relative_url) + # local_file_path = os.path.join(root_dir, relative_url) + local_file_path = relative_url + # print("Downloading %s..." % full_url) + + if cmd_exists('wget'): + if not installer: + download_cmd = ['wget', "-c", "--quiet", "-x", "-nH", full_url] + # this doesn't work as there are multiple metadata files with the same name! + # download_cmd = ['wget', "-c", "--quiet", full_url] + else: + download_cmd = ['wget', "-c", full_url] + else: + if not installer: + download_cmd = ['curl', "--silent", "--show-error", "-o", local_file_path, "--create-dirs", full_url] + else: + local_file_path = os.path.basename(local_file_path) + download_cmd = ['curl', "-o", local_file_path, full_url] + + try: + subprocess.check_call(download_cmd) + except subprocess.CalledProcessError as err: + raise ReplicationError(err) + return local_file_path + + +def parse_server_metadata(filename): + '''Parses a softwareupdate server metadata file, looking for information + of interest. + Returns a dictionary containing title, version, and description.''' + title = '' + vers = '' + try: + md_plist = plistlib.readPlist(filename) + except (OSError, IOError, ExpatError) as err: + print('Error reading %s: %s' % (filename, err), file=sys.stderr) + return {} + vers = md_plist.get('CFBundleShortVersionString', '') + localization = md_plist.get('localization', {}) + preferred_localization = (localization.get('English') or + localization.get('en')) + if preferred_localization: + title = preferred_localization.get('title', '') + + metadata = {} + metadata['title'] = title + metadata['version'] = vers + + """ + {'title': 'macOS Mojave', 'version': '10.14.5'} + {'title': 'macOS Mojave', 'version': '10.14.6'} + """ + return metadata + + +def get_server_metadata(catalog, product_key, workdir, ignore_cache=False): + '''Replicate ServerMetaData''' + try: + url = catalog['Products'][product_key]['ServerMetadataURL'] + try: + smd_path = replicate_url( + url, root_dir=workdir, ignore_cache=ignore_cache) + return smd_path + except ReplicationError as err: + print('Could not replicate %s: %s' % (url, err), file=sys.stderr) + return None + except KeyError: + # print('Malformed catalog.', file=sys.stderr) + return None + + +def parse_dist(filename): + '''Parses a softwareupdate dist file, returning a dict of info of + interest''' + dist_info = {} + try: + dom = minidom.parse(filename) + except ExpatError: + print('Invalid XML in %s' % filename, file=sys.stderr) + return dist_info + except IOError as err: + print('Error reading %s: %s' % (filename, err), file=sys.stderr) + return dist_info + + titles = dom.getElementsByTagName('title') + if titles: + dist_info['title_from_dist'] = titles[0].firstChild.wholeText + + auxinfos = dom.getElementsByTagName('auxinfo') + if not auxinfos: + return dist_info + auxinfo = auxinfos[0] + key = None + value = None + children = auxinfo.childNodes + # handle the possibility that keys from auxinfo may be nested + # within a 'dict' element + dict_nodes = [n for n in auxinfo.childNodes + if n.nodeType == n.ELEMENT_NODE and + n.tagName == 'dict'] + if dict_nodes: + children = dict_nodes[0].childNodes + for node in children: + if node.nodeType == node.ELEMENT_NODE and node.tagName == 'key': + key = node.firstChild.wholeText + if node.nodeType == node.ELEMENT_NODE and node.tagName == 'string': + value = node.firstChild.wholeText + if key and value: + dist_info[key] = value + key = None + value = None + return dist_info + + +def download_and_parse_sucatalog(sucatalog, workdir, ignore_cache=False): + '''Downloads and returns a parsed softwareupdate catalog''' + try: + localcatalogpath = replicate_url( + sucatalog, root_dir=workdir, ignore_cache=ignore_cache) + except ReplicationError as err: + print('Could not replicate %s: %s' % (sucatalog, err), file=sys.stderr) + exit(-1) + if os.path.splitext(localcatalogpath)[1] == '.gz': + with gzip.open(localcatalogpath) as the_file: + content = the_file.read() + try: + catalog = plistlib.readPlistFromString(content) + return catalog + except ExpatError as err: + print('Error reading %s: %s' % (localcatalogpath, err), file=sys.stderr) + exit(-1) + else: + try: + catalog = plistlib.readPlist(localcatalogpath) + return catalog + except (OSError, IOError, ExpatError) as err: + print('Error reading %s: %s' % (localcatalogpath, err), file=sys.stderr) + exit(-1) + + +def find_mac_os_installers(catalog): + '''Return a list of product identifiers for what appear to be macOS + installers''' + mac_os_installer_products = [] + if 'Products' in catalog: + for product_key in catalog['Products'].keys(): + product = catalog['Products'][product_key] + try: + if product['ExtendedMetaInfo'][ + 'InstallAssistantPackageIdentifiers']: + mac_os_installer_products.append(product_key) + except KeyError: + continue + + return mac_os_installer_products + + +def os_installer_product_info(catalog, workdir, ignore_cache=False): + '''Returns a dict of info about products that look like macOS installers''' + product_info = {} + installer_products = find_mac_os_installers(catalog) + for product_key in installer_products: + product_info[product_key] = {} + filename = get_server_metadata(catalog, product_key, workdir) + if filename: + product_info[product_key] = parse_server_metadata(filename) + else: + # print('No server metadata for %s' % product_key) + product_info[product_key]['title'] = None + product_info[product_key]['version'] = None + + product = catalog['Products'][product_key] + product_info[product_key]['PostDate'] = product['PostDate'] + distributions = product['Distributions'] + dist_url = distributions.get('English') or distributions.get('en') + try: + dist_path = replicate_url( + dist_url, root_dir=workdir, ignore_cache=ignore_cache) + except ReplicationError as err: + print('Could not replicate %s: %s' % (dist_url, err), + file=sys.stderr) + else: + dist_info = parse_dist(dist_path) + product_info[product_key]['DistributionPath'] = dist_path + product_info[product_key].update(dist_info) + if not product_info[product_key]['title']: + product_info[product_key]['title'] = dist_info.get('title_from_dist') + if not product_info[product_key]['version']: + product_info[product_key]['version'] = dist_info.get('VERSION') + + return product_info + + +def replicate_product(catalog, product_id, workdir, ignore_cache=False, product_title=""): + '''Downloads all the packages for a product''' + product = catalog['Products'][product_id] + for package in product.get('Packages', []): + # TO-DO: Check 'Size' attribute and make sure + # we have enough space on the target + # filesystem before attempting to download + if 'URL' in package: + try: + replicate_url( + package['URL'], root_dir=workdir, + show_progress=True, ignore_cache=ignore_cache, + attempt_resume=(not ignore_cache), installer=True, product_title=product_title) + except ReplicationError as err: + print('Could not replicate %s: %s' % (package['URL'], err), file=sys.stderr) + exit(-1) + if 'MetadataURL' in package: + try: + replicate_url(package['MetadataURL'], root_dir=workdir, + ignore_cache=ignore_cache, installer=True) + except ReplicationError as err: + print('Could not replicate %s: %s' % (package['MetadataURL'], err), file=sys.stderr) + exit(-1) + + +def find_installer_app(mountpoint): + '''Returns the path to the Install macOS app on the mountpoint''' + applications_dir = os.path.join(mountpoint, 'Applications') + for item in os.listdir(applications_dir): + if item.endswith('.app'): + return os.path.join(applications_dir, item) + return None + + +def determine_version(version, product_info): + if version: + if version == 'latest': + from distutils.version import StrictVersion + latest_version = StrictVersion('0.0.0') + for index, product_id in enumerate(product_info): + d = product_info[product_id]['version'] + if d > latest_version: + latest_version = d + + if latest_version == StrictVersion("0.0.0"): + print("Could not find latest version {}") + exit(1) + + version = str(latest_version) + + for index, product_id in enumerate(product_info): + v = product_info[product_id]['version'] + if v == version: + return product_id, product_info[product_id]['title'] + + print("Could not find version {}. Versions available are:".format(version)) + for _, pid in enumerate(product_info): + print("- {}".format(product_info[pid]['version'])) + + exit(1) + + # display a menu of choices (some seed catalogs have multiple installers) + print('%2s %12s %10s %11s %s' % ('#', 'ProductID', 'Version', + 'Post Date', 'Title')) + for index, product_id in enumerate(product_info): + print('%2s %12s %10s %11s %s' % ( + index + 1, + product_id, + product_info[product_id]['version'], + product_info[product_id]['PostDate'].strftime('%Y-%m-%d'), + product_info[product_id]['title'] + )) + + answer = input( + '\nChoose a product to download (1-%s): ' % len(product_info)) + try: + index = int(answer) - 1 + if index < 0: + raise ValueError + product_id = list(product_info.keys())[index] + return product_id, product_info[product_id]['title'] + except (ValueError, IndexError): + pass + + print('Invalid input provided.') + exit(0) + + +def main(): + '''Do the main thing here''' + """ + if os.getuid() != 0: + sys.exit('This command requires root (to install packages), so please ' + 'run again with sudo or as root.') + """ + parser = argparse.ArgumentParser() + parser.add_argument('--workdir', metavar='path_to_working_dir', + default='.', + help='Path to working directory on a volume with over ' + '10G of available space. Defaults to current working ' + 'directory.') + parser.add_argument('--version', metavar='version', + default=None, + help='The version to download in the format of ' + '"$major.$minor.$patch", e.g. "10.15.4". Can ' + 'be "latest" to download the latest version.') + parser.add_argument('--compress', action='store_true', + help='Output a read-only compressed disk image with ' + 'the Install macOS app at the root. This is now the ' + 'default. Use --raw to get a read-write sparse image ' + 'with the app in the Applications directory.') + parser.add_argument('--raw', action='store_true', + help='Output a read-write sparse image ' + 'with the app in the Applications directory. Requires ' + 'less available disk space and is faster.') + parser.add_argument('--ignore-cache', action='store_true', + help='Ignore any previously cached files.') + args = parser.parse_args() + + su_catalog_url = get_default_catalog() + if not su_catalog_url: + print('Could not find a default catalog url for this OS version.', file=sys.stderr) + exit(-1) + + # download sucatalog and look for products that are for macOS installers + catalog = download_and_parse_sucatalog( + su_catalog_url, args.workdir, ignore_cache=args.ignore_cache) + product_info = os_installer_product_info( + catalog, args.workdir, ignore_cache=args.ignore_cache) + + if not product_info: + print('No macOS installer products found in the sucatalog.', file=sys.stderr) + exit(-1) + + product_id, product_title = determine_version(args.version, product_info) + print(product_id, product_title) + + # download all the packages for the selected product + replicate_product(catalog, product_id, args.workdir, ignore_cache=args.ignore_cache, product_title=product_title) + + +if __name__ == '__main__': + main() From 95c7ee6792f6f4ed97e8aecca6bad88f07e97864 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Fri, 26 Mar 2021 11:58:16 +0000 Subject: [PATCH 47/68] Add shields with live image sizes --- CREDITS.md | 2 + README.md | 181 ++++++++++++++++++++++++++++++----------------------- 2 files changed, 106 insertions(+), 77 deletions(-) diff --git a/CREDITS.md b/CREDITS.md index 5f6bf40..979906d 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -67,3 +67,5 @@ This project now uses the fantastic OpenCore bootloader from the community OpenC [@panos](https://github.com/panos) - Improved README #212 [@ggjulio](https://github.com/ggjulio) - Restarting an "auto" container #216 + +[@panos](https://github.com/panos) - Made further improvements to the README #219 diff --git a/README.md b/README.md index c8d0767..0db33be 100644 --- a/README.md +++ b/README.md @@ -14,38 +14,71 @@ Additionally, comprehensive list of all contributors can be found here: https:// Special thanks to [@kholia](https://twitter.com/kholia) for maintaining the upstream project, which Docker-OSX is built on top of: [OSX-KVM](https://github.com/kholia/OSX-KVM). +Big thanks to the OpenCore team over at: https://github.com/acidanthera/OpenCorePkg. Their well-maintained bootloader provides much of the great functionality that Docker-OSX users enjoy :) + +If you like this project, consider contributing here or upstream! + +## Quick Start Docker-OSX + +### Catalina [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/latest?label=sickcodes%2Fdocker-osx%3Alatest](https://img.shields.io/docker/image-size/sickcodes/docker-osx/latest?label=sickcodes%2Fdocker-osx%3Alatest)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) + +```bash +docker run -it \ + --device /dev/kvm \ + -p 50922:10022 \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e "DISPLAY=${DISPLAY:-:0.0}" \ + sickcodes/docker-osx:latest +``` +### Big Sur [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/big-sur?label=sickcodes%2Fdocker-osx%3Abig-sur](https://img.shields.io/docker/image-size/sickcodes/docker-osx/big-sur?label=sickcodes%2Fdocker-osx%3Abig-sur)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) + +```bash +docker run -it \ + --device /dev/kvm \ + -p 50922:10022 \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e "DISPLAY=${DISPLAY:-:0.0}" \ + sickcodes/docker-osx:big-sur +``` + ## Technical details -**Current large image size:** 17.5GB +There currently 4 images, each with different use-cases (explained below): + +[![https://img.shields.io/docker/image-size/sickcodes/docker-osx/latest?label=sickcodes%2Fdocker-osx%3Alatest](https://img.shields.io/docker/image-size/sickcodes/docker-osx/latest?label=sickcodes%2Fdocker-osx%3Alatest)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) + +[![https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked](https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) + +[![https://img.shields.io/docker/image-size/sickcodes/docker-osx/big-sur?label=sickcodes%2Fdocker-osx%3Abig-sur](https://img.shields.io/docker/image-size/sickcodes/docker-osx/big-sur?label=sickcodes%2Fdocker-osx%3Abig-sur)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) + +[![https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto](https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) The images (excluding `:naked`) launch a container with an existing installation with a couple of premade configurations. This special image was developed by [Sick.Codes](https://sick.codes): - username: `user`, password: `alpine` -- ssh enabled (`localhost:50922`) -- vnc enabled (`localhost:8888`) +- SSH enabled (`localhost:50922`) +- VNC enabled (`localhost:8888`) if using ./vnc version +- VNC enabled (`localhost:8888`) if using ./vnc version - auto-updates disabled -- serial number generators! -- x11 forwarding is enabled +- [serial number generator!](https://github.com/sickcodes/osx-serial-generator) +- X11 forwarding is enabled - runs on top of QEMU + KVM -- supports big sur, custom images, xfvb headless mode +- supports Big Sur, custom images, Xvfb headless mode - you can clone your container with `docker commit` ### Requirements -- at least 50 GBs (half for the base image, half for your runtime image -- virtualization should be enabled in your bios settings +- 20GB disk space for bare minimum installation +- virtualization should be enabled in your BIOS settings - a kvm-capable host +- at least 50 GBs for `:auto` (half for the base image, half for your runtime image -### To be done +### TODO - documentation for security researchers - gpu acceleration - support for virt-manager -Big thanks to the OpenCore team over at: https://github.com/acidanthera/OpenCorePkg. Their well-maintained bootloader provides much of the great functionality that Docker-OSX users enjoy :) - -If you like this project, consider contributing upstream! - ## Docker Images built on top of the contents of this repository are also available on **Docker Hub** for convenience: https://hub.docker.com/r/sickcodes/docker-osx @@ -102,31 +135,6 @@ Product names, logos, brands and other trademarks referred to within this projec ## Instructions -#### Quick Start - -```bash -docker pull sickcodes/docker-osx:latest - -# Catalina -docker run -it \ - --device /dev/kvm \ - -p 50922:10022 \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - -e "DISPLAY=${DISPLAY:-:0.0}" \ - sickcodes/docker-osx:latest - -docker pull sickcodes/docker-osx:big-sur -# Big Sur -docker run -it \ - --device /dev/kvm \ - -p 50922:10022 \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - -e "DISPLAY=${DISPLAY:-:0.0}" \ - sickcodes/docker-osx:big-sur - -# Wait 2-3 minutes until the logo appears. -``` - ### Container images There are three different Docker images available, which are suitable for different purposes: **latest**, **auto** and **naked**. @@ -140,7 +148,7 @@ Create your personal image using `:latest`. Then, extract the image. Afterwards, - `sickcodes/docker-osx:auto` - [I'm only interested in using the command line. (Useful for compiling software or using Homebrew headlessly).](https://github.com/sickcodes/Docker-OSX#pre-built-image-arbitrary-command-line-arguments) - `sickcodes/docker-osx:naked` - [I need iMessage/iCloud for security research.](https://github.com/sickcodes/Docker-OSX#serial-numbers) -#### I need video output. +## I need video output. The Quick Start command should work out of the box, provided that you keep the following lines. Works in `auto` & `naked` machines: @@ -149,7 +157,7 @@ The Quick Start command should work out of the box, provided that you keep the f -e "DISPLAY=${DISPLAY:-:0.0}" \ ``` -#### I need to use Docker-OSX headlessly. +## I need to use Docker-OSX headlessly. In that case, **remove** the two lines in your command: @@ -158,7 +166,35 @@ In that case, **remove** the two lines in your command: # -e "DISPLAY=${DISPLAY:-:0.0}" \ ``` -#### I need VNC to a Remote Host (Secure) +## I need VNC on localhost (Local use only!) + +### VNC Insecure + +**Must change -it to -i to be able to interact with the QEMU console** + +Native QEMU VNC example + +```bash +docker run -i \ + --device /dev/kvm \ + -p 50922:10022 \ + -p 5999:5999 \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e "DISPLAY=${DISPLAY:-:0.0}" \ + -e EXTRA="-display none -vnc 0.0.0.0:99,password" \ + sickcodes/docker-osx:big-sur + +# type `change vnc password` into the docker terminal and set a password +# connect to localhost:5999 using VNC +``` + +**NOT TLS/HTTPS Encrypted at all!** + +Or `ssh -N root@1.1.1.1 -L 5999:127.0.0.1:5999`, where `1.1.1.1` is your remote server IP. + +(Note: if you close port 5999 and use the SSH tunnel, this becomes secure.) + +## I need VNC to a Remote Host (Secure) Now you can direct connect VNC to any image! @@ -170,31 +206,14 @@ In the Docker terminal, press `enter` until you see `(qemu)`. Type `change vnc password` -`ip n` will usually show the container IP first. +You also need the container IP: `docker inspect | jq -r '.[0].NetworkSettings.IPAddress'` -Port is `5999`. +Or `ip n` will usually show the container IP first. Now VNC connect using the Docker container IP, for example `172.17.0.2:5999` -You can also find the container IP: `docker inspect | jq -r '.[0].NetworkSettings.IPAddress'` - Remote VNC over SSH: `ssh -N root@1.1.1.1 -L 5999:172.17.0.2:5999`, where `1.1.1.1` is your remote server IP and `172.17.0.2` is your LAN container IP. -#### I need VNC on localhost (Local use only!) - -##### VNC Insecure - -**NOT TLS/HTTPS Encrypted at all!** -``` --p 5999:5999 --e EXTRA="-display none -vnc 0.0.0.0:99,password" -``` -VNC Connect to `localhost:5999`. - -Or `ssh -N root@1.1.1.1 -L 5999:127.0.0.1:5999`, where `1.1.1.1` is your remote server IP. - -(Note: if you close port 5999 and use the SSH tunnel, this becomes secure.) - #### I have used Docker-OSX before and wish to extract my Mac OS X image. Use `docker commit`, copy the ID, and then run `docker start -ai `. @@ -205,21 +224,9 @@ Use `docker commit`, copy the ID, and then run `docker start -ai Date: Sun, 28 Mar 2021 10:17:47 +0000 Subject: [PATCH 48/68] Remove envsubst to allow interactive QEMU using -i --- Dockerfile.auto | 2 +- Dockerfile.naked | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.auto b/Dockerfile.auto index 8175e3e..170029f 100644 --- a/Dockerfile.auto +++ b/Dockerfile.auto @@ -219,7 +219,7 @@ CMD echo "${BOILERPLATE}" \ /usr/bin/ssh-keygen -t rsa -f ~/.ssh/id_docker_osx -q -N "" \ && chmod 600 ~/.ssh/id_docker_osx \ ; } \ - ; envsubst < ./Launch.sh | bash \ + ; /bin/bash -c ./Launch.sh \ & echo "Booting Docker-OSX in the background. Please wait..." \ ; until [[ "$(sshpass -palpine ssh-copy-id -f -i ~/.ssh/id_docker_osx.pub -p 10022 user@127.0.0.1)" ]]; do \ echo "Disk is being copied between layers. Repeating until able to copy SSH key into OSX..." \ diff --git a/Dockerfile.naked b/Dockerfile.naked index 6a5e397..16de510 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -177,4 +177,4 @@ CMD sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ ; } \ - ; ./enable-ssh.sh && envsubst < ./Launch.sh | bash + ; ./enable-ssh.sh && /bin/bash -c ./Launch.sh From bf9a00e679bb5d40a86249ab7d8118b0fb22bb1d Mon Sep 17 00:00:00 2001 From: sickcodes Date: Sun, 28 Mar 2021 10:33:05 +0000 Subject: [PATCH 49/68] Script to build all the images --- tests/test.sh | 300 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 300 insertions(+) create mode 100644 tests/test.sh diff --git a/tests/test.sh b/tests/test.sh new file mode 100644 index 0000000..a8e328b --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,300 @@ +#!/usr/bin/docker +# ____ __ ____ ______ __ +# / __ \____ _____/ /_____ _____/ __ \/ ___/ |/ / +# / / / / __ \/ ___/ //_/ _ \/ ___/ / / /\__ \| / +# / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / | +# /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| TESTS +# +# Title: Docker-OSX (Mac on Docker) +# Author: Sick.Codes https://twitter.com/sickcodes +# Version: 4.2 +# License: GPLv3+ +# Repository: https://github.com/sickcodes/Docker-OSX +# Website: https://sick.codes +# +# Status: Work in progress. +# + +help_text="Usage: ./test.sh --branch --repo + +General options: + --branch, -b Git branch, default is master + --repo, -r Alternative link to build + --mirror-country, -m Two letter country code for Arch mirrors + --docker-username, -u Docker hub username + --docker-password, -p Docker hub password + --vnc-password, -v Choose a VNC passwd. + +Flags + --no-no-cache, -nn Disable --no-cache docker builds + --help, -h, help Display this help and exit +" + +# set -xeuf -o pipefail + +NO_CACHE='--no-cache' + +# gather arguments +while (( "$#" )); do + case "${1}" in + + --help | -h | h | help ) + echo "${help_text}" && exit 0 + ;; + + --branch=* | -b=* ) + export BRANCH="${1#*=}" + shift + ;; + --branch* | -b* ) + export BRANCH="${2}" + shift + shift + ;; + --repo=* | -r=* ) + export REPO="${1#*=}" + shift + ;; + --repo* | -r* ) + export REPO="${2}" + shift + shift + ;; + --mirror-country=* | -m=* ) + export MIRROR_COUNTRY="${1#*=}" + shift + ;; + --mirror-country* | -m* ) + export MIRROR_COUNTRY="${2}" + shift + shift + ;; + --vnc-password=* | -v=* | --vnc-passwd=* ) + export VNC_PASSWORD="${1#*=}" + shift + ;; + --vnc-password* | -v* | --vnc-passwd* ) + export VNC_PASSWORD="${2}" + shift + shift + ;; + --docker-username=* | -u=* ) + export DOCKER_USERNAME="${1#*=}" + shift + ;; + --docker-username* | -u* ) + export DOCKER_USERNAME="${2}" + shift + shift + ;; + --docker-password=* | -p=* ) + export DOCKER_PASSWORD="${1#*=}" + shift + ;; + --docker-password* | -p* ) + export DOCKER_PASSWORD="${2}" + shift + shift + ;; + --no-no-cache | -nn ) + export NO_CACHE= + shift + ;; + *) + echo "Invalid option: ${1}" + exit 1 + ;; + + esac +done + +BRANCH="${BRANCH:=master}" +REPO="${REPO:=https://github.com/sickcodes/Docker-OSX.git}" +VNC_PASSWORD="${VNC_PASSWORD:=testing}" +MIRROR_COUNTRY="${MIRROR_COUNTRY:=US}" + +TEST_BUILDS=( +'docker-osx:latest' +'docker-osx:naked' +'docker-osx:big-sur' +'docker-osx:auto' +#'docker-osx:auto-big-sur' +) + +install_docker () { + apt remove docker docker-engine docker.io containerd runc -y \ + ; apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y \ + && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \ + && apt-key fingerprint 0EBFCD88 \ + && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \ + && apt update -y \ + && apt install docker-ce docker-ce-cli containerd.io -y \ + && usermod -aG docker "${USER}" \ + && su hook docker run --rm hello-world +} + +install_vnc () { + apt update -y \ + && apt install xorg openbox tigervnc-standalone-server tigervnc-common tigervnc-xorg-extension tigervnc-viewer -y \ + && mkdir -p ${HOME}/.vnc \ + && touch ~/.vnc/config \ + && tee -a ~/.vnc/config <<< 'geometry=1920x1080' \ + && tee -a ~/.vnc/config <<< 'localhost' \ + && tee -a ~/.vnc/config <<< 'alwaysshared' \ + && touch ./vnc.sh \ + && printf '\n%s\n' \ + 'sudo rm -f /tmp/.X99-lock' \ + 'export DISPLAY=:99' \ + '/usr/bin/Xvnc -geometry 1920x1080 -rfbauth ~/.vnc/passwd :99 &' > ./vnc.sh \ + && tee vncpasswd_file <<< "${VNC_PASSWORD:=testing}" && echo "${VNC_PASSWORD:="$(tr -dc '[:graph:]' ${HOME}/.vnc/passwd \ + && chmod 600 ~/.vnc/passwd \ + && apt install qemu qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virt-manager -y \ + && sudo systemctl enable libvirtd.service \ + && sudo systemctl enable virtlogd.service \ + && echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs \ + && sudo modprobe kvm \ + && echo 'export DISPLAY=:99' >> ~/.bashrc \ + && printf '\n\n\n\n%s\n%s\n\n\n\n' '===========VNC_PASSWORD========== ' "$( Date: Sun, 28 Mar 2021 11:04:29 +0000 Subject: [PATCH 50/68] Big Sur auto preparations --- tests/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index a8e328b..8323c5c 100644 --- a/tests/test.sh +++ b/tests/test.sh @@ -243,8 +243,8 @@ docker-osx:auto-big-sur () { "${NO_CACHE}" \ --build-arg RANKMIRRORS=true \ --build-arg MIRROR_COUNTRY="${MIRROR_COUNTRY}" \ - --build-arg IMAGE_URL='https://images.sick.codes/mac_hdd_ng_auto_big_sur.img' - -f ./Dockerfile.auto-big-sur \ + --build-arg IMAGE_URL='https://images.sick.codes/mac_hdd_ng_auto_big_sur.img' \ + -f ./Dockerfile.auto \ -t docker-osx:auto-big-sur . docker tag docker-osx:auto-big-sur sickcodes/docker-osx:auto-big-sur } From b161ad7afd0b62a3ff5f5091d6c27321ee752bba Mon Sep 17 00:00:00 2001 From: sickcodes <65906298+sickcodes@users.noreply.github.com> Date: Wed, 31 Mar 2021 09:10:12 +0000 Subject: [PATCH 51/68] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0db33be..6b5583c 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,8 @@ In that case, **remove** the two lines in your command: **Must change -it to -i to be able to interact with the QEMU console** +**To exit a container using -i you must `docker kill `. For example, to kill everything, `docker ps | xargs docker kill`.** + Native QEMU VNC example ```bash From cb6c0e554b1714f07e66a859f7d78fa5728b352d Mon Sep 17 00:00:00 2001 From: kaoudis Date: Sun, 4 Apr 2021 13:47:32 -0600 Subject: [PATCH 52/68] link to KVM docs from GTK error --- README.md | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6b5583c..c480a6c 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ Follow [@sickcodes](https://twitter.com/sickcodes)! ### Professional support -For more sophisticated endeavours, we offer the following support services: +For more sophisticated endeavours, we offer the following support services: - Enterprise support, business support, or casual support. - Custom images, custom scripts, consulting (per hour available!) @@ -324,13 +324,13 @@ docker start -ai -i This is my favourite container. You can supply an existing disk image as a Docker command line argument. -- Pull images out using `sudo find /var/lib/docker -size +10G | grep mac_hdd_ng.img` +- Pull images out using `sudo find /var/lib/docker -size +10G | grep mac_hdd_ng.img` - Supply your own local image with the command argument `-v "${PWD}/mac_hdd_ng.img:/image"` and use `sickcodes/docker-osx:naked` when instructing Docker to create your container. - Naked image is for booting any existing .img file, e.g in the current working directory (`$PWD`) - By default, this image has a variable called `NOPICKER` which is `"true"`. This skips the disk selection menu. Use `-e NOPICKER=false` or any other string than the word `true` to enter the boot menu. - + This lets you use other disks instead of skipping the boot menu, e.g. recovery disk or disk utility. ```bash @@ -496,11 +496,15 @@ docker run \ Big thank you to our contributors who have worked out almost every conceivable issue so far! -### LibGTK - Permission denied - [https://github.com/sickcodes/Docker-OSX/blob/master/CREDITS.md](https://github.com/sickcodes/Docker-OSX/blob/master/CREDITS.md) -#### libgtk permissions denied error +#### LibGTK + +You may see a LibGTK-related error if you do not have everything you need set up for hardware virtualisation yet. If you have not yet done so, check out the [KVM on the host](https://github.com/kaoudis/Docker-OSX#requirements-kvm-on-the-host) section. + +##### LibGTK: permissions denied error + +If you are fully set up with KVM, the issue may be with X11/Xorg: ```bash echo $DISPLAY @@ -549,9 +553,9 @@ Swap: 11Gi 0B 11Gi Of course you cannot allocate more RAM that your have. The default is 3 Gigabytes: `-e RAM=3`. -#### PulseAudio +### PulseAudio -### Use PulseAudio for sound +#### Use PulseAudio for sound Note: [AppleALC](https://github.com/acidanthera/AppleALC), [`alcid`](https://dortania.github.io/OpenCore-Post-Install/universal/audio.html) and [VoodooHDA-OC](https://github.com/chris1111/VoodooHDA-OC) do not have [codec support](https://osy.gitbook.io/hac-mini-guide/details/hda-fix#hda-codec). However, [IORegistryExplorer](https://github.com/vulgo/IORegistryExplorer) does show the controller component working. @@ -576,7 +580,7 @@ docker run \ sickcodes/docker-osx pactl list ``` -#### Nested Hardware Virtualization +### Nested Hardware Virtualization Check if your PC has hardware virtualization enabled: @@ -586,7 +590,7 @@ sudo tee /sys/module/kvm/parameters/ignore_msrs <<< 1 egrep -c '(svm|vmx)' /proc/cpuinfo ``` -### Routine checks +## Routine checks #### Confirm that your CPU supports virtualization @@ -982,7 +986,7 @@ generate-specific-bootdisk.sh \ --output-bootdisk OpenCore-nopicker.qcow2 ``` -# Change Resolution Docker-OSX - change resolution OpenCore OSX-KVM +# Change Resolution Docker-OSX - change resolution OpenCore OSX-KVM The display resolution is controlled by this line: From 42b52e2cc3ec0b068d049d2dd813c822e664b313 Mon Sep 17 00:00:00 2001 From: kaoudis Date: Sun, 4 Apr 2021 16:18:31 -0600 Subject: [PATCH 53/68] move things around for flow and fix up links --- README.md | 949 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 485 insertions(+), 464 deletions(-) diff --git a/README.md b/README.md index c480a6c..ab87b90 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ docker run -it \ ## Technical details -There currently 4 images, each with different use-cases (explained below): +There currently four images, each with different use cases (explained [below](https://github.com/sickcodes/Docker-OSX#container-images)): [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/latest?label=sickcodes%2Fdocker-osx%3Alatest](https://img.shields.io/docker/image-size/sickcodes/docker-osx/latest?label=sickcodes%2Fdocker-osx%3Alatest)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) @@ -103,7 +103,7 @@ Feel free to open an [issue](https://github.com/sickcodes/Docker-OSX/issues/new/ #### Resolved issues -Before you open an issue, however, please check the [closed issues](https://github.com/sickcodes/Docker-OSX/issues?q=is%3Aissue+is%3Aclosed) and confirm that you're using the latest version of this repository — your issues may have already been resolved! +Before you open an issue, however, please check the [closed issues](https://github.com/sickcodes/Docker-OSX/issues?q=is%3Aissue+is%3Aclosed) and confirm that you're using the latest version of this repository — your issues may have already been resolved! You might also see your answer in our questions and answers section [below](https://github.com/sickcodes/Docker-OSX#more-questions-and-answers). ### Feature requests and updates @@ -133,11 +133,13 @@ If you are serious about Apple Security, and possibly finding 6-figure bug bount Product names, logos, brands and other trademarks referred to within this project are the property of their respective trademark holders. These trademark holders are not affiliated with our repository in any capacity. They do not sponsor or endorse this project in any way. -## Instructions +# Instructions -### Container images +## Container images -There are three different Docker images available, which are suitable for different purposes: **latest**, **auto** and **naked**. +### Already set up or just looking to make a container quickly? Check out our [container creation examples](https://github.com/sickcodes/Docker-OSX#container-creation-examples) section. + +There are several different Docker images available, which are suitable for different purposes. - `sickcodes/docker-osx:latest` - [I just want to try it out.](https://github.com/sickcodes/Docker-OSX#quick-start-large-pre-made-image) - `sickcodes/docker-osx:latest` - [I want to use Docker-OSX to develop/secure apps in Xcode (sign into Xcode, Transporter)](https://github.com/sickcodes/Docker-OSX#basic-quick-start-docker-osx) @@ -146,278 +148,13 @@ There are three different Docker images available, which are suitable for differ Create your personal image using `:latest`. Then, extract the image. Afterwards, you will be able to duplicate that image and import it to the `:naked` container, in order to revert the container to a previous state repeatedly. - `sickcodes/docker-osx:auto` - [I'm only interested in using the command line. (Useful for compiling software or using Homebrew headlessly).](https://github.com/sickcodes/Docker-OSX#pre-built-image-arbitrary-command-line-arguments) -- `sickcodes/docker-osx:naked` - [I need iMessage/iCloud for security research.](https://github.com/sickcodes/Docker-OSX#serial-numbers) +- `sickcodes/docker-osx:naked` - [I need iMessage/iCloud for security research.](https://github.com/sickcodes/Docker-OSX#generating-serial-numbers) +- `sickcodes/docker-osx:big-sur` - [I want to run Big Sur.](https://github.com/sickcodes/Docker-OSX#technical-details) -## I need video output. +## Initial setup +Before you do anything else, you will need to turn on hardware virtualization in your BIOS. Precisely how will depend on your particular machine (and BIOS), but it should be straightforward. -The Quick Start command should work out of the box, provided that you keep the following lines. Works in `auto` & `naked` machines: - -``` - -v /tmp/.X11-unix:/tmp/.X11-unix \ - -e "DISPLAY=${DISPLAY:-:0.0}" \ -``` - -## I need to use Docker-OSX headlessly. - -In that case, **remove** the two lines in your command: - -``` - # -v /tmp/.X11-unix:/tmp/.X11-unix \ - # -e "DISPLAY=${DISPLAY:-:0.0}" \ -``` - -## I need VNC on localhost (Local use only!) - -### VNC Insecure - -**Must change -it to -i to be able to interact with the QEMU console** - -**To exit a container using -i you must `docker kill `. For example, to kill everything, `docker ps | xargs docker kill`.** - -Native QEMU VNC example - -```bash -docker run -i \ - --device /dev/kvm \ - -p 50922:10022 \ - -p 5999:5999 \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - -e "DISPLAY=${DISPLAY:-:0.0}" \ - -e EXTRA="-display none -vnc 0.0.0.0:99,password" \ - sickcodes/docker-osx:big-sur - -# type `change vnc password` into the docker terminal and set a password -# connect to localhost:5999 using VNC -``` - -**NOT TLS/HTTPS Encrypted at all!** - -Or `ssh -N root@1.1.1.1 -L 5999:127.0.0.1:5999`, where `1.1.1.1` is your remote server IP. - -(Note: if you close port 5999 and use the SSH tunnel, this becomes secure.) - -## I need VNC to a Remote Host (Secure) - -Now you can direct connect VNC to any image! - -Add the following line: - -`-e EXTRA="-display none -vnc 0.0.0.0:99,password"` - -In the Docker terminal, press `enter` until you see `(qemu)`. - -Type `change vnc password` - -You also need the container IP: `docker inspect | jq -r '.[0].NetworkSettings.IPAddress'` - -Or `ip n` will usually show the container IP first. - -Now VNC connect using the Docker container IP, for example `172.17.0.2:5999` - -Remote VNC over SSH: `ssh -N root@1.1.1.1 -L 5999:172.17.0.2:5999`, where `1.1.1.1` is your remote server IP and `172.17.0.2` is your LAN container IP. - -#### I have used Docker-OSX before and wish to extract my Mac OS X image. - -Use `docker commit`, copy the ID, and then run `docker start -ai `. - -**Alternatively:** - -[Extract the .img file](https://github.com/sickcodes/Docker-OSX#backup-the-disk-wheres-my-disk), and then use that [.img file with :naked](https://github.com/sickcodes/Docker-OSX#quick-start-own-image-naked-container-image) - -#### Further examples - -Apart from the previous examples, there's a myriad of other potential use cases that can work perfectly with Docker-OSX, which you'll see below! - -### Run Catalina Pre-Installed [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto](https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) - -```bash -docker pull sickcodes/docker-osx:auto - -# boot directly into a real OS X shell with a visual display [NOT HEADLESS] -docker run -it \ - --device /dev/kvm \ - -p 50922:10022 \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - -e "DISPLAY=${DISPLAY:-:0.0}" \ - sickcodes/docker-osx:auto - -# username is user -# passsword is alpine -``` - -```bash -docker pull sickcodes/docker-osx:auto - -# boot directly into a real OS X shell with no display (Xvfb) [HEADLESS] -docker run -it \ - --device /dev/kvm \ - -p 50922:10022 \ - sickcodes/docker-osx:auto - -# username is user -# passsword is alpine -# Wait 2-3 minutes until you drop into the shell. -``` - - -### Download the image manually and use it in Docker [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked](https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) - - -This is a particularly good way for downloading the container, in case Docker's CDN (or your connection) happens to be slow. - -```bash -wget https://images2.sick.codes/mac_hdd_ng_auto.img - -docker run -it \ - --device /dev/kvm \ - -p 50922:10022 \ - -v "${PWD}/mac_hdd_ng_auto.img:/image" \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - -e "DISPLAY=${DISPLAY:-:0.0}" \ - sickcodes/docker-osx:naked -``` - -### Use a pre-built image + arbitrary command line arguments. [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto](https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) - -```bash -docker pull sickcodes/docker-osx:auto - -# boot to OS X shell + display + specify commands to run inside OS X! -docker run -it \ - --device /dev/kvm \ - -p 50922:10022 \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - -e "DISPLAY=${DISPLAY:-:0.0}" \ - -e "OSX_COMMANDS=/bin/bash -c \"pwd && uname -a\"" \ - sickcodes/docker-osx:auto - -# Boots in a minute or two! -``` - -### Run Mac OS X headlessly with a custom image [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked](https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) - - -This is particularly helpful for CI/CD pipelines. - -```bash -# run your own image headless + SSH -docker run -it \ - --device /dev/kvm \ - -p 50922:10022 \ - -v "${PWD}/mac_hdd_ng.img:/image" \ - sickcodes/docker-osx:naked -``` - -### Restart a container that starts automatically - -Containers that use `sickcodes/docker-osx:auto` can be stopped while being started. - -```bash -# find last container -docker ps -a - -# docker start old container with -i for interactive, -a for attach STDIN/STDOUT -docker start -ai -i -``` - -### Quick Start your own image (naked container image) - -This is my favourite container. You can supply an existing disk image as a Docker command line argument. - -- Pull images out using `sudo find /var/lib/docker -size +10G | grep mac_hdd_ng.img` - -- Supply your own local image with the command argument `-v "${PWD}/mac_hdd_ng.img:/image"` and use `sickcodes/docker-osx:naked` when instructing Docker to create your container. - - - Naked image is for booting any existing .img file, e.g in the current working directory (`$PWD`) - - By default, this image has a variable called `NOPICKER` which is `"true"`. This skips the disk selection menu. Use `-e NOPICKER=false` or any other string than the word `true` to enter the boot menu. - - This lets you use other disks instead of skipping the boot menu, e.g. recovery disk or disk utility. - -```bash -docker pull sickcodes/docker-osx:naked - -# run your own image + SSH -# change 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}" \ - sickcodes/docker-osx:naked - -# run local copy of the auto image + SSH + Boot menu -docker run -it \ - --device /dev/kvm \ - -p 50922:10022 \ - -v "${PWD}/mac_hdd_ng_auto.img:/image" \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - -e "DISPLAY=${DISPLAY:-:0.0}" \ - -e "NOPICKER=false" \ - sickcodes/docker-osx:naked -``` - -### Run the original version of Docker-OSX - -```bash - -docker pull sickcodes/docker-osx:latest - -docker run -it \ - --device /dev/kvm \ - --device /dev/snd \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - -e "DISPLAY=${DISPLAY:-:0.0}" \ - sickcodes/docker-osx:latest - -# press CTRL + G if your mouse gets stuck -# scroll down to troubleshooting if you have problems -# need more RAM and SSH on localhost -p 50922? -``` - -# Run but enable SSH in OS X (Original Version)! - -```bash -docker run -it \ - --device /dev/kvm \ - --device /dev/snd \ - -p 50922:10022 \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - -e "DISPLAY=${DISPLAY:-:0.0}" \ - sickcodes/docker-osx:latest - -# turn on SSH after you've installed OS X in the "Sharing" settings. -ssh user@localhost -p 50922 -``` - -### Autoboot into OS X after you've installed everything - -You can use `-e NOPICKER=true`. - -Old machines: - -```bash -# find you containerID -docker ps - -# move the no picker script on top of the Launch script -# NEW CONTAINERS -docker exec containerID mv ./Launch-nopicker.sh ./Launch.sh - -# VNC-VERSION-CONTAINER -docker exec containerID mv ./Launch-nopicker.sh ./Launch_custom.sh - -# LEGACY CONTAINERS -docker exec containerID bash -c "grep -v InstallMedia ./Launch.sh > ./Launch-nopicker.sh -chmod +x ./Launch-nopicker.sh -sed -i -e s/OpenCore\.qcow2/OpenCore\-nopicker\.qcow2/ ./Launch-nopicker.sh -" -``` - -# Requirements: KVM on the host -Need to turn on hardware virtualization in your BIOS, very easy to do. - -Then have QEMU on the host if you haven't already +Then, you'll need QEMU and some other dependencies on your host: ```bash # ARCH @@ -428,8 +165,11 @@ sudo apt install qemu qemu-kvm libvirt-clients libvirt-daemon-system bridge-util # CENTOS RHEL FEDORA sudo yum install libvirt qemu-kvm +``` -# then run +Then, enable libvirt and load the KVM kernel module: + +```bash sudo systemctl enable --now libvirtd sudo systemctl enable --now virtlogd @@ -438,7 +178,108 @@ echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs sudo modprobe kvm ``` -# Start the same container later (persistent disk) +## Additional boot instructions for when you are creating your container using whatever [method](https://github.com/sickcodes/Docker-OSX#container-creation-examples) you choose + +- Boot the macOS Base System + +- Click `Disk Utility` + +- Erase the BIGGEST disk (around 200gb default), DO NOT MODIFY THE SMALLER DISKS. +-- if you can't click `erase`, you may need to reduce the disk size by 1kb + +- (optional) Create a partition using the unused space to house the OS and your files if you want to limit the capacity. (For Xcode 12 partition at least 60gb.) + +- Click `Reinstall macOS` + +## Troubleshooting + +### Routine checks + +This is a great place to start if you are having trouble getting going, especially if you're not that familiar with Docker just yet. + +Just looking to make a container quickly? Check out our [container creation examples](https://github.com/sickcodes/Docker-OSX#container-creation-examples) section. + +More specific/advanced troubleshooting questions and answers may be found in [More Questions and Answers](https://github.com/sickcodes/Docker-OSX#more-questions-and-answers). You should also check out the [closed issues](https://github.com/sickcodes/Docker-OSX/issues?q=is%3Aissue+is%3Aclosed). Someone else might have gotten a question like yours answered already even if you can't find it in this document! + +#### Confirm that your CPU supports virtualization + +See [initial setup](https://github.com/sickcodes/Docker-OSX#initial-setup). + +#### Confirm your user is part of the the Docker group, KVM group, libvirt group + +If you use `sudo dockerd` or dockerd is controlled by systemd/systemctl, then you must be in the Docker group. +If you are not in the Docker group: + +```bash +sudo usermod -aG docker "${USER}" +``` +and also add yourself to the kvm and libvirt groups if needed: + +```bash +sudo usermod -aG libvirt "${USER}" +sudo usermod -aG kvm "${USER}" +``` + +See also: [initial setup](https://github.com/sickcodes/Docker-OSX#initial-setup). + +#### Is the docker daemon enabled? + +```bash +# enable it in systemd (it will persist across reboots this way) +sudo systemctl enable --now docker + +# or just start it as your user with systemd instead of enabling it +systemctl start docker + +# or run ad hoc +sudo dockerd + +# or daemonize it +sudo nohup dockerd & +``` + +## More Questions and Answers + +Big thank you to our contributors who have worked out almost every conceivable issue so far! + +[https://github.com/sickcodes/Docker-OSX/blob/master/CREDITS.md](https://github.com/sickcodes/Docker-OSX/blob/master/CREDITS.md) + +### What is `${DISPLAY:-:0.0}`? + +`$DISPLAY` is the shell variable that refers to your X11 display server. + +`${DISPLAY}` is the same, but allows you to join variables like this: + +- e.g. `${DISPLAY}_${DISPLAY}` would print `:0.0_:0.0` +- e.g. `$DISPLAY_$DISPLAY` would print `:0.0` + +...because `$DISPLAY_` is not `$DISPLAY` + +`${variable:-fallback}` allows you to set a "fallback" variable to be substituted if `$variable` is not set. + +You can also use `${variable:=fallback}` to set that variable (in your current terminal). + +In Docker-OSX, we assume, `:0.0` is your default `$DISPLAY` variable. + +You can see what yours is + +```bash +echo $DISPLAY +``` + +That way, `${DISPLAY:-:0.0}` will use whatever variable your X11 server has set for you, else `:0.0` + +### What is `-v /tmp/.X11-unix:/tmp/.X11-unix`? + +`-v` is a Docker command-line option that lets you pass a volume to the container. + +The directory that we are letting the Docker container use is a X server display socket. + +`/tmp/.X11-unix` + +If we let the Docker container use the same display socket as our own environment, then any applications you run inside the Docker container will show up on your screen too! [https://www.x.org/archive/X11R6.8.0/doc/RELNOTES5.html](https://www.x.org/archive/X11R6.8.0/doc/RELNOTES5.html) + +### I have used Docker-OSX before and would like to reuse the same container (persistent disk) 1. You can now pull the `.img` file out of the container, which is stored in `/var/lib/docker`, and supply it as a runtime argument to the `:naked` Docker image. See above. @@ -460,51 +301,33 @@ docker start -ai abc123xyz567 ``` -# Additional Boot Instructions +### I have used Docker-OSX before and would like to extract the Mac OSX image from my container -- Boot the macOS Base System +Use `docker commit`, copy the ID, and then run `docker start -ai `. -- Click `Disk Utility` +**Alternatively:** -- Erase the BIGGEST disk (around 200gb default), DO NOT MODIFY THE SMALLER DISKS. --- if you can't click `erase`, you may need to reduce the disk size by 1kb +[Extract the .img file](https://github.com/sickcodes/Docker-OSX#backup-the-disk-wheres-my-disk), and then use that [.img file with :naked](https://github.com/sickcodes/Docker-OSX#quick-start-own-image-naked-container-image) -- (optional) Create a partition using the unused space to house the OS and your files if you want to limit the capacity. (For Xcode 12 partition at least 60gb.) +### I have used Docker-OSX before and want to restart a container that starts automatically -- Click `Reinstall macOS` +Containers that use `sickcodes/docker-osx:auto` can be stopped while being started. - -## Creating images: ```bash -# You can create an image of an already configured and setup container. -# This allows you to effectively duplicate a system. -# To do this, run the following commands +# find last container +docker ps -a -# make note of your container id -docker ps --all -docker commit containerid newImageName - -# To run this image do the following -docker run \ - --device /dev/kvm \ - --device /dev/snd \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - newImageName +# docker start old container with -i for interactive, -a for attach STDIN/STDOUT +docker start -ai -i ``` -## Troubleshooting +### LibGTK errors -Big thank you to our contributors who have worked out almost every conceivable issue so far! +You may see one or more libgtk-related errors if you do not have everything set up for hardware virtualisation yet. If you have not yet done so, check out the [initial setup](https://github.com/sickcodes/Docker-OSX#initial-setup) section and the [routine checks](https://github.com/sickcodes/Docker-OSX#routine-checks) section as you may have missed a setup step or may not have all the needed Docker dependencies ready to go. -[https://github.com/sickcodes/Docker-OSX/blob/master/CREDITS.md](https://github.com/sickcodes/Docker-OSX/blob/master/CREDITS.md) +#### Permissions denied error -#### LibGTK - -You may see a LibGTK-related error if you do not have everything you need set up for hardware virtualisation yet. If you have not yet done so, check out the [KVM on the host](https://github.com/kaoudis/Docker-OSX#requirements-kvm-on-the-host) section. - -##### LibGTK: permissions denied error - -If you are fully set up with KVM, the issue may be with X11/Xorg: +If you have not yet set up xhost, try the following: ```bash echo $DISPLAY @@ -522,10 +345,13 @@ sudo yum install xorg-x11-server-utils xhost + ``` -#### RAM over-allocation Error -Cause by trying to allocate more ram to the container than you currently have available for allocation: `cannot set up guest memory 'pc.ram': Cannot allocate memory`. -For example: +### RAM over-allocation +You cannot allocate more RAM than your machine has. The default is 3 Gigabytes: `-e RAM=3`. + +If you are trying to allocate more RAM to the container than you currently have available, you may see an error like the following: `cannot set up guest memory 'pc.ram': Cannot allocate memory`. + +For example (below) the `buff/cache` already contains 20 Gigabytes of allocated RAM: ```console [user@hostname ~]$ free -mh @@ -534,15 +360,13 @@ Mem: 30Gi 3.5Gi 7.0Gi 728Mi 20Gi 26Gi Swap: 11Gi 0B 11Gi ``` -In the example above, the `buff/cache` already contains 20 Gigabytes of allocated RAM. - Clear the buffer and the cache: ```bash sudo tee /proc/sys/vm/drop_caches <<< 3 ``` -Now check the ram again: +Now check the RAM again: ```console [user@hostname ~]$ free -mh @@ -551,8 +375,6 @@ Mem: 30Gi 3.3Gi 26Gi 697Mi 1.5Gi 26Gi Swap: 11Gi 0B 11Gi ``` -Of course you cannot allocate more RAM that your have. The default is 3 Gigabytes: `-e RAM=3`. - ### PulseAudio #### Use PulseAudio for sound @@ -580,58 +402,15 @@ docker run \ sickcodes/docker-osx pactl list ``` -### Nested Hardware Virtualization +### Forward additional ports (nginx hosting example) -Check if your PC has hardware virtualization enabled: - -```bash -sudo tee /sys/module/kvm/parameters/ignore_msrs <<< 1 - -egrep -c '(svm|vmx)' /proc/cpuinfo -``` - -## Routine checks - -#### Confirm that your CPU supports virtualization - -#### Add yourself to the Docker group, KVM group, libvirt group. - -If you use `sudo dockerd` or dockerd is controlled by systemd/systemctl, then you must be in the Docker group: - -#### Try adding yourself to the docker group - -```bash -sudo usermod -aG docker "${USER}" -``` -and also to the kvm and libvirt groups: - -```bash -sudo usermod -aG libvirt "${USER}" -sudo usermod -aG kvm "${USER}" -``` - -#### Enable docker daemon - -```bash -# enable it in systemd -sudo systemctl enable --now docker - -# or run ad hoc -sudo dockerd - -# or daemonize it -sudo nohup dockerd & -``` - -#### Forward additional ports (nginx) - -It's possible to forward additional ports depending on your needs. In this example, we're going to use Mac OS X to host nginx in a way that looks like this: +It's possible to forward additional ports depending on your needs. In this example, we'll use Mac OSX to host nginx: ``` host:10023 <-> 10023:container:10023 <-> 80:guest ``` -On the host machine, you should run: +On the host machine, run: ```bash docker run -it \ @@ -642,7 +421,7 @@ docker run -it \ sickcodes/docker-osx:auto ``` -In a Terminal session running the container, you should run: +In a Terminal session running the container, run: ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" @@ -653,9 +432,9 @@ sudo sed -i -e 's/8080/80/' /usr/local/etc/nginx/nginx.confcd sudo nginx ``` -**nginx should now be reachable on the port 10023.** +**nginx should now be reachable on port 10023.** -Additionally, you can string multiple statements, for example: +Additionally, you can string multiple statements together, for example: ```bash -e ADDITIONAL_PORTS='hostfwd=tcp::10023-:80,hostfwd=tcp::10043-:443,' @@ -663,9 +442,11 @@ Additionally, you can string multiple statements, for example: -p 10043:10043 \ ``` -### Enable IPv4 forwarding for bridged network connections +### Enable IPv4 forwarding for bridged network connections for remote installations -This is not required for LOCAL installations and may [cause the host to leak your IP, even if you're using a VPN in the container](https://sick.codes/cve-2020-15590/). +This is not required for LOCAL installations. + +Additionally note it may [cause the host to leak your IP, even if you're using a VPN in the container](https://sick.codes/cve-2020-15590/). However, if you're trying to connect to an instance of Docker-OSX remotely (e.g. an instance of Docker-OSX hosted in a datacenter), this may improve your performance: @@ -688,7 +469,7 @@ nano /etc/sysctl.conf || vi /etc/sysctl.conf || vim /etc/sysctl.conf # now reboot ``` -### Fedora: No internet connectivity with a bridged network +### Fedora: enable internet connectivity with a bridged network Fedora's default firewall settings may prevent Docker's network interface from reaching the internet. In order to reoslve this, you will need to whitelist the interface in your firewall: @@ -698,6 +479,16 @@ sudo firewall-cmd --permanent --zone=trusted --add-interface=docker0 sudo firewall-cmd --reload ``` +### Nested Hardware Virtualization + +Check if your machine has hardware virtualization enabled: + +```bash +sudo tee /sys/module/kvm/parameters/ignore_msrs <<< 1 + +egrep -c '(svm|vmx)' /proc/cpuinfo +``` + ### Virtual network adapters #### Fast internet connectivity @@ -708,24 +499,6 @@ sudo firewall-cmd --reload `-e NETWORKING=e1000-82545em` - -### I'd like to use SPICE instead of VNC - -Optionally, you can enable the SPICE protocol, which allows you to use `remote-viewer` to access it rather than VNC. - -Note: `-disable-ticketing` will allow unauthenticated access to the VM. See the [spice manual](https://www.spice-space.org/spice-user-manual.html) for help setting up authenticated access ("Ticketing"). - -```bash - docker run \ - --device /dev/kvm \ - -p 50922:10022 \ - -e "DISPLAY=${DISPLAY:-:0.0}" \ - -e EXTRA="-monitor telnet::45454,server,nowait -nographic -serial null -spice disable-ticketing,port=3001" \ - mycustomimage -``` - -Then simply do `remote-viewer spice://localhost:3001` and add `--spice-debug` for debugging. - ### CI/CD Related Improvements #### Tips for reducing the size of the image @@ -772,11 +545,11 @@ Then run it with these arguments. mycustomimage ``` -## Setting the appropriate mirrors when building locally +## Setting the appropriate mirrors when building Docker-OSX locally -If you are building Docker-OSX locally, you'd probably want to use Arch Linux's mirrors. +If you are building Docker-OSX locally, you'll probably want to use Arch Linux's mirrors. -Mirror locations can be found here (use 2 letter country codes): https://archlinux.org/mirrorlist/all/ +Mirror locations can be found here (uses two-letter country codes): https://archlinux.org/mirrorlist/all/ ```bash docker build -t docker-osx:latest \ @@ -789,7 +562,7 @@ docker build -t docker-osx:latest \ ### Custom QEMU Arguments (passthrough devices) -Pass any devices/directories to the Docker container & the QEMU arguments using the handy `-e EXTRA=` runtime options. +Pass any devices/directories to the Docker container & the QEMU arguments using the handy runtime argument provider option `-e EXTRA=`. ```bash # example customizations @@ -813,18 +586,69 @@ docker run \ ### Generating serial numbers -For serial numbers, generate them in `./custom` OR make docker generate them at runtime (see below). +Generate serial numbers in `./custom` OR make docker generate them at runtime (see below). -At any time, verify your serial number before logging in iCloud, etc. +At any time, verify your serial number before logging into iCloud, etc. ```bash -# this is a quick way to check your serial number via cli inside OS X +# this is a quick way to check your serial number via cli inside OSX ioreg -l | grep IOPlatformSerialNumber # or from the host sshpass -p 'alpine' ssh user@localhost -p 50922 'ioreg -l | grep IOPlatformSerialNumber' ``` -# This example generates a random set of serial numbers at runtime, headlessly + +#### Getting started with serial numbers + +```bash +# ARCH +pacman -S libguestfs + +# UBUNTU DEBIAN +apt install libguestfs -y + +# RHEL FEDORA CENTOS +yum install libguestfs -y +``` + +Inside the `./custom` folder you will find `4` scripts. + +- `config-nopicker-custom.plist` +- `opencore-image-ng.sh` + +These two files are from OSX-KVM. + +You don't need to touch these two files. + +The config.plist has 5 values replaced with placeholders. [Click here to see those values for no reason.](https://github.com/sickcodes/Docker-OSX/blob/master/custom/config-nopicker-custom.plist#L705) + +- `generate-unique-machine-values.sh` +This script will generate serial numbers, with Mac Addresses, plus output to CSV/TSV, plus make a `bootdisk image`. + +You can create hundreds, `./custom/generate-unique-machine-values.sh --help` + +```bash +./custom/generate-unique-machine-values.sh \ + --count 1 \ + --tsv ./serial.tsv \ + --bootdisks \ + --output-bootdisk OpenCore.qcow2 \ + --output-env source.env.sh +``` + +Or if you have some specific serial numbers... + +- `generate-specific-bootdisk.sh` +```bash +generate-specific-bootdisk.sh \ + --model "${DEVICE_MODEL}" \ + --serial "${SERIAL}" \ + --board-serial "${BOARD_SERIAL}" \ + --uuid "${UUID}" \ + --mac-address "${MAC_ADDRESS}" \ + --output-bootdisk OpenCore-nopicker.qcow2 +``` +#### This example generates a random set of serial numbers at runtime, headlessly ```bash # proof of concept only, generates random serial numbers, headlessly, and quits right after. @@ -838,7 +662,7 @@ docker run --rm -it \ sickcodes/docker-osx:auto ``` -# This example generates a specific set of serial numbers at runtime +#### This example generates a specific set of serial numbers at runtime ```bash # run the same as above 17gb auto image, with SSH, with nopicker, and save the bootdisk for later. @@ -940,53 +764,7 @@ Or tell the container to use specific ones using `-e GENERATE_SPECIFIC=true` -e MAC_ADDRESS="A8:5C:2C:9A:46:2F" \ ``` -#### How to obtain serial numbers - -```bash -apt install libguestfs -y -pacman -S libguestfs -yum install libguestfs -y -``` - -Inside the `./custom` folder you will find `4` scripts. - -- `config-nopicker-custom.plist` -- `opencore-image-ng.sh` - -These two files are from OSX-KVM. - -You don't need to touch these two files. - -The config.plist has 5 values replaced with placeholders. [Click here to see those values for no reason.](https://github.com/sickcodes/Docker-OSX/blob/master/custom/config-nopicker-custom.plist#L705) - -- `generate-unique-machine-values.sh` -This script will generate serial numbers, with Mac Addresses, plus output to CSV/TSV, plus make a `bootdisk image`. - -You can create hundreds, `./custom/generate-unique-machine-values.sh --help` - -```bash -./custom/generate-unique-machine-values.sh \ - --count 1 \ - --tsv ./serial.tsv \ - --bootdisks \ - --output-bootdisk OpenCore.qcow2 \ - --output-env source.env.sh -``` - -Or if you have some specific serial numbers... - -- `generate-specific-bootdisk.sh` -```bash -generate-specific-bootdisk.sh \ - --model "${DEVICE_MODEL}" \ - --serial "${SERIAL}" \ - --board-serial "${BOARD_SERIAL}" \ - --uuid "${UUID}" \ - --mac-address "${MAC_ADDRESS}" \ - --output-bootdisk OpenCore-nopicker.qcow2 -``` - -# Change Resolution Docker-OSX - change resolution OpenCore OSX-KVM +### Change Resolution Docker-OSX - change resolution OpenCore OSX-KVM The display resolution is controlled by this line: @@ -1014,7 +792,7 @@ It will take around 30 seconds longer to boot because it needs to make a new boo -e MAC_ADDRESS="" \ ``` -## Change Docker-OSX Resolution Examples +#### Change Docker-OSX Resolution Examples ```bash # using an image in your current directory @@ -1051,7 +829,6 @@ docker run -it \ sickcodes/docker-osx:latest ``` - Here's a few other resolutions! If you resolution is invalid, it will default to 800x600. ``` @@ -1166,37 +943,281 @@ You should see the device show up when you do `system_profiler SPUSBDataType` in Important Note: this will cause the host system to lose access to the USB device while the VM is running! -#### What is `${DISPLAY:-:0.0}`? +## Container creation examples -`$DISPLAY` is the shell variable that refers to your X11 display server. +#### Quick Start your own image (naked container image) -`${DISPLAY}` is the same, but allows you to join variables like this: +This is my favourite container. You can supply an existing disk image as a Docker command line argument. -- e.g. `${DISPLAY}_${DISPLAY}` would print `:0.0_:0.0` -- e.g. `$DISPLAY_$DISPLAY` would print `:0.0` +- Pull images out using `sudo find /var/lib/docker -size +10G | grep mac_hdd_ng.img` -...because `$DISPLAY_` is not `$DISPLAY` +- Supply your own local image with the command argument `-v "${PWD}/mac_hdd_ng.img:/image"` and use `sickcodes/docker-osx:naked` when instructing Docker to create your container. -`${variable:-fallback}` allows you to set a "fallback" variable to be substituted if `$variable` is not set. + - Naked image is for booting any existing .img file, e.g in the current working directory (`$PWD`) + - By default, this image has a variable called `NOPICKER` which is `"true"`. This skips the disk selection menu. Use `-e NOPICKER=false` or any other string than the word `true` to enter the boot menu. -You can also use `${variable:=fallback}` to set that variable (in your current terminal). - -In Docker-OSX, we assume, `:0.0` is your default `$DISPLAY` variable. - -You can see what yours is + This lets you use other disks instead of skipping the boot menu, e.g. recovery disk or disk utility. ```bash -echo $DISPLAY +docker pull sickcodes/docker-osx:naked + +# run your own image + SSH +# change 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}" \ + sickcodes/docker-osx:naked + +# run local copy of the auto image + SSH + Boot menu +docker run -it \ + --device /dev/kvm \ + -p 50922:10022 \ + -v "${PWD}/mac_hdd_ng_auto.img:/image" \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e "DISPLAY=${DISPLAY:-:0.0}" \ + -e "NOPICKER=false" \ + sickcodes/docker-osx:naked ``` -That way, `${DISPLAY:-:0.0}` will use whatever variable your X11 server has set for you, else `:0.0` +### Building an OSX container with video output -#### What is `-v /tmp/.X11-unix:/tmp/.X11-unix`? +The Quick Start command should work out of the box, provided that you keep the following lines. Works in `auto` & `naked` machines: -`-v` is a Docker command-line option that lets you pass a volume to the container. +``` + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e "DISPLAY=${DISPLAY:-:0.0}" \ +``` -The directory that we are letting the Docker container use is a X server display socket. +#### Download the image manually and use it in Docker [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked](https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) -`/tmp/.X11-unix` -If we let the Docker container use the same display socket as our own environment, then any applications you run inside the Docker container will show up on your screen too! [https://www.x.org/archive/X11R6.8.0/doc/RELNOTES5.html](https://www.x.org/archive/X11R6.8.0/doc/RELNOTES5.html) +This is a particularly good way for downloading the container, in case Docker's CDN (or your connection) happens to be slow. + +```bash +wget https://images2.sick.codes/mac_hdd_ng_auto.img + +docker run -it \ + --device /dev/kvm \ + -p 50922:10022 \ + -v "${PWD}/mac_hdd_ng_auto.img:/image" \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e "DISPLAY=${DISPLAY:-:0.0}" \ + sickcodes/docker-osx:naked +``` + +#### Use a pre-built image + arbitrary command line arguments. [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto](https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) + +```bash +docker pull sickcodes/docker-osx:auto + +# boot to OS X shell + display + specify commands to run inside OS X! +docker run -it \ + --device /dev/kvm \ + -p 50922:10022 \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e "DISPLAY=${DISPLAY:-:0.0}" \ + -e "OSX_COMMANDS=/bin/bash -c \"pwd && uname -a\"" \ + sickcodes/docker-osx:auto + +# Boots in a minute or two! +``` + +### Further examples + +There's a myriad of other potential use cases that can work perfectly with Docker-OSX, some of which you'll see below! + +### Building a headless OSX container + +For a headless container, **remove** the following two lines from your `docker run` command: + +``` + # -v /tmp/.X11-unix:/tmp/.X11-unix \ + # -e "DISPLAY=${DISPLAY:-:0.0}" \ +``` + +#### Building a headless container from a custom image [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked](https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) + +This is particularly helpful for CI/CD pipelines. + +```bash +# run your own image headless + SSH +docker run -it \ + --device /dev/kvm \ + -p 50922:10022 \ + -v "${PWD}/mac_hdd_ng.img:/image" \ + sickcodes/docker-osx:naked +``` + +### Building a headless container which allows insecure VNC on localhost (!for local use only!) + +**Must change -it to -i to be able to interact with the QEMU console** + +**To exit a container using -i you must `docker kill `. For example, to kill everything, `docker ps | xargs docker kill`.** + +Native QEMU VNC example + +```bash +docker run -i \ + --device /dev/kvm \ + -p 50922:10022 \ + -p 5999:5999 \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e "DISPLAY=${DISPLAY:-:0.0}" \ + -e EXTRA="-display none -vnc 0.0.0.0:99,password" \ + sickcodes/docker-osx:big-sur + +# type `change vnc password` into the docker terminal and set a password +# connect to localhost:5999 using VNC +``` + +**NOT TLS/HTTPS Encrypted at all!** + +Or `ssh -N root@1.1.1.1 -L 5999:127.0.0.1:5999`, where `1.1.1.1` is your remote server IP. + +(Note: if you close port 5999 and use the SSH tunnel, this becomes secure.) + +### Building a headless container to run remotely with secure VNC + +Add the following line: + +`-e EXTRA="-display none -vnc 0.0.0.0:99,password"` + +In the Docker terminal, press `enter` until you see `(qemu)`. + +Type `change vnc password` + +You also need the container IP: `docker inspect | jq -r '.[0].NetworkSettings.IPAddress'` + +Or `ip n` will usually show the container IP first. + +Now VNC connect using the Docker container IP, for example `172.17.0.2:5999` + +Remote VNC over SSH: `ssh -N root@1.1.1.1 -L 5999:172.17.0.2:5999`, where `1.1.1.1` is your remote server IP and `172.17.0.2` is your LAN container IP. + +Now you can direct connect VNC to any container built with this command! + +### I'd like to use SPICE instead of VNC + +Optionally, you can enable the SPICE protocol, which allows use of `remote-viewer` to access your OSX container rather than VNC. + +Note: `-disable-ticketing` will allow unauthenticated access to the VM. See the [spice manual](https://www.spice-space.org/spice-user-manual.html) for help setting up authenticated access ("Ticketing"). + +```bash + docker run \ + --device /dev/kvm \ + -p 50922:10022 \ + -e "DISPLAY=${DISPLAY:-:0.0}" \ + -e EXTRA="-monitor telnet::45454,server,nowait -nographic -serial null -spice disable-ticketing,port=3001" \ + mycustomimage +``` + +Then simply do `remote-viewer spice://localhost:3001` and add `--spice-debug` for debugging. + +#### Creating images based on an already configured and set up container +```bash +# You can create an image of an already configured and setup container. +# This allows you to effectively duplicate a system. +# To do this, run the following commands + +# make note of your container id +docker ps --all +docker commit containerid newImageName + +# To run this image do the following +docker run \ + --device /dev/kvm \ + --device /dev/snd \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + newImageName +``` + +#### Run Catalina Pre-Installed [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto](https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) + +```bash +docker pull sickcodes/docker-osx:auto + +# boot directly into a real OS X shell with a visual display [NOT HEADLESS] +docker run -it \ + --device /dev/kvm \ + -p 50922:10022 \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e "DISPLAY=${DISPLAY:-:0.0}" \ + sickcodes/docker-osx:auto + +# username is user +# passsword is alpine +``` + +```bash +docker pull sickcodes/docker-osx:auto + +# boot directly into a real OS X shell with no display (Xvfb) [HEADLESS] +docker run -it \ + --device /dev/kvm \ + -p 50922:10022 \ + sickcodes/docker-osx:auto + +# username is user +# passsword is alpine +# Wait 2-3 minutes until you drop into the shell. +``` + +#### Run the original version of Docker-OSX + +```bash + +docker pull sickcodes/docker-osx:latest + +docker run -it \ + --device /dev/kvm \ + --device /dev/snd \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e "DISPLAY=${DISPLAY:-:0.0}" \ + sickcodes/docker-osx:latest + +# press CTRL + G if your mouse gets stuck +# scroll down to troubleshooting if you have problems +# need more RAM and SSH on localhost -p 50922? +``` + +#### Run but enable SSH in OS X (Original Version)! + +```bash +docker run -it \ + --device /dev/kvm \ + --device /dev/snd \ + -p 50922:10022 \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e "DISPLAY=${DISPLAY:-:0.0}" \ + sickcodes/docker-osx:latest + +# turn on SSH after you've installed OS X in the "Sharing" settings. +ssh user@localhost -p 50922 +``` + +#### Autoboot into OS X after you've installed everything + +Add the extra option `-e NOPICKER=true`. + +Old machines: + +```bash +# find your containerID +docker ps + +# move the no picker script on top of the Launch script +# NEW CONTAINERS +docker exec containerID mv ./Launch-nopicker.sh ./Launch.sh + +# VNC-VERSION-CONTAINER +docker exec containerID mv ./Launch-nopicker.sh ./Launch_custom.sh + +# LEGACY CONTAINERS +docker exec containerID bash -c "grep -v InstallMedia ./Launch.sh > ./Launch-nopicker.sh +chmod +x ./Launch-nopicker.sh +sed -i -e s/OpenCore\.qcow2/OpenCore\-nopicker\.qcow2/ ./Launch-nopicker.sh +" +``` From e9ec998332f9bed4df554af3d2e9222f313156ce Mon Sep 17 00:00:00 2001 From: kaoudis Date: Mon, 5 Apr 2021 10:37:42 -0600 Subject: [PATCH 54/68] couple minor formatting corrections --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ab87b90..9bc6de6 100644 --- a/README.md +++ b/README.md @@ -178,7 +178,7 @@ echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs sudo modprobe kvm ``` -## Additional boot instructions for when you are creating your container using whatever [method](https://github.com/sickcodes/Docker-OSX#container-creation-examples) you choose +## Additional boot instructions for when you are [creating your container](https://github.com/sickcodes/Docker-OSX#container-creation-examples) - Boot the macOS Base System @@ -545,7 +545,7 @@ Then run it with these arguments. mycustomimage ``` -## Setting the appropriate mirrors when building Docker-OSX locally +### What mirrors are appropriate to use to build Docker-OSX locally? If you are building Docker-OSX locally, you'll probably want to use Arch Linux's mirrors. @@ -856,7 +856,7 @@ Here's a few other resolutions! If you resolution is invalid, it will default to -e HEIGHT=1600 \ ``` -### Mounting physical disks in Mac OS X +### Mounting physical disks in Mac OSX Pass the disk into the container as a volume and then pass the disk again into QEMU command line extras with. @@ -871,7 +871,7 @@ DISK_TWO="${PWD}/mount_me.img" -e EXTRA='-device ide-hd,bus=sata.5,drive=DISK-TWO -drive id=DISK-TWO,if=none,file=/disktwo,format=qcow2' \ ``` -### Example +#### Physical disk mounting example ```bash OSX_IMAGE="${PWD}/mac_hdd_ng_xcode_bigsur.img" @@ -890,9 +890,9 @@ docker run -it \ ### USB Passthrough -The simplest way to do this is the following: +Firstly, QEMU must be started as root. -First of all, in order to do this, QEMU must be started as root. It is also potentially possible to do this by changing the permissions of the device in the container. +It is also potentially possible to accomplish USB passthrough by changing the permissions of the device in the container. See [here](https://www.linuxquestions.org/questions/slackware-14/qemu-usb-permissions-744557/#post3628691). For example, create a new Dockerfile with the following @@ -906,7 +906,7 @@ COPY --chown=arch ./new_image.img /home/arch/OSX-KVM/mac_hdd_ng.img Where `new_image.img` is the qcow2 image you extracted. Then rebuild with `docker build .` -Find out the bus and port numbers of your USB device which you want to pass through to the VM. +Next we need to find out the bus and port numbers of the USB device we want to pass through to the VM: ```bash lsusb -t @@ -1008,7 +1008,7 @@ docker run -it \ sickcodes/docker-osx:naked ``` -#### Use a pre-built image + arbitrary command line arguments. [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto](https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) +#### Use a prebuilt image with arbitrary command line arguments [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto](https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) ```bash docker pull sickcodes/docker-osx:auto From ee587a69634131fa82f575f0637656c5e2e70121 Mon Sep 17 00:00:00 2001 From: kaoudis Date: Mon, 5 Apr 2021 11:31:25 -0600 Subject: [PATCH 55/68] adds some of the more recent notable closed question issues --- README.md | 50 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 9bc6de6..1bc7639 100644 --- a/README.md +++ b/README.md @@ -244,6 +244,10 @@ Big thank you to our contributors who have worked out almost every conceivable i [https://github.com/sickcodes/Docker-OSX/blob/master/CREDITS.md](https://github.com/sickcodes/Docker-OSX/blob/master/CREDITS.md) +### The big-sur image starts slowly after installation. Is this expected? + +Automatic updates are still on in the container's settings. You may wish to turn them off. [We have future plans for development around this.](https://github.com/sickcodes/Docker-OSX/issues/227) + ### What is `${DISPLAY:-:0.0}`? `$DISPLAY` is the shell variable that refers to your X11 display server. @@ -279,13 +283,22 @@ The directory that we are letting the Docker container use is a X server display If we let the Docker container use the same display socket as our own environment, then any applications you run inside the Docker container will show up on your screen too! [https://www.x.org/archive/X11R6.8.0/doc/RELNOTES5.html](https://www.x.org/archive/X11R6.8.0/doc/RELNOTES5.html) -### I have used Docker-OSX before and would like to reuse the same container (persistent disk) +### ALSA errors on startup or container creation -1. You can now pull the `.img` file out of the container, which is stored in `/var/lib/docker`, and supply it as a runtime argument to the `:naked` Docker image. See above. +You may when initialising or booting into a container see errors from the `(qemu)` console of the following form: +`ALSA lib blahblahblah: (function name) returned error: no such file or directory`. These are more or less expected. As long as you are able to boot into the container and everything is working, no reason to worry about these. -2. This is for when you want to run the SAME container again later. +See also: [here](https://github.com/sickcodes/Docker-OSX/issues/174). -If you don't run this you will have a new image every time. +### Start the same container later (persistent disk) + +Created a container with `docker run` and want to reuse the underlying image again later? + +See [container creation examples](https://github.com/sickcodes/Docker-OSX#container-creation-examples) for how to get to the point where this is applicable. + +This is for when you want to run the SAME container again later. You may need to use `docker commit` to save your container before you can reuse it. Check if your container is persisted with `docker ps --all`. + +If you don't run this you will have a new image every time. ```bash # look at your recent containers and copy the CONTAINER ID @@ -301,13 +314,9 @@ docker start -ai abc123xyz567 ``` -### I have used Docker-OSX before and would like to extract the Mac OSX image from my container +You can also pull the `.img` file out of the container, which is stored in `/var/lib/docker`, and supply it as a runtime argument to the `:naked` Docker image. -Use `docker commit`, copy the ID, and then run `docker start -ai `. - -**Alternatively:** - -[Extract the .img file](https://github.com/sickcodes/Docker-OSX#backup-the-disk-wheres-my-disk), and then use that [.img file with :naked](https://github.com/sickcodes/Docker-OSX#quick-start-own-image-naked-container-image) +See also: [here](https://github.com/sickcodes/Docker-OSX/issues/197). ### I have used Docker-OSX before and want to restart a container that starts automatically @@ -325,6 +334,8 @@ docker start -ai -i You may see one or more libgtk-related errors if you do not have everything set up for hardware virtualisation yet. If you have not yet done so, check out the [initial setup](https://github.com/sickcodes/Docker-OSX#initial-setup) section and the [routine checks](https://github.com/sickcodes/Docker-OSX#routine-checks) section as you may have missed a setup step or may not have all the needed Docker dependencies ready to go. +See also: [here](https://github.com/sickcodes/Docker-OSX/issues/174). + #### Permissions denied error If you have not yet set up xhost, try the following: @@ -349,7 +360,7 @@ xhost + ### RAM over-allocation You cannot allocate more RAM than your machine has. The default is 3 Gigabytes: `-e RAM=3`. -If you are trying to allocate more RAM to the container than you currently have available, you may see an error like the following: `cannot set up guest memory 'pc.ram': Cannot allocate memory`. +If you are trying to allocate more RAM to the container than you currently have available, you may see an error like the following: `cannot set up guest memory 'pc.ram': Cannot allocate memory`. See also: [here](https://github.com/sickcodes/Docker-OSX/issues/188), [here](https://github.com/sickcodes/Docker-OSX/pull/189). For example (below) the `buff/cache` already contains 20 Gigabytes of allocated RAM: @@ -442,6 +453,12 @@ Additionally, you can string multiple statements together, for example: -p 10043:10043 \ ``` +### Bridged networking + +You might not need to do anything with the default setup to enable internet connectivity from inside the container. Additionally, `curl` may work even if `ping` doesn't. + +See discussion [here](https://github.com/sickcodes/Docker-OSX/issues/177) and [here](https://github.com/sickcodes/Docker-OSX/issues/72) and [here](https://github.com/sickcodes/Docker-OSX/issues/88). + ### Enable IPv4 forwarding for bridged network connections for remote installations This is not required for LOCAL installations. @@ -764,7 +781,14 @@ Or tell the container to use specific ones using `-e GENERATE_SPECIFIC=true` -e MAC_ADDRESS="A8:5C:2C:9A:46:2F" \ ``` -### Change Resolution Docker-OSX - change resolution OpenCore OSX-KVM +### I'd like to run Docker-OSX with WSL2 (Windows, Ubuntu) + +Ensure KVM is enabled and `x11-apps` is installed. + +See more in-depth discussion [here](https://github.com/sickcodes/Docker-OSX/issues/17) and [here](https://github.com/sickcodes/Docker-OSX/issues/60). + + +### Changing display resolution The display resolution is controlled by this line: @@ -888,6 +912,8 @@ docker run -it \ sickcodes/docker-osx:naked ``` +See also: [here](https://github.com/sickcodes/Docker-OSX/issues/222). + ### USB Passthrough Firstly, QEMU must be started as root. From 6e50ac14ee5ac9a040ff39effcccc1fe1831a76b Mon Sep 17 00:00:00 2001 From: kaoudis Date: Mon, 5 Apr 2021 12:27:49 -0600 Subject: [PATCH 56/68] at least the important-ish links work now --- README.md | 57 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 1bc7639..db5c4ee 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ If you like this project, consider contributing here or upstream! ## Quick Start Docker-OSX +First time here? try [initial setup](#initial-setup), otherwise try the instructions below to use either Catalina or Big Sur. + ### Catalina [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/latest?label=sickcodes%2Fdocker-osx%3Alatest](https://img.shields.io/docker/image-size/sickcodes/docker-osx/latest?label=sickcodes%2Fdocker-osx%3Alatest)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) ```bash @@ -43,7 +45,7 @@ docker run -it \ ## Technical details -There currently four images, each with different use cases (explained [below](https://github.com/sickcodes/Docker-OSX#container-images)): +There currently four images, each with different use cases (explained [below](#container-images)): [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/latest?label=sickcodes%2Fdocker-osx%3Alatest](https://img.shields.io/docker/image-size/sickcodes/docker-osx/latest?label=sickcodes%2Fdocker-osx%3Alatest)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) @@ -53,8 +55,9 @@ There currently four images, each with different use cases (explained [below](ht [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto](https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) -The images (excluding `:naked`) launch a container with an existing installation with a couple of premade configurations. This special image was developed by [Sick.Codes](https://sick.codes): +This special set of images was developed by [Sick.Codes](https://sick.codes). +The images (excluding `:naked`) launch a container with an existing installation with a couple of premade configurations: - username: `user`, password: `alpine` - SSH enabled (`localhost:50922`) - VNC enabled (`localhost:8888`) if using ./vnc version @@ -83,7 +86,7 @@ The images (excluding `:naked`) launch a container with an existing installation Images built on top of the contents of this repository are also available on **Docker Hub** for convenience: https://hub.docker.com/r/sickcodes/docker-osx -A comprehensive list of the available Docker images and their intended purpose can be found in the [Instructions](README.md#Instructions). +A comprehensive list of the available Docker images and their intended purpose can be found in the [Instructions](#instructions). ## Kubernetes @@ -103,7 +106,7 @@ Feel free to open an [issue](https://github.com/sickcodes/Docker-OSX/issues/new/ #### Resolved issues -Before you open an issue, however, please check the [closed issues](https://github.com/sickcodes/Docker-OSX/issues?q=is%3Aissue+is%3Aclosed) and confirm that you're using the latest version of this repository — your issues may have already been resolved! You might also see your answer in our questions and answers section [below](https://github.com/sickcodes/Docker-OSX#more-questions-and-answers). +Before you open an issue, however, please check the [closed issues](https://github.com/sickcodes/Docker-OSX/issues?q=is%3Aissue+is%3Aclosed) and confirm that you're using the latest version of this repository — your issues may have already been resolved! You might also see your answer in our questions and answers section [below](#more-questions-and-answers). ### Feature requests and updates @@ -129,7 +132,7 @@ Docker-OSX is licensed under the [GPL v3+](LICENSE). Contributions are welcomed ## Disclaimer -If you are serious about Apple Security, and possibly finding 6-figure bug bounties within the Apple Bug Bounty Program, then you're in the right place! Further notes: [Is Hackintosh, OSX-KVM, or Docker-OSX legal?](https://sick.codes/is-hackintosh-osx-kvm-or-docker-osx-legal/). +If you are serious about Apple Security, and possibly finding 6-figure bug bounties within the Apple Bug Bounty Program, then you're in the right place! Further notes: [Is Hackintosh, OSX-KVM, or Docker-OSX legal?](https://sick.codes/is-hackintosh-osx-kvm-or-docker-osx-legal/) Product names, logos, brands and other trademarks referred to within this project are the property of their respective trademark holders. These trademark holders are not affiliated with our repository in any capacity. They do not sponsor or endorse this project in any way. @@ -137,19 +140,19 @@ Product names, logos, brands and other trademarks referred to within this projec ## Container images -### Already set up or just looking to make a container quickly? Check out our [container creation examples](https://github.com/sickcodes/Docker-OSX#container-creation-examples) section. +### Already set up or just looking to make a container quickly? Check out our [quick start](#quick-start-docker-osx) or see a bunch more use cases under our [container creation examples](#container-creation-examples) section. -There are several different Docker images available, which are suitable for different purposes. +There are several different Docker-OSX images available which are suitable for different purposes. -- `sickcodes/docker-osx:latest` - [I just want to try it out.](https://github.com/sickcodes/Docker-OSX#quick-start-large-pre-made-image) -- `sickcodes/docker-osx:latest` - [I want to use Docker-OSX to develop/secure apps in Xcode (sign into Xcode, Transporter)](https://github.com/sickcodes/Docker-OSX#basic-quick-start-docker-osx) -- `sickcodes/docker-osx:naked` - [I want to use Docker-OSX for CI/CD-related purposes (sign into Xcode, Transporter)](https://github.com/sickcodes/Docker-OSX#fully-headless-using-my-own-image-for-cicd) +- `sickcodes/docker-osx:latest` - [I just want to try it out.](#quick-start-docker-osx) +- `sickcodes/docker-osx:latest` - [I want to use Docker-OSX to develop/secure apps in Xcode (sign into Xcode, Transporter)](#quick-start-your-own-image-naked-container-image) +- `sickcodes/docker-osx:naked` - [I want to use Docker-OSX for CI/CD-related purposes (sign into Xcode, Transporter)](#building-a-headless-container-from-a-custom-image) Create your personal image using `:latest`. Then, extract the image. Afterwards, you will be able to duplicate that image and import it to the `:naked` container, in order to revert the container to a previous state repeatedly. -- `sickcodes/docker-osx:auto` - [I'm only interested in using the command line. (Useful for compiling software or using Homebrew headlessly).](https://github.com/sickcodes/Docker-OSX#pre-built-image-arbitrary-command-line-arguments) -- `sickcodes/docker-osx:naked` - [I need iMessage/iCloud for security research.](https://github.com/sickcodes/Docker-OSX#generating-serial-numbers) -- `sickcodes/docker-osx:big-sur` - [I want to run Big Sur.](https://github.com/sickcodes/Docker-OSX#technical-details) +- `sickcodes/docker-osx:auto` - [I'm only interested in using the command line (useful for compiling software or using Homebrew headlessly).](#prebuilt-image-with-arbitrary-command-line-arguments) +- `sickcodes/docker-osx:naked` - [I need iMessage/iCloud for security research.](#generating-serial-numbers) +- `sickcodes/docker-osx:big-sur` - [I want to run Big Sur.](#quick-start-docker-osx) ## Initial setup Before you do anything else, you will need to turn on hardware virtualization in your BIOS. Precisely how will depend on your particular machine (and BIOS), but it should be straightforward. @@ -178,7 +181,7 @@ echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs sudo modprobe kvm ``` -## Additional boot instructions for when you are [creating your container](https://github.com/sickcodes/Docker-OSX#container-creation-examples) +## Additional boot instructions for when you are [creating your container](#container-creation-examples) - Boot the macOS Base System @@ -197,13 +200,13 @@ sudo modprobe kvm This is a great place to start if you are having trouble getting going, especially if you're not that familiar with Docker just yet. -Just looking to make a container quickly? Check out our [container creation examples](https://github.com/sickcodes/Docker-OSX#container-creation-examples) section. +Just looking to make a container quickly? Check out our [container creation examples](#container-creation-examples) section. -More specific/advanced troubleshooting questions and answers may be found in [More Questions and Answers](https://github.com/sickcodes/Docker-OSX#more-questions-and-answers). You should also check out the [closed issues](https://github.com/sickcodes/Docker-OSX/issues?q=is%3Aissue+is%3Aclosed). Someone else might have gotten a question like yours answered already even if you can't find it in this document! +More specific/advanced troubleshooting questions and answers may be found in [More Questions and Answers](#more-questions-and-answers). You should also check out the [closed issues](https://github.com/sickcodes/Docker-OSX/issues?q=is%3Aissue+is%3Aclosed). Someone else might have gotten a question like yours answered already even if you can't find it in this document! #### Confirm that your CPU supports virtualization -See [initial setup](https://github.com/sickcodes/Docker-OSX#initial-setup). +See [initial setup](#initial-setup). #### Confirm your user is part of the the Docker group, KVM group, libvirt group @@ -220,7 +223,7 @@ sudo usermod -aG libvirt "${USER}" sudo usermod -aG kvm "${USER}" ``` -See also: [initial setup](https://github.com/sickcodes/Docker-OSX#initial-setup). +See also: [initial setup](#initial-setup). #### Is the docker daemon enabled? @@ -294,7 +297,7 @@ See also: [here](https://github.com/sickcodes/Docker-OSX/issues/174). Created a container with `docker run` and want to reuse the underlying image again later? -See [container creation examples](https://github.com/sickcodes/Docker-OSX#container-creation-examples) for how to get to the point where this is applicable. +NB: see [container creation examples](#container-creation-examples) first for how to get to the point where this is applicable. This is for when you want to run the SAME container again later. You may need to use `docker commit` to save your container before you can reuse it. Check if your container is persisted with `docker ps --all`. @@ -332,7 +335,7 @@ docker start -ai -i ### LibGTK errors -You may see one or more libgtk-related errors if you do not have everything set up for hardware virtualisation yet. If you have not yet done so, check out the [initial setup](https://github.com/sickcodes/Docker-OSX#initial-setup) section and the [routine checks](https://github.com/sickcodes/Docker-OSX#routine-checks) section as you may have missed a setup step or may not have all the needed Docker dependencies ready to go. +You may see one or more libgtk-related errors if you do not have everything set up for hardware virtualisation yet. If you have not yet done so, check out the [initial setup](#initial-setup) section and the [routine checks](#routine-checks) section as you may have missed a setup step or may not have all the needed Docker dependencies ready to go. See also: [here](https://github.com/sickcodes/Docker-OSX/issues/174). @@ -699,7 +702,7 @@ docker run -it \ sickcodes/docker-osx:auto ``` -#### This example generates a specific set of serial numbers at runtime, with your existing image, at 1000x1000 display resolution. +#### This example generates a specific set of serial numbers at runtime, with your existing image, at 1000x1000 display resolution ```bash # run an existing image in current directory, with a screen, with SSH, with nopicker. @@ -1017,7 +1020,9 @@ The Quick Start command should work out of the box, provided that you keep the f -e "DISPLAY=${DISPLAY:-:0.0}" \ ``` -#### Download the image manually and use it in Docker [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked](https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) +#### Download the image manually and use it in Docker + +[![https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked](https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) This is a particularly good way for downloading the container, in case Docker's CDN (or your connection) happens to be slow. @@ -1034,7 +1039,9 @@ docker run -it \ sickcodes/docker-osx:naked ``` -#### Use a prebuilt image with arbitrary command line arguments [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto](https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) +#### Prebuilt image with arbitrary command line arguments + +[![https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto](https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) ```bash docker pull sickcodes/docker-osx:auto @@ -1064,7 +1071,9 @@ For a headless container, **remove** the following two lines from your `docker r # -e "DISPLAY=${DISPLAY:-:0.0}" \ ``` -#### Building a headless container from a custom image [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked](https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) +#### Building a headless container from a custom image + +[![https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked](https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) This is particularly helpful for CI/CD pipelines. From e2d69c2bb5d08bb73b828e20db1f705533da6f13 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Mon, 12 Apr 2021 09:16:44 +0000 Subject: [PATCH 57/68] Fix NO_CACHE by default for testing --- tests/test.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index 8323c5c..2218921 100644 --- a/tests/test.sh +++ b/tests/test.sh @@ -26,13 +26,13 @@ General options: --vnc-password, -v Choose a VNC passwd. Flags + --no-cache, -n Enable --no-cache (default already) --no-no-cache, -nn Disable --no-cache docker builds --help, -h, help Display this help and exit " # set -xeuf -o pipefail -NO_CACHE='--no-cache' # gather arguments while (( "$#" )); do @@ -96,6 +96,10 @@ while (( "$#" )); do shift shift ;; + --no-cache | -n ) + export NO_CACHE='--no-cache' + shift + ;; --no-no-cache | -nn ) export NO_CACHE= shift @@ -112,6 +116,8 @@ BRANCH="${BRANCH:=master}" REPO="${REPO:=https://github.com/sickcodes/Docker-OSX.git}" VNC_PASSWORD="${VNC_PASSWORD:=testing}" MIRROR_COUNTRY="${MIRROR_COUNTRY:=US}" +NO_CACHE="${NO_CACHE:=--no-cache}" + TEST_BUILDS=( 'docker-osx:latest' @@ -195,8 +201,7 @@ clone_repo () { docker-osx:latest () { - docker build \ - "${NO_CACHE}" \ + docker build ${NO_CACHE} \ --build-arg BRANCH="${BRANCH}" \ --build-arg RANKMIRRORS=true \ --build-arg MIRROR_COUNTRY="${MIRROR_COUNTRY}" \ @@ -207,8 +212,7 @@ docker-osx:latest () { docker-osx:naked () { - docker build \ - "${NO_CACHE}" \ + docker build ${NO_CACHE} \ --build-arg RANKMIRRORS=true \ --build-arg MIRROR_COUNTRY="${MIRROR_COUNTRY}" \ -f ./Dockerfile.naked \ @@ -218,8 +222,7 @@ docker-osx:naked () { docker-osx:big-sur () { - docker build \ - "${NO_CACHE}" \ + docker build ${NO_CACHE} \ --build-arg VERSION=11 \ --build-arg RANKMIRRORS=true \ --build-arg MIRROR_COUNTRY="${MIRROR_COUNTRY}" \ @@ -229,8 +232,7 @@ docker-osx:big-sur () { } docker-osx:auto () { - docker build \ - "${NO_CACHE}" \ + docker build ${NO_CACHE} \ --build-arg RANKMIRRORS=true \ --build-arg MIRROR_COUNTRY="${MIRROR_COUNTRY}" \ -f ./Dockerfile.auto \ @@ -239,8 +241,7 @@ docker-osx:auto () { } docker-osx:auto-big-sur () { - docker build \ - "${NO_CACHE}" \ + docker build ${NO_CACHE} \ --build-arg RANKMIRRORS=true \ --build-arg MIRROR_COUNTRY="${MIRROR_COUNTRY}" \ --build-arg IMAGE_URL='https://images.sick.codes/mac_hdd_ng_auto_big_sur.img' \ From bbb38349b15a45e1c1d3da962cb5bba652fd9c86 Mon Sep 17 00:00:00 2001 From: a10kiloham <295361+a10kiloham@users.noreply.github.com> Date: Tue, 13 Apr 2021 18:23:25 +0100 Subject: [PATCH 58/68] Dockerfile for :naked image with VNC support --- vnc-version/Dockerfile.nakedvnc | 208 ++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 vnc-version/Dockerfile.nakedvnc diff --git a/vnc-version/Dockerfile.nakedvnc b/vnc-version/Dockerfile.nakedvnc new file mode 100644 index 0000000..9203e58 --- /dev/null +++ b/vnc-version/Dockerfile.nakedvnc @@ -0,0 +1,208 @@ +#!/usr/bin/docker +# ____ __ ____ ______ __ +# / __ \____ _____/ /_____ _____/ __ \/ ___/ |/ / +# / / / / __ \/ ___/ //_/ _ \/ ___/ / / /\__ \| / +# / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / | +# /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| :NAKED +# +# Title: Docker-OSX (Mac on Docker) +# Author: Sick.Codes https://twitter.com/sickcodes +# Version: 4.3 +# License: GPLv3+ +# Repository: https://github.com/sickcodes/Docker-OSX +# Website: https://sick.codes +# +# This image won't run unless you supply a disk image using: +# -v ${PWD}/mac_hdd_ng.img:/image +# +# Take screenshots in the Arch container and display in terminal: scrotcat +# +# Build: +# +# docker build -t docker-osx:naked -f Dockerfile.naked . +# +# Run headless: +# +# docker run -it --device /dev/kvm -p 50922:10022 -v ${PWD}/mac_hdd_ng.img:/image docker-osx:naked +# +# Run with display: +# +# docker run -it --device /dev/kvm -p 50922:10022 -v ${PWD}/mac_hdd_ng.img:/image -e "DISPLAY=${DISPLAY:-:0.0}" -v /tmp/.X11-unix:/tmp/.X11-unix docker-osx:naked +# + +FROM sickcodes/docker-osx:latest + +MAINTAINER 'https://twitter.com/sickcodes' + +USER root + +WORKDIR /root + +RUN rm -f /home/arch/OSX-KVM/mac_hdd_ng.img + +# OPTIONAL: Arch Linux server mirrors for super fast builds +# set RANKMIRRORS to any value other that nothing, e.g. -e RANKMIRRORS=true +ARG RANKMIRRORS +ARG MIRROR_COUNTRY=US +ARG MIRROR_COUNT=10 +RUN if [[ "${RANKMIRRORS}" ]]; then { pacman -Sy wget --noconfirm || pacman -Syu wget --noconfirm ; } \ + ; wget -O ./rankmirrors "https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/rankmirrors" \ + ; wget -O- "https://www.archlinux.org/mirrorlist/?country=${MIRROR_COUNTRY:-US}&protocol=https&use_mirror_status=on" \ + | sed -e 's/^#Server/Server/' -e '/^#/d' \ + | head -n "$((${MIRROR_COUNT:-10}+1))" \ + | bash ./rankmirrors --verbose --max-time 5 - > /etc/pacman.d/mirrorlist \ + && tee -a /etc/pacman.d/mirrorlist <<< 'Server = http://mirrors.evowise.com/archlinux/$repo/os/$arch' \ + && tee -a /etc/pacman.d/mirrorlist <<< 'Server = http://mirror.rackspace.com/archlinux/$repo/os/$arch' \ + && tee -a /etc/pacman.d/mirrorlist <<< 'Server = https://mirror.rackspace.com/archlinux/$repo/os/$arch' \ + && cat /etc/pacman.d/mirrorlist ; fi + +# TEMP-FIX for pacman issue +RUN patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst \ + && curl -LO "https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/${patched_glibc}" \ + && bsdtar -C / -xvf "${patched_glibc}" || echo "Everything is fine." +# TEMP-FIX for pacman issue + +# For taking screenshots of the Xfvb screen, useful during development. +ARG SCROT + +RUN pacman -Syu xorg-server-xvfb wget xterm xorg-xhost xorg-xrandr sshpass --noconfirm \ + && if [[ "${SCROT}" ]]; then \ + pacman -Syu scrot base-devel --noconfirm \ + && git clone --recurse-submodules --depth 1 https://github.com/stolk/imcat.git \ + && cd imcat \ + && make \ + && sudo cp imcat /usr/bin/imcat \ + && touch /usr/bin/scrotcat \ + && tee -a /usr/bin/scrotcat <<< '/usr/bin/imcat <(scrot -o /dev/stdout)' \ + && chmod +x /usr/bin/scrotcat \ + ; else \ + touch /usr/bin/scrotcat \ + && echo echo >> /usr/bin/scrotcat \ + && chmod +x /usr/bin/scrotcat \ + ; fi \ + ; yes | pacman -Scc + +# TEMP-FIX for pacman issue +RUN patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst \ + && curl -LO "https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/${patched_glibc}" \ + && bsdtar -C / -xvf "${patched_glibc}" || echo "Everything is fine." +# TEMP-FIX for pacman issue + +USER arch + +WORKDIR /home/arch/OSX-KVM + +RUN mkdir -p ~/.ssh \ + && touch ~/.ssh/authorized_keys \ + && touch ~/.ssh/config \ + && chmod 700 ~/.ssh \ + && chmod 600 ~/.ssh/config \ + && chmod 600 ~/.ssh/authorized_keys \ + && tee -a ~/.ssh/config <<< 'Host *' \ + && tee -a ~/.ssh/config <<< ' StrictHostKeyChecking no' \ + && tee -a ~/.ssh/config <<< ' UserKnownHostsFile=/dev/null' + +#### SPECIAL RUNTIME ARGUMENTS BELOW + +ENV ADDITIONAL_PORTS= + +ENV BOOTDISK= + +ENV DISPLAY=:99 + +ENV HEADLESS=false + +ENV ENV=/env + +# Boolean for generating a bootdisk with new random serials. +ENV GENERATE_UNIQUE=false + +# Boolean for generating a bootdisk with specific serials. +ENV GENERATE_SPECIFIC=false + +ENV IMAGE_PATH=/image +ENV IMAGE_FORMAT=qcow2 + +ENV KVM='accel=kvm:tcg' + +# ENV MASTER_PLIST_URL="https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist" + +# ENV NETWORKING=e1000-82545em +ENV NETWORKING=vmxnet3 + +ENV NOPICKER=true + +# dynamic RAM options for runtime +ENV RAM=8 +# ENV RAM=max +# ENV RAM=half + +# 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 + +CMD sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true \ + ; sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true \ + ; { [[ "${DISPLAY}" = ':99' ]] || [[ "${HEADLESS}" == true ]] ; } && { \ + nohup Xvfb :99 -screen 0 1920x1080x16 \ + & until [[ "$(xrandr --query 2>/dev/null)" ]]; do sleep 1 ; done \ + ; } \ + ; [[ "${NOPICKER}" == true ]] && { \ + sed -i '/^.*InstallMedia.*/d' Launch.sh \ + && export BOOTDISK="${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore-nopicker.qcow2}" \ + ; } \ + || export BOOTDISK="${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ + ; [[ "${GENERATE_UNIQUE}" == true ]] && { \ + ./Docker-OSX/osx-serial-generator/generate-unique-machine-values.sh \ + --master-plist-url="${MASTER_PLIST_URL}" \ + --count 1 \ + --tsv ./serial.tsv \ + --bootdisks \ + --width "${WIDTH:-1920}" \ + --height "${HEIGHT:-1080}" \ + --output-bootdisk "${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ + --output-env "${ENV:=/env}" \ + ; } \ + ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ + source "${ENV:=/env}" 2>/dev/null \ + ; ./Docker-OSX/osx-serial-generator/generate-specific-bootdisk.sh \ + --master-plist-url="${MASTER_PLIST_URL}" \ + --model "${DEVICE_MODEL}" \ + --serial "${SERIAL}" \ + --board-serial "${BOARD_SERIAL}" \ + --uuid "${UUID}" \ + --mac-address "${MAC_ADDRESS}" \ + --width "${WIDTH:-1920}" \ + --height "${HEIGHT:-1080}" \ + --output-bootdisk "${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ + ; } \ + # ; ./enable-ssh.sh && /bin/bash -c ./Launch.sh + +WORKDIR /home/arch/OSX-KVM + +RUN sudo pacman -Syyuu --noconfirm \ + && sudo pacman -S tigervnc xterm xorg-xhost xdotool ufw --noconfirm \ + && mkdir -p ${HOME}/.vnc \ + && touch ~/.vnc/config \ + && tee -a ~/.vnc/config <<< 'geometry=1920x1080' \ + && tee -a ~/.vnc/config <<< 'localhost' \ + && tee -a ~/.vnc/config <<< 'alwaysshared' + +RUN printf '\n%s\n' \ +'sudo rm -f /tmp/.X99-lock' \ +'export DISPLAY=:99' \ +'/usr/bin/Xvnc -geometry 1920x1080 -rfbauth "${HOME}/.vnc/passwd" :99 &' > vnc.sh + +RUN cat vnc.sh Launch.sh > Launch_custom.sh + +RUN chmod +x Launch_custom.sh + +RUN tee vncpasswd_file <<< "${VNC_PASSWORD:="$(tr -dc '[:graph:]' ${HOME}/.vnc/passwd + +RUN chmod 600 ~/.vnc/passwd +RUN printf '\n\n\n\n%s\n%s\n\n\n\n' '===========VNC_PASSWORD========== ' "$( Date: Thu, 15 Apr 2021 09:55:15 +0000 Subject: [PATCH 59/68] Update custom from https://github.com/sickcodes/osx-serial-generator.git --- custom/generate-specific-bootdisk.sh | 2 +- custom/generate-unique-machine-values.sh | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/custom/generate-specific-bootdisk.sh b/custom/generate-specific-bootdisk.sh index 89ecad7..386c13b 100755 --- a/custom/generate-specific-bootdisk.sh +++ b/custom/generate-specific-bootdisk.sh @@ -210,7 +210,7 @@ download_qcow_efi_folder () { # EFI Shell commands touch startup.nsh && echo 'fs0:\EFI\BOOT\BOOTx64.efi' > startup.nsh - cp -ra "${EFI_FOLDER}" . + cp -a "${EFI_FOLDER}" . mkdir -p ./EFI/OC/Resources diff --git a/custom/generate-unique-machine-values.sh b/custom/generate-unique-machine-values.sh index ad5bd1f..1cdd707 100755 --- a/custom/generate-unique-machine-values.sh +++ b/custom/generate-unique-machine-values.sh @@ -243,7 +243,7 @@ download_qcow_efi_folder () { # EFI Shell commands touch startup.nsh && echo 'fs0:\EFI\BOOT\BOOTx64.efi' > startup.nsh - cp -ra "${EFI_FOLDER}" . + cp -a "${EFI_FOLDER}" . mkdir -p ./EFI/OC/Resources @@ -275,28 +275,30 @@ generate_serial_sets () { | 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 - cat <> "${CSV_SERIAL_SETS_FILE}" + tee -a "${CSV_SERIAL_SETS_FILE}" <> "${TSV_SERIAL_SETS_FILE}" + tee -a "${TSV_SERIAL_SETS_FILE}" < Date: Thu, 15 Apr 2021 17:14:40 +0100 Subject: [PATCH 60/68] Adding Bluebubbles as an example use case --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index db5c4ee..5619ad5 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ Docker-OSX is licensed under the [GPL v3+](LICENSE). Contributions are welcomed ### Other cool Docker/QEMU based projects - [Run iOS in a Docker container with Docker-eyeOS](https://github.com/sickcodes/Docker-eyeOS) - [https://github.com/sickcodes/Docker-eyeOS](https://github.com/sickcodes/Docker-eyeOS) +- [Run iMessage relayer in Docker with Bluebubbles.app](https://bluebubbles.app/) - [Getting started wiki](https://github.com/BlueBubblesApp/BlueBubbles-Server/wiki/Running-via-Docker) ## Disclaimer From 19439bf2bda7c592098c0d4da0f74182e9713e70 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Sun, 18 Apr 2021 10:54:43 +0000 Subject: [PATCH 61/68] Add LIBGUESTFS debug & trace commands, exit on fail. Update credits --- CHANGELOG.md | 1 + CREDITS.md | 10 +++++++++- Dockerfile | 12 ++++++------ Dockerfile.auto | 10 +++++++--- Dockerfile.naked | 10 +++++++--- 5 files changed, 30 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dcc665f..fa95f9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ |Version|Date|Notes| |---|---|---| +| |2021-04-18|Add LIBGUESTFS debug & trace commands, exit on fail when creating bootdisks. Silence touch errors.| |4.3|2021-03-24|Enable interactive QEMU again. Remove envsubst since we are already using bash... Add set -x flag| |4.2|2021-03-24|Add all ENV variables to each dockerfile for readability. Add RAM allocation buffer and cache drop bug fix. Add kvm and libvirt groups. Add `IMAGE_FORMAT=qcow2` to allow `IMAGE_FORMAT=raw` too.| | |2021-03-19|Use RAM=3 as the default RAM allocation. Add instructions to clear buff/cache.| diff --git a/CREDITS.md b/CREDITS.md index 979906d..1f66922 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -2,7 +2,11 @@ ## Upstream Acknowledgements: -This project uses OSX-KVM from https://github.com/kholia/OSX-KVM/ and fully appreciates the work done by [@Kholia](https://github.com/Kholia) and all the contributors who are listed: [https://github.com/kholia/OSX-KVM/blob/master/CREDITS.md](https://github.com/kholia/OSX-KVM/blob/master/CREDITS.md) +This project uses OSX-KVM from https://github.com/kholia/OSX-KVM and fully appreciates the work done by [@Kholia](https://github.com/Kholia) and all the contributors who are listed: [https://github.com/kholia/OSX-KVM/blob/master/CREDITS.md](https://github.com/kholia/OSX-KVM/blob/master/CREDITS.md) + +This project also uses KVM-OpenCore from https://github.com/Leoyzen/KVM-Opencore and fully appreciates the work done by [@Leoyzen](https://github.com/Leoyzen). + +We use a special fork by [Nicholas Sherlock](https://www.nicksherlock.com/) of KVM-Opencore https://github.com/thenickdude/KVM-Opencore and thank Nick for his awesome upstream work! This project now uses the fantastic OpenCore bootloader from the community OpenCore project: https://github.com/acidanthera/OpenCorePkg. You can join their [Subreddit here](https://www.reddit.com/r/hackintosh/)! @@ -69,3 +73,7 @@ This project now uses the fantastic OpenCore bootloader from the community OpenC [@ggjulio](https://github.com/ggjulio) - Restarting an "auto" container #216 [@panos](https://github.com/panos) - Made further improvements to the README #219 + +[@a10kiloham] - Dockerfile for :naked image with VNC support #245 + +[@a10kiloham] - Adding Bluebubbles as an example use case #250 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 74c6cb3..def686d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -185,9 +185,6 @@ RUN [[ "${VERSION%%.*}" -ge 11 ]] && { wget "${FETCH_MAC_OS_RAW}" \ && rm -f BaseSystem.dmg \ ; } || true -# > Launch.sh -# > Docker-OSX.xml - WORKDIR /home/arch/OSX-KVM ARG LINUX=true @@ -289,6 +286,9 @@ ENV RAM=3 ENV WIDTH=1920 ENV HEIGHT=1080 +# libguestfs verbose +ENV LIBGUESTFS_DEBUG=1 +ENV LIBGUESTFS_TRACE=1 VOLUME ["/tmp/.X11-unix"] @@ -311,7 +311,7 @@ VOLUME ["/tmp/.X11-unix"] # the default serial numbers are already contained in ./OpenCore-Catalina/OpenCore.qcow2 # And the default serial numbers -CMD sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true \ +CMD sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" 2>/dev/null || true \ ; sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true \ ; [[ "${NOPICKER}" == true ]] && { \ sed -i '/^.*InstallMedia.*/d' Launch.sh \ @@ -328,7 +328,7 @@ CMD sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ --output-env "${ENV:=/env}" \ - ; } \ + || exit 1 ; } \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ source "${ENV:=/env}" 2>/dev/null \ ; ./Docker-OSX/osx-serial-generator/generate-specific-bootdisk.sh \ @@ -341,7 +341,7 @@ CMD sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true --width "${WIDTH:-1920}" \ --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ - ; } \ + || exit 1 ; } \ ; ./enable-ssh.sh && /bin/bash -c ./Launch.sh # virt-manager mode: eta son diff --git a/Dockerfile.auto b/Dockerfile.auto index 170029f..56aba71 100644 --- a/Dockerfile.auto +++ b/Dockerfile.auto @@ -170,6 +170,10 @@ ENV RAM=3 ENV WIDTH=1920 ENV HEIGHT=1080 +# libguestfs verbose +ENV LIBGUESTFS_DEBUG=1 +ENV LIBGUESTFS_TRACE=1 + ENV TERMS_OF_USE=i_agree ENV BOILERPLATE="By using this Dockerfile, you hereby agree that you are a security reseacher or developer and agree to use this Dockerfile to make the world a safer place. Examples include: making your apps safer, finding your mobile phone, compiling security products, etc. You understand that Docker-OSX is an Open Source project, which is released to the public under the GNU Pulic License version 3 and above. You acknowledge that the Open Source project is absolutely unaffiliated with any third party, in any form whatsoever. Any trademarks or intelectual property which happen to be mentioned anywhere in or around the project are owned by their respective owners. By using this Dockerfile, you agree to agree to the EULA of each piece of upstream or downstream software. The following code is released for the sole purpose of security research, under the GNU Public License version 3. If you are concerned about the licensing, please note that this project is not AGPL. A copy of the license is available online: https://github.com/sickcodes/Docker-OSX/blob/master/LICENSE. In order to use the following Dockerfile you must read and understand the terms. Once you have read the terms, use the -e TERMS_OF_USE=i_agree or -e TERMS_OF_USE=i_disagree" @@ -177,7 +181,7 @@ ENV BOILERPLATE="By using this Dockerfile, you hereby agree that you are a secur CMD echo "${BOILERPLATE}" \ ; [[ "${TERMS_OF_USE}" = i_agree ]] || exit 1 \ ; echo "Disk is being copied between layers... Please wait a minute..." \ - ; sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true \ + ; sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" 2>/dev/null || true \ ; sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true \ ; [[ "${NOPICKER}" == true ]] && { \ sed -i '/^.*InstallMedia.*/d' Launch.sh \ @@ -194,7 +198,7 @@ CMD echo "${BOILERPLATE}" \ --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ --output-env "${ENV:=/env}" \ - ; } \ + || exit 1 ; } \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ source "${ENV:=/env}" 2>/dev/null \ ; ./Docker-OSX/osx-serial-generator/generate-specific-bootdisk.sh \ @@ -207,7 +211,7 @@ CMD echo "${BOILERPLATE}" \ --width "${WIDTH:-1920}" \ --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ - ; } \ + || exit 1 ; } \ ; { [[ "${DISPLAY}" = ':99' ]] || [[ "${HEADLESS}" == true ]] ; } && { \ nohup Xvfb :99 -screen 0 1920x1080x16 \ & until [[ "$(xrandr --query 2>/dev/null)" ]]; do sleep 1 ; done \ diff --git a/Dockerfile.naked b/Dockerfile.naked index 16de510..afaa2bd 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -142,7 +142,11 @@ ENV RAM=3 ENV WIDTH=1920 ENV HEIGHT=1080 -CMD sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true \ +# libguestfs verbose +ENV LIBGUESTFS_DEBUG=1 +ENV LIBGUESTFS_TRACE=1 + +CMD sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" 2>/dev/null || true \ ; sudo chown -R $(id -u):$(id -g) /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true \ ; { [[ "${DISPLAY}" = ':99' ]] || [[ "${HEADLESS}" == true ]] ; } && { \ nohup Xvfb :99 -screen 0 1920x1080x16 \ @@ -163,7 +167,7 @@ CMD sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ --output-env "${ENV:=/env}" \ - ; } \ + || exit 1 ; } \ ; [[ "${GENERATE_SPECIFIC}" == true ]] && { \ source "${ENV:=/env}" 2>/dev/null \ ; ./Docker-OSX/osx-serial-generator/generate-specific-bootdisk.sh \ @@ -176,5 +180,5 @@ CMD sudo touch /dev/kvm /dev/snd "${IMAGE_PATH}" "${BOOTDISK}" "${ENV}" || true --width "${WIDTH:-1920}" \ --height "${HEIGHT:-1080}" \ --output-bootdisk "${BOOTDISK:=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2}" \ - ; } \ + || exit 1 ; } \ ; ./enable-ssh.sh && /bin/bash -c ./Launch.sh From 5542eafad7e4be0de3e0cf2f5ea63a99bf925af8 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Sun, 18 Apr 2021 10:58:17 +0000 Subject: [PATCH 62/68] Fix CREDITS.md --- CREDITS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CREDITS.md b/CREDITS.md index 1f66922..42154d0 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -74,6 +74,6 @@ This project now uses the fantastic OpenCore bootloader from the community OpenC [@panos](https://github.com/panos) - Made further improvements to the README #219 -[@a10kiloham] - Dockerfile for :naked image with VNC support #245 +[@a10kiloham](https://github.com/a10kiloham) - Dockerfile for :naked image with VNC support #245 -[@a10kiloham] - Adding Bluebubbles as an example use case #250 \ No newline at end of file +[@a10kiloham](https://github.com/a10kiloham) - Adding Bluebubbles as an example use case #250 \ No newline at end of file From 15cb15e153d817a877875f9212735eb19c3f368f Mon Sep 17 00:00:00 2001 From: sickcodes Date: Sun, 18 Apr 2021 16:06:29 +0000 Subject: [PATCH 63/68] [@aronzvi](https://github.com/aronzvi) - Fixed Failed to boot OSX with GENERATE_UNIQUE #244 --- Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index def686d..8221eaa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -197,6 +197,11 @@ RUN if [[ "${LINUX}" == true ]]; then \ && bsdtar -C / -xvf "${patched_glibc}" || echo "Everything is fine." \ ; fi +RUN yes | sudo pacman -U https://archive.archlinux.org/packages/f/file/file-5.39-1-x86_64.pkg.tar.zst \ + && patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst \ + && curl -LO "https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/${patched_glibc}" \ + && bsdtar -C / -xvf "${patched_glibc}" || echo "Everything is fine." + # optional --build-arg to change branches for testing ARG BRANCH=master ARG REPO='https://github.com/sickcodes/Docker-OSX.git' From 309ff1cd5170245273c8e9dba2673a5b0c517e78 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Sun, 18 Apr 2021 19:28:03 +0000 Subject: [PATCH 64/68] Downgrade file to 5.39 due to libguestfs bug. All Dockerfiles though. --- CREDITS.md | 4 +++- Dockerfile | 4 +++- Dockerfile.auto | 7 +++++++ Dockerfile.naked | 7 +++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CREDITS.md b/CREDITS.md index 42154d0..7a78a67 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -76,4 +76,6 @@ This project now uses the fantastic OpenCore bootloader from the community OpenC [@a10kiloham](https://github.com/a10kiloham) - Dockerfile for :naked image with VNC support #245 -[@a10kiloham](https://github.com/a10kiloham) - Adding Bluebubbles as an example use case #250 \ No newline at end of file +[@a10kiloham](https://github.com/a10kiloham) - Adding Bluebubbles as an example use case #250 + +[@aronzvi](https://github.com/aronzvi) - Fixed Failed to boot OSX with GENERATE_UNIQUE #244 diff --git a/Dockerfile b/Dockerfile index 8221eaa..788d670 100644 --- a/Dockerfile +++ b/Dockerfile @@ -197,10 +197,12 @@ RUN if [[ "${LINUX}" == true ]]; then \ && bsdtar -C / -xvf "${patched_glibc}" || echo "Everything is fine." \ ; fi -RUN yes | sudo pacman -U https://archive.archlinux.org/packages/f/file/file-5.39-1-x86_64.pkg.tar.zst \ +# TEMP-FIX for file 5.40 libguestfs issue +RUN yes | pacman -U https://archive.archlinux.org/packages/f/file/file-5.39-1-x86_64.pkg.tar.zst \ && patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst \ && curl -LO "https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/${patched_glibc}" \ && bsdtar -C / -xvf "${patched_glibc}" || echo "Everything is fine." +# TEMP-FIX for file 5.40 libguestfs issue # optional --build-arg to change branches for testing ARG BRANCH=master diff --git a/Dockerfile.auto b/Dockerfile.auto index 56aba71..937bcc3 100644 --- a/Dockerfile.auto +++ b/Dockerfile.auto @@ -99,6 +99,13 @@ RUN patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst \ && bsdtar -C / -xvf "${patched_glibc}" || echo "Everything is fine." # TEMP-FIX for pacman issue +# TEMP-FIX for file 5.40 libguestfs issue +RUN yes | pacman -U https://archive.archlinux.org/packages/f/file/file-5.39-1-x86_64.pkg.tar.zst \ + && patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst \ + && curl -LO "https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/${patched_glibc}" \ + && bsdtar -C / -xvf "${patched_glibc}" || echo "Everything is fine." +# TEMP-FIX for file 5.40 libguestfs issue + USER arch WORKDIR /home/arch/OSX-KVM diff --git a/Dockerfile.naked b/Dockerfile.naked index afaa2bd..052029e 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -88,6 +88,13 @@ RUN patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst \ && bsdtar -C / -xvf "${patched_glibc}" || echo "Everything is fine." # TEMP-FIX for pacman issue +# TEMP-FIX for file 5.40 libguestfs issue +RUN yes | pacman -U https://archive.archlinux.org/packages/f/file/file-5.39-1-x86_64.pkg.tar.zst \ + && patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst \ + && curl -LO "https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/${patched_glibc}" \ + && bsdtar -C / -xvf "${patched_glibc}" || echo "Everything is fine." +# TEMP-FIX for file 5.40 libguestfs issue + USER arch WORKDIR /home/arch/OSX-KVM From c5a2a5539d0c6c06cff34619ffcb4fd16b72cf4a Mon Sep 17 00:00:00 2001 From: Chaim Krause Date: Sat, 24 Apr 2021 09:53:28 -0500 Subject: [PATCH 65/68] initial commit --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 5619ad5..4084f94 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,6 @@ The images (excluding `:naked`) launch a container with an existing installation - username: `user`, password: `alpine` - SSH enabled (`localhost:50922`) - VNC enabled (`localhost:8888`) if using ./vnc version -- VNC enabled (`localhost:8888`) if using ./vnc version - auto-updates disabled - [serial number generator!](https://github.com/sickcodes/osx-serial-generator) - X11 forwarding is enabled From 5dc2f4fd044b4afa27f0f23e30bbc2f56aa9c232 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Tue, 27 Apr 2021 22:58:05 +0000 Subject: [PATCH 66/68] Temp Fix Failed to boot OSX with GENERATE_UNIQUE #244 --- Dockerfile | 2 +- Dockerfile.auto | 2 +- Dockerfile.naked | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 788d670..5ac61b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -198,7 +198,7 @@ RUN if [[ "${LINUX}" == true ]]; then \ ; fi # TEMP-FIX for file 5.40 libguestfs issue -RUN yes | pacman -U https://archive.archlinux.org/packages/f/file/file-5.39-1-x86_64.pkg.tar.zst \ +RUN yes | sudo pacman -U https://archive.archlinux.org/packages/f/file/file-5.39-1-x86_64.pkg.tar.zst \ && patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst \ && curl -LO "https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/${patched_glibc}" \ && bsdtar -C / -xvf "${patched_glibc}" || echo "Everything is fine." diff --git a/Dockerfile.auto b/Dockerfile.auto index 937bcc3..6ec56fc 100644 --- a/Dockerfile.auto +++ b/Dockerfile.auto @@ -100,7 +100,7 @@ RUN patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst \ # TEMP-FIX for pacman issue # TEMP-FIX for file 5.40 libguestfs issue -RUN yes | pacman -U https://archive.archlinux.org/packages/f/file/file-5.39-1-x86_64.pkg.tar.zst \ +RUN yes | sudo pacman -U https://archive.archlinux.org/packages/f/file/file-5.39-1-x86_64.pkg.tar.zst \ && patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst \ && curl -LO "https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/${patched_glibc}" \ && bsdtar -C / -xvf "${patched_glibc}" || echo "Everything is fine." diff --git a/Dockerfile.naked b/Dockerfile.naked index 052029e..742e1d9 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -89,7 +89,7 @@ RUN patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst \ # TEMP-FIX for pacman issue # TEMP-FIX for file 5.40 libguestfs issue -RUN yes | pacman -U https://archive.archlinux.org/packages/f/file/file-5.39-1-x86_64.pkg.tar.zst \ +RUN yes | sudo pacman -U https://archive.archlinux.org/packages/f/file/file-5.39-1-x86_64.pkg.tar.zst \ && patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst \ && curl -LO "https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/${patched_glibc}" \ && bsdtar -C / -xvf "${patched_glibc}" || echo "Everything is fine." From 9ccb93101d9c9fedb3f3ff5afe333f3766666748 Mon Sep 17 00:00:00 2001 From: Minghua Zheng Date: Wed, 28 Apr 2021 13:14:52 +0100 Subject: [PATCH 67/68] Update README.md add instructions to change resolution after the container is created --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 4084f94..8bf8ae5 100644 --- a/README.md +++ b/README.md @@ -883,6 +883,23 @@ Here's a few other resolutions! If you resolution is invalid, it will default to -e HEIGHT=1600 \ ``` +#### This example shows how to change resolution after the container is created. + +First step is to stop the docker daemon +``` +sudo systemctl stop docker +``` +The second step is to change container config in +``` +/var/lib/docker/containers/[container-id]/config.v2.json +``` +(Suppose your original WIDTH is 1024 and HEIGHT is 768, you can search 1024 and replace it with the new value. Same for 768.) + +The last step is to restart the docker daemon +``` +sudo systemctl restart docker +``` + ### Mounting physical disks in Mac OSX Pass the disk into the container as a volume and then pass the disk again into QEMU command line extras with. From 77307c7b2482cbf2165c754a533f64fe6fbf29c5 Mon Sep 17 00:00:00 2001 From: sickcodes <65906298+sickcodes@users.noreply.github.com> Date: Sun, 2 May 2021 10:15:06 +0000 Subject: [PATCH 68/68] Add cool shield from https://dockeri.co/ to README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8bf8ae5..bcb3eb8 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ Big thanks to the OpenCore team over at: https://github.com/acidanthera/OpenCore If you like this project, consider contributing here or upstream! +[![dockeri.co](https://dockeri.co/image/sickcodes/docker-osx)](https://hub.docker.com/r/sickcodes/docker-osx) + ## Quick Start Docker-OSX First time here? try [initial setup](#initial-setup), otherwise try the instructions below to use either Catalina or Big Sur.