mirror of
https://github.com/dockur/macos.git
synced 2026-03-11 08:34:24 +00:00
Compare commits
161 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
297714126c | ||
|
|
056dfdd026 | ||
|
|
4cdd13585d | ||
|
|
1b3f506bbe | ||
|
|
9288c856e4 | ||
|
|
67a172743c | ||
|
|
333948ef19 | ||
|
|
dd59b97af6 | ||
|
|
5c26b95ee4 | ||
|
|
b3450d11eb | ||
|
|
61ff166d16 | ||
|
|
211601d12b | ||
|
|
e032e349ee | ||
|
|
2f0e962edd | ||
|
|
05a699ba9a | ||
|
|
72468237d3 | ||
|
|
20068d21a3 | ||
|
|
6672deb920 | ||
|
|
fb7cd67691 | ||
|
|
c3d9de925c | ||
|
|
b1d47f113b | ||
|
|
8def1efbc0 | ||
|
|
9a8afcf237 | ||
|
|
e461eba7b3 | ||
|
|
3935b89941 | ||
|
|
9c8458d30b | ||
|
|
61d30d1672 | ||
|
|
0daaa39547 | ||
|
|
2d21f714c3 | ||
|
|
d3c2d44855 | ||
|
|
cfd279b7e1 | ||
|
|
8423965cf8 | ||
|
|
4c529524ad | ||
|
|
7f1202725c | ||
|
|
6c6f929adf | ||
|
|
feac11ef9a | ||
|
|
9d19aeeaf3 | ||
|
|
edaa2d2bfc | ||
|
|
a92a2cb0a0 | ||
|
|
944d58a982 | ||
|
|
eda63efc6e | ||
|
|
45b966703e | ||
|
|
1f31b50ff8 | ||
|
|
05dad712f3 | ||
|
|
4e804a1ef9 | ||
|
|
5b25e4c64d | ||
|
|
f9ea2f2781 | ||
|
|
35c7419044 | ||
|
|
8e7572b1ff | ||
|
|
125f14164b | ||
|
|
1ed6749ccd | ||
|
|
fc99211115 | ||
|
|
d4add50eb4 | ||
|
|
c787b8dd13 | ||
|
|
54e08a9425 | ||
|
|
733266fd6c | ||
|
|
08ac3ab823 | ||
|
|
a737399811 | ||
|
|
109b84fd6f | ||
|
|
fb044b9158 | ||
|
|
a82c3b58fd | ||
|
|
0cd494674c | ||
|
|
7d85112d12 | ||
|
|
f15a2d6ae5 | ||
|
|
827f458cae | ||
|
|
27a66f4748 | ||
|
|
9fb20e6ef5 | ||
|
|
e1977b9cdc | ||
|
|
db7d2d32a4 | ||
|
|
fa9319e74e | ||
|
|
b6a318f6e9 | ||
|
|
d93c75b979 | ||
|
|
9115d132f6 | ||
|
|
88c3f6219e | ||
|
|
e0a357091d | ||
|
|
69b79d9ba9 | ||
|
|
132033171d | ||
|
|
88a476ef4c | ||
|
|
08255c5a45 | ||
|
|
a410d8a123 | ||
|
|
6060d36387 | ||
|
|
0ffd7852fe | ||
|
|
431d9e544f | ||
|
|
1bf46b7e0b | ||
|
|
bbbc853178 | ||
|
|
453ec734ba | ||
|
|
cdf3e9df63 | ||
|
|
8e23be901f | ||
|
|
431b4b6ce9 | ||
|
|
a4735a328f | ||
|
|
6d588e42e1 | ||
|
|
5698b772b3 | ||
|
|
874bfa197b | ||
|
|
6d65c6cfbb | ||
|
|
9e07cb5367 | ||
|
|
de76cca895 | ||
|
|
69fb95c90f | ||
|
|
d07d09ea48 | ||
|
|
422ded1364 | ||
|
|
3277ec9eea | ||
|
|
2f0ee294e0 | ||
|
|
ad46446f1b | ||
|
|
e94516ebec | ||
|
|
876b858c69 | ||
|
|
35922a1714 | ||
|
|
70f6feb864 | ||
|
|
5ccb6fde73 | ||
|
|
90e5afd771 | ||
|
|
0d270138f2 | ||
|
|
3768d0f3df | ||
|
|
8d10ce8f68 | ||
|
|
250a09a2ac | ||
|
|
82865eb6d5 | ||
|
|
eb50bf405a | ||
|
|
44be8f5869 | ||
|
|
028b71f593 | ||
|
|
c2422ba1a4 | ||
|
|
72971f2df5 | ||
|
|
7aec69abd4 | ||
|
|
b37ed52881 | ||
|
|
431e95d798 | ||
|
|
17a2f29834 | ||
|
|
5cae89f75f | ||
|
|
22fedbfa72 | ||
|
|
01e809c0aa | ||
|
|
e0c84427f8 | ||
|
|
6f833321b3 | ||
|
|
c6ec08c0b5 | ||
|
|
ddff7a3f92 | ||
|
|
fba0a66658 | ||
|
|
f6831a5ba6 | ||
|
|
7225019302 | ||
|
|
be5b26a754 | ||
|
|
b993d8c0bd | ||
|
|
cea3262937 | ||
|
|
b709ec3057 | ||
|
|
40fe37786b | ||
|
|
ee97b791e0 | ||
|
|
5ddafa7568 | ||
|
|
c2aa3c6f43 | ||
|
|
c9c3d82a54 | ||
|
|
48ae8e666b | ||
|
|
b6be959712 | ||
|
|
2fa64cf373 | ||
|
|
4528b3ecd6 | ||
|
|
1cf4f3d154 | ||
|
|
0e69a19220 | ||
|
|
471a809902 | ||
|
|
c0865239d5 | ||
|
|
bb640e7ecf | ||
|
|
60ddd4d611 | ||
|
|
2ce297f9c5 | ||
|
|
55ecf49757 | ||
|
|
8c6314b5ab | ||
|
|
cffe7321eb | ||
|
|
0e999a5f5d | ||
|
|
4d566a22aa | ||
|
|
9b7bc11294 | ||
|
|
24377bb04a | ||
|
|
d6a0a37026 | ||
|
|
a65c619da8 |
24 changed files with 888 additions and 302 deletions
19
.devcontainer/010 - macOS Sequoia/devcontainer.json
Normal file
19
.devcontainer/010 - macOS Sequoia/devcontainer.json
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "macOS 15 (Sequoia)",
|
||||
"service": "macos",
|
||||
"containerEnv": {
|
||||
"VERSION": "15"
|
||||
},
|
||||
"forwardPorts": [8006],
|
||||
"portsAttributes": {
|
||||
"8006": {
|
||||
"label": "Web",
|
||||
"onAutoForward": "notify"
|
||||
}
|
||||
},
|
||||
"otherPortsAttributes": {
|
||||
"onAutoForward": "ignore"
|
||||
},
|
||||
"dockerComposeFile": "../codespaces.yml",
|
||||
"initializeCommand": "docker system prune --all --force"
|
||||
}
|
||||
19
.devcontainer/030 - macOS Ventura/devcontainer.json
Normal file
19
.devcontainer/030 - macOS Ventura/devcontainer.json
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "macOS 13 (Ventura)",
|
||||
"service": "macos",
|
||||
"containerEnv": {
|
||||
"VERSION": "13"
|
||||
},
|
||||
"forwardPorts": [8006],
|
||||
"portsAttributes": {
|
||||
"8006": {
|
||||
"label": "Web",
|
||||
"onAutoForward": "notify"
|
||||
}
|
||||
},
|
||||
"otherPortsAttributes": {
|
||||
"onAutoForward": "ignore"
|
||||
},
|
||||
"dockerComposeFile": "../codespaces.yml",
|
||||
"initializeCommand": "docker system prune --all --force"
|
||||
}
|
||||
19
.devcontainer/040 - macOS Monterey/devcontainer.json
Normal file
19
.devcontainer/040 - macOS Monterey/devcontainer.json
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "macOS 12 (Monterey)",
|
||||
"service": "macos",
|
||||
"containerEnv": {
|
||||
"VERSION": "12"
|
||||
},
|
||||
"forwardPorts": [8006],
|
||||
"portsAttributes": {
|
||||
"8006": {
|
||||
"label": "Web",
|
||||
"onAutoForward": "notify"
|
||||
}
|
||||
},
|
||||
"otherPortsAttributes": {
|
||||
"onAutoForward": "ignore"
|
||||
},
|
||||
"dockerComposeFile": "../codespaces.yml",
|
||||
"initializeCommand": "docker system prune --all --force"
|
||||
}
|
||||
19
.devcontainer/050 - macOS Big Sur/devcontainer.json
Normal file
19
.devcontainer/050 - macOS Big Sur/devcontainer.json
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "macOS 11 (Big Sur)",
|
||||
"service": "macos",
|
||||
"containerEnv": {
|
||||
"VERSION": "11"
|
||||
},
|
||||
"forwardPorts": [8006],
|
||||
"portsAttributes": {
|
||||
"8006": {
|
||||
"label": "Web",
|
||||
"onAutoForward": "notify"
|
||||
}
|
||||
},
|
||||
"otherPortsAttributes": {
|
||||
"onAutoForward": "ignore"
|
||||
},
|
||||
"dockerComposeFile": "../codespaces.yml",
|
||||
"initializeCommand": "docker system prune --all --force"
|
||||
}
|
||||
19
.devcontainer/060 - macOS Catalina/devcontainer.json
Normal file
19
.devcontainer/060 - macOS Catalina/devcontainer.json
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "macOS 10 (Catalina)",
|
||||
"service": "macos",
|
||||
"containerEnv": {
|
||||
"VERSION": "10"
|
||||
},
|
||||
"forwardPorts": [8006],
|
||||
"portsAttributes": {
|
||||
"8006": {
|
||||
"label": "Web",
|
||||
"onAutoForward": "notify"
|
||||
}
|
||||
},
|
||||
"otherPortsAttributes": {
|
||||
"onAutoForward": "ignore"
|
||||
},
|
||||
"dockerComposeFile": "../codespaces.yml",
|
||||
"initializeCommand": "docker system prune --all --force"
|
||||
}
|
||||
21
.devcontainer/codespaces.yml
Normal file
21
.devcontainer/codespaces.yml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
services:
|
||||
macos:
|
||||
container_name: macos
|
||||
image: ghcr.io/dockur/macos
|
||||
environment:
|
||||
RAM_SIZE: "half"
|
||||
DISK_SIZE: "max"
|
||||
CPU_CORES: "max"
|
||||
devices:
|
||||
- /dev/kvm
|
||||
- /dev/net/tun
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
ports:
|
||||
- 8006:8006
|
||||
- 5900:5900/tcp
|
||||
- 5900:5900/udp
|
||||
volumes:
|
||||
- ./macos:/storage
|
||||
restart: on-failure
|
||||
stop_grace_period: 2m
|
||||
19
.devcontainer/devcontainer.json
Normal file
19
.devcontainer/devcontainer.json
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "macOS 14 (Sonoma)",
|
||||
"service": "macos",
|
||||
"containerEnv": {
|
||||
"VERSION": "14"
|
||||
},
|
||||
"forwardPorts": [8006],
|
||||
"portsAttributes": {
|
||||
"8006": {
|
||||
"label": "Web",
|
||||
"onAutoForward": "notify"
|
||||
}
|
||||
},
|
||||
"otherPortsAttributes": {
|
||||
"onAutoForward": "ignore"
|
||||
},
|
||||
"dockerComposeFile": "codespaces.yml",
|
||||
"initializeCommand": "docker system prune --all --force"
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
.dockerignore
|
||||
.devcontainer
|
||||
.git
|
||||
.github
|
||||
.gitignore
|
||||
|
|
|
|||
2
.github/ISSUE_TEMPLATE/1-issue.yml
vendored
2
.github/ISSUE_TEMPLATE/1-issue.yml
vendored
|
|
@ -21,6 +21,7 @@ body:
|
|||
attributes:
|
||||
label: Docker compose
|
||||
description: The compose file (or otherwise the `docker run` command used).
|
||||
render: yaml
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
|
|
@ -28,6 +29,7 @@ body:
|
|||
attributes:
|
||||
label: Docker log
|
||||
description: The logfile of the container (as shown by `docker logs macos`).
|
||||
render: shell
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
|
|
|
|||
2
.github/ISSUE_TEMPLATE/3-bug.yml
vendored
2
.github/ISSUE_TEMPLATE/3-bug.yml
vendored
|
|
@ -23,6 +23,7 @@ body:
|
|||
attributes:
|
||||
label: Docker compose
|
||||
description: The compose file (or otherwise the `docker run` command used).
|
||||
render: yaml
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
|
|
@ -30,6 +31,7 @@ body:
|
|||
attributes:
|
||||
label: Docker log
|
||||
description: The logfile of the container (as shown by `docker logs macos`).
|
||||
render: shell
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
|
|
|
|||
18
.github/workflows/build.yml
vendored
18
.github/workflows/build.yml
vendored
|
|
@ -2,16 +2,6 @@ name: Build
|
|||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths-ignore:
|
||||
- '**/*.md'
|
||||
- '**/*.yml'
|
||||
- '.gitignore'
|
||||
- '.dockerignore'
|
||||
- '.github/**'
|
||||
- '.github/workflows/**'
|
||||
|
||||
concurrency:
|
||||
group: build
|
||||
|
|
@ -32,7 +22,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
-
|
||||
|
|
@ -50,7 +40,7 @@ jobs:
|
|||
labels: |
|
||||
org.opencontainers.image.title=${{ vars.NAME }}
|
||||
env:
|
||||
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
|
||||
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
|
@ -69,12 +59,12 @@ jobs:
|
|||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
name: Build Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
provenance: false
|
||||
platforms: linux/amd64,linux/arm64
|
||||
platforms: linux/amd64
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
annotations: ${{ steps.meta.outputs.annotations }}
|
||||
|
|
|
|||
11
.github/workflows/check.yml
vendored
11
.github/workflows/check.yml
vendored
|
|
@ -7,14 +7,19 @@ jobs:
|
|||
name: shellcheck
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- name: Run ShellCheck
|
||||
uses: ludeeus/action-shellcheck@master
|
||||
env:
|
||||
SHELLCHECK_OPTS: -x --source-path=src -e SC1091 -e SC2001 -e SC2002 -e SC2034 -e SC2064 -e SC2153 -e SC2317 -e SC2028
|
||||
- name: Lint Dockerfile
|
||||
uses: hadolint/hadolint-action@v3.1.0
|
||||
uses: hadolint/hadolint-action@v3.3.0
|
||||
with:
|
||||
dockerfile: Dockerfile
|
||||
ignore: DL3008,DL3020,DL3029,DL3059
|
||||
ignore: DL3008,DL3018,DL3020,DL3029,DL3059
|
||||
failure-threshold: warning
|
||||
-
|
||||
name: Validate JSON and YML files
|
||||
uses: GrantBirki/json-yaml-validate@v4
|
||||
with:
|
||||
yaml_exclude_regex: ".*\\kubernetes\\.yml$"
|
||||
|
|
|
|||
22
.github/workflows/hub.yml
vendored
22
.github/workflows/hub.yml
vendored
|
|
@ -12,13 +12,15 @@ jobs:
|
|||
dockerHubDescription:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
-
|
||||
name: Docker Hub Description
|
||||
uses: peter-evans/dockerhub-description@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
repository: ${{ secrets.DOCKERHUB_REPO }}
|
||||
short-description: ${{ github.event.repository.description }}
|
||||
readme-filepath: ./readme.md
|
||||
-
|
||||
name: Checkout repo
|
||||
uses: actions/checkout@v6
|
||||
-
|
||||
name: Docker Hub Description
|
||||
uses: peter-evans/dockerhub-description@v5
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
repository: ${{ secrets.DOCKERHUB_REPO }}
|
||||
short-description: ${{ github.event.repository.description }}
|
||||
readme-filepath: ./readme.md
|
||||
|
|
|
|||
66
.github/workflows/review.yml
vendored
Normal file
66
.github/workflows/review.yml
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
on:
|
||||
pull_request:
|
||||
|
||||
name: "Review"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
checks: write
|
||||
|
||||
jobs:
|
||||
review:
|
||||
name: review
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
-
|
||||
name: Spelling
|
||||
uses: reviewdog/action-misspell@v1
|
||||
with:
|
||||
locale: "US"
|
||||
level: warning
|
||||
pattern: |
|
||||
*.md
|
||||
*.sh
|
||||
reporter: github-pr-review
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
name: Hadolint
|
||||
uses: reviewdog/action-hadolint@v1
|
||||
with:
|
||||
level: warning
|
||||
reporter: github-pr-review
|
||||
hadolint_ignore: DL3008 DL3018 DL3020 DL3029 DL3059
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
name: YamlLint
|
||||
uses: reviewdog/action-yamllint@v1
|
||||
with:
|
||||
level: warning
|
||||
reporter: github-pr-review
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
name: ActionLint
|
||||
uses: reviewdog/action-actionlint@v1
|
||||
with:
|
||||
level: warning
|
||||
reporter: github-pr-review
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
name: Shellformat
|
||||
uses: reviewdog/action-shfmt@v1
|
||||
with:
|
||||
level: warning
|
||||
shfmt_flags: "-i 2 -ci -bn"
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
name: Shellcheck
|
||||
uses: reviewdog/action-shellcheck@v1
|
||||
with:
|
||||
level: warning
|
||||
reporter: github-pr-review
|
||||
shellcheck_flags: -x -e SC1091 -e SC2001 -e SC2002 -e SC2034 -e SC2064 -e SC2153 -e SC2317 -e SC2028
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
5
.github/workflows/test.yml
vendored
5
.github/workflows/test.yml
vendored
|
|
@ -1,11 +1,6 @@
|
|||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
paths:
|
||||
- '**/*.sh'
|
||||
- '.github/workflows/test.yml'
|
||||
- '.github/workflows/check.yml'
|
||||
- 'Dockerfile'
|
||||
|
||||
name: "Test"
|
||||
permissions: {}
|
||||
|
|
|
|||
68
Dockerfile
68
Dockerfile
|
|
@ -1,6 +1,23 @@
|
|||
FROM --platform=linux/amd64 debian:trixie-slim AS builder
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM --platform=$BUILDPLATFORM alpine:3.22 AS builder
|
||||
|
||||
ARG VERSION_OPENCORE="1.0.4"
|
||||
ARG REPO_OPENCORE="https://github.com/acidanthera/OpenCorePkg"
|
||||
ADD $REPO_OPENCORE/releases/download/$VERSION_OPENCORE/OpenCore-$VERSION_OPENCORE-RELEASE.zip /tmp/opencore.zip
|
||||
|
||||
RUN apk --update --no-cache add unzip && \
|
||||
unzip /tmp/opencore.zip -d /tmp/oc && \
|
||||
cp /tmp/oc/Utilities/macserial/macserial.linux /macserial && \
|
||||
rm -rf /tmp/* /var/tmp/* /var/cache/apk/*
|
||||
|
||||
FROM scratch AS runner
|
||||
COPY --from=qemux/qemu:7.29 / /
|
||||
|
||||
ARG VERSION_ARG="0.0"
|
||||
ARG VERSION_KVM_OPENCORE="v21"
|
||||
ARG VERSION_OSX_KVM="326053dd61f49375d5dfb28ee715d38b04b5cd8e"
|
||||
ARG REPO_OSX_KVM="https://raw.githubusercontent.com/kholia/OSX-KVM"
|
||||
ARG REPO_KVM_OPENCORE="https://github.com/thenickdude/KVM-Opencore"
|
||||
|
||||
ARG DEBCONF_NOWARNINGS="yes"
|
||||
|
|
@ -10,58 +27,29 @@ ARG DEBCONF_NONINTERACTIVE_SEEN="true"
|
|||
RUN set -eu && \
|
||||
apt-get update && \
|
||||
apt-get --no-install-recommends -y install \
|
||||
fdisk \
|
||||
mtools && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
COPY --chmod=755 ./src/build.sh /run
|
||||
COPY --chmod=644 ./config.plist /run
|
||||
|
||||
ADD $REPO_KVM_OPENCORE/releases/download/$VERSION_KVM_OPENCORE/OpenCore-$VERSION_KVM_OPENCORE.iso.gz /tmp/opencore.iso.gz
|
||||
|
||||
RUN gzip -d /tmp/opencore.iso.gz && \
|
||||
run/build.sh /tmp/opencore.iso /run/config.plist && \
|
||||
rm -rf /tmp/*
|
||||
|
||||
FROM scratch AS runner
|
||||
COPY --from=qemux/qemu-docker:5.16 / /
|
||||
|
||||
ARG VERSION_ARG="0.0"
|
||||
ARG VERSION_OPENCORE="1.0.0"
|
||||
ARG VERSION_OSX_KVM="326053dd61f49375d5dfb28ee715d38b04b5cd8e"
|
||||
|
||||
ARG REPO_OSX_KVM="https://raw.githubusercontent.com/kholia/OSX-KVM"
|
||||
ARG REPO_OPENCORE="https://raw.githubusercontent.com/acidanthera/OpenCorePkg"
|
||||
|
||||
ARG DEBCONF_NOWARNINGS="yes"
|
||||
ARG DEBIAN_FRONTEND="noninteractive"
|
||||
ARG DEBCONF_NONINTERACTIVE_SEEN="true"
|
||||
|
||||
RUN set -eu && \
|
||||
apt-get update && \
|
||||
apt-get --no-install-recommends -y install \
|
||||
python3 && \
|
||||
apt-get clean && \
|
||||
echo "$VERSION_ARG" > /run/version && \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
COPY --chmod=755 ./src /run/
|
||||
COPY --chmod=644 --from=builder /images /images
|
||||
COPY --chmod=755 ./assets /assets/
|
||||
COPY --chmod=755 --from=builder /macserial /usr/local/bin/
|
||||
|
||||
ADD --chmod=755 $REPO_OPENCORE/$VERSION_OPENCORE/Utilities/macrecovery/macrecovery.py /run/
|
||||
ADD --chmod=644 \
|
||||
$REPO_OSX_KVM/$VERSION_OSX_KVM/OVMF_CODE.fd \
|
||||
$REPO_OSX_KVM/$VERSION_OSX_KVM/OVMF_VARS.fd \
|
||||
$REPO_OSX_KVM/$VERSION_OSX_KVM/OVMF_VARS-1024x768.fd \
|
||||
$REPO_OSX_KVM/$VERSION_OSX_KVM/OVMF_VARS-1920x1080.fd /usr/share/OVMF/
|
||||
|
||||
EXPOSE 8006 5900
|
||||
VOLUME /storage
|
||||
ADD $REPO_KVM_OPENCORE/releases/download/$VERSION_KVM_OPENCORE/OpenCore-$VERSION_KVM_OPENCORE.iso.gz /opencore.iso.gz
|
||||
|
||||
ENV RAM_SIZE "4G"
|
||||
ENV CPU_CORES "2"
|
||||
ENV DISK_SIZE "64G"
|
||||
ENV VERSION "ventura"
|
||||
VOLUME /storage
|
||||
EXPOSE 5900 8006
|
||||
|
||||
ENV VERSION="14"
|
||||
ENV RAM_SIZE="4G"
|
||||
ENV CPU_CORES="1"
|
||||
ENV DISK_SIZE="64G"
|
||||
|
||||
ENTRYPOINT ["/usr/bin/tini", "-s", "/run/entry.sh"]
|
||||
|
|
|
|||
|
|
@ -1,15 +1,19 @@
|
|||
services:
|
||||
osx:
|
||||
macos:
|
||||
image: dockurr/macos
|
||||
container_name: macos
|
||||
environment:
|
||||
VERSION: "ventura"
|
||||
VERSION: "14"
|
||||
devices:
|
||||
- /dev/kvm
|
||||
- /dev/net/tun
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
ports:
|
||||
- 8006:8006
|
||||
- 5900:5900/tcp
|
||||
- 5900:5900/udp
|
||||
volumes:
|
||||
- ./macos:/storage
|
||||
restart: always
|
||||
stop_grace_period: 2m
|
||||
|
|
|
|||
|
|
@ -1,72 +1,86 @@
|
|||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: macos-pvc
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 64Gi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: macos
|
||||
labels:
|
||||
name: macos
|
||||
spec:
|
||||
terminationGracePeriodSeconds: 120 # the Kubernetes default is 30 seconds and it may be not enough
|
||||
containers:
|
||||
- name: macos
|
||||
image: dockurr/macos
|
||||
ports:
|
||||
- containerPort: 8006
|
||||
protocol: TCP
|
||||
- containerPort: 5000
|
||||
protocol: TCP
|
||||
- containerPort: 5000
|
||||
protocol: UDP
|
||||
securityContext:
|
||||
privileged: true
|
||||
env:
|
||||
- name: RAM_SIZE
|
||||
value: 4G
|
||||
- name: CPU_CORES
|
||||
value: "2"
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: macos
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: macos
|
||||
spec:
|
||||
containers:
|
||||
- name: macos
|
||||
image: dockurr/macos
|
||||
env:
|
||||
- name: VERSION
|
||||
value: "14"
|
||||
- name: DISK_SIZE
|
||||
value: "64G"
|
||||
volumeMounts:
|
||||
ports:
|
||||
- containerPort: 8006
|
||||
name: http
|
||||
protocol: TCP
|
||||
- containerPort: 5900
|
||||
name: vnc
|
||||
protocol: TCP
|
||||
securityContext:
|
||||
capabilities:
|
||||
add:
|
||||
- NET_ADMIN
|
||||
privileged: true
|
||||
volumeMounts:
|
||||
- mountPath: /storage
|
||||
name: storage
|
||||
- mountPath: /dev/kvm
|
||||
name: dev-kvm
|
||||
volumes:
|
||||
- name: storage
|
||||
persistentVolumeClaim:
|
||||
claimName: macos-pvc
|
||||
- name: dev-kvm
|
||||
hostPath:
|
||||
path: /dev/kvm
|
||||
- mountPath: /dev/net/tun
|
||||
name: dev-tun
|
||||
terminationGracePeriodSeconds: 120
|
||||
volumes:
|
||||
- name: storage
|
||||
persistentVolumeClaim:
|
||||
claimName: macos-pvc
|
||||
- hostPath:
|
||||
path: /dev/kvm
|
||||
name: dev-kvm
|
||||
- hostPath:
|
||||
path: /dev/net/tun
|
||||
type: CharDevice
|
||||
name: dev-tun
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: macos
|
||||
spec:
|
||||
type: NodePort
|
||||
selector:
|
||||
name: macos
|
||||
internalTrafficPolicy: Cluster
|
||||
ports:
|
||||
- name: tcp-8006
|
||||
protocol: TCP
|
||||
- name: http
|
||||
port: 8006
|
||||
targetPort: 8006
|
||||
- name: tcp-5900
|
||||
protocol: TCP
|
||||
targetPort: 8006
|
||||
- name: vnc
|
||||
port: 5900
|
||||
protocol: TCP
|
||||
targetPort: 5900
|
||||
- name: udp-5900
|
||||
protocol: UDP
|
||||
port: 5900
|
||||
targetPort: 5900
|
||||
selector:
|
||||
app: macos
|
||||
type: ClusterIP
|
||||
|
|
|
|||
175
readme.md
175
readme.md
|
|
@ -1,4 +1,4 @@
|
|||
<h1 align="center">OSX<br />
|
||||
<h1 align="center">macOS<br />
|
||||
<div align="center">
|
||||
<a href="https://github.com/dockur/macos/"><img src="https://github.com/dockur/macos/raw/master/.github/logo.png" title="Logo" style="max-width:100%;" width="128" /></a>
|
||||
</div>
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
</div></h1>
|
||||
|
||||
OSX (macOS) inside a Docker container.
|
||||
MacOS inside a Docker container.
|
||||
|
||||
## Features ✨
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ OSX (macOS) inside a Docker container.
|
|||
|
||||
## Usage 🐳
|
||||
|
||||
Via Docker Compose:
|
||||
##### Via Docker Compose:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
|
|
@ -30,67 +30,85 @@ services:
|
|||
image: dockurr/macos
|
||||
container_name: macos
|
||||
environment:
|
||||
VERSION: "ventura"
|
||||
VERSION: "14"
|
||||
devices:
|
||||
- /dev/kvm
|
||||
- /dev/net/tun
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
ports:
|
||||
- 8006:8006
|
||||
- 5900:5900/tcp
|
||||
- 5900:5900/udp
|
||||
volumes:
|
||||
- ./macos:/storage
|
||||
restart: always
|
||||
stop_grace_period: 2m
|
||||
```
|
||||
|
||||
Via Docker CLI:
|
||||
##### Via Docker CLI:
|
||||
|
||||
```bash
|
||||
docker run -it --rm -p 8006:8006 --device=/dev/kvm --cap-add NET_ADMIN --stop-timeout 120 dockurr/macos
|
||||
docker run -it --rm --name macos -e "VERSION=14" -p 8006:8006 --device=/dev/kvm --device=/dev/net/tun --cap-add NET_ADMIN -v "${PWD:-.}/macos:/storage" --stop-timeout 120 docker.io/dockurr/macos
|
||||
```
|
||||
|
||||
Via Kubernetes:
|
||||
##### Via Kubernetes:
|
||||
|
||||
```shell
|
||||
kubectl apply -f kubernetes.yml
|
||||
kubectl apply -f https://raw.githubusercontent.com/dockur/macos/refs/heads/master/kubernetes.yml
|
||||
```
|
||||
|
||||
##### Via Github Codespaces:
|
||||
|
||||
[](https://codespaces.new/dockur/macos)
|
||||
|
||||
## FAQ 💬
|
||||
|
||||
### How do I use it?
|
||||
|
||||
Very simple! These are the steps:
|
||||
|
||||
- Start the container and connect to [port 8006](http://localhost:8006) using your web browser.
|
||||
- Start the container and connect to [port 8006](http://127.0.0.1:8006/) using your web browser.
|
||||
|
||||
- Choose `Disk Utility` and then select the largest `Apple Inc. VirtIO Block Media` disk.
|
||||
|
||||
- Click the `Erase` button to format the disk, and give it any recognizable name you like.
|
||||
- Click the `Erase` button to format the disk to APFS, and give it any name you like.
|
||||
|
||||
- Close the current window and proceed the installation by clicking `Reinstall macOS`.
|
||||
|
||||
- When prompted where you want to install it, select the disk you just created previously.
|
||||
- When prompted where you want to install it, select the disk you created previously.
|
||||
|
||||
- After all files are copied, select your region, language, and account settings.
|
||||
- After all files are copied, select your region, language, and keyboard settings.
|
||||
|
||||
- When the `Migration Assistant` wants to transfer data, select `Not now` (bottom left).
|
||||
|
||||
- On the `Apple ID` screen, select `Set Up Later` (bottom left) and then proceed using `Skip`.
|
||||
|
||||
- On the `Create a Computer Account` screen, fill in a username and password and `Continue`.
|
||||
|
||||
Enjoy your brand new machine, and don't forget to star this repo!
|
||||
|
||||
### How do I select the macOS version?
|
||||
### How do I select the version of macOS?
|
||||
|
||||
By default, macOS Ventura will be installed. But you can add the `VERSION` environment variable to your compose file, in order to specify an alternative macOS version to be downloaded:
|
||||
By default, macOS 14 (Sonoma) will be installed, but you can add the `VERSION` environment variable in order to specify an alternative:
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
VERSION: "ventura"
|
||||
VERSION: "15"
|
||||
```
|
||||
|
||||
Select from the values below:
|
||||
|
||||
| **Value** | **Version** |
|
||||
|----|-----|
|
||||
| `sonoma` | macOS Sonoma |
|
||||
| `ventura` | macOS Ventura |
|
||||
| `monterey` | macOS Monterey |
|
||||
| `big-sur` | macOS Big Sur |
|
||||
| **Value** | **Version** | **Name** |
|
||||
|-------------|----------------|------------------|
|
||||
| `15` | macOS 15 | Sequoia |
|
||||
| `14` | macOS 14 | Sonoma |
|
||||
| `13` | macOS 13 | Ventura |
|
||||
| `12` | macOS 12 | Monterey |
|
||||
| `11` | macOS 11 | Big Sur |
|
||||
|
||||
> [!NOTE]
|
||||
> Support for macOS 15 (Sequoia) is still in its infancy, as it does not allow you to sign in to your Apple Account yet.
|
||||
|
||||
### How do I change the storage location?
|
||||
|
||||
|
|
@ -98,10 +116,10 @@ kubectl apply -f kubernetes.yml
|
|||
|
||||
```yaml
|
||||
volumes:
|
||||
- /var/osx:/storage
|
||||
- ./macos:/storage
|
||||
```
|
||||
|
||||
Replace the example path `/var/osx` with the desired storage folder.
|
||||
Replace the example path `./macos` with the desired storage folder or named volume.
|
||||
|
||||
### How do I change the size of the disk?
|
||||
|
||||
|
|
@ -117,7 +135,7 @@ kubectl apply -f kubernetes.yml
|
|||
|
||||
### How do I change the amount of CPU or RAM?
|
||||
|
||||
By default, the container will be allowed to use a maximum of 2 CPU cores and 4 GB of RAM.
|
||||
By default, macOS will be allowed to use a single CPU core and 4 GB of RAM.
|
||||
|
||||
If you want to adjust this, you can specify the desired amount using the following environment variables:
|
||||
|
||||
|
|
@ -127,6 +145,73 @@ kubectl apply -f kubernetes.yml
|
|||
CPU_CORES: "4"
|
||||
```
|
||||
|
||||
> [!IMPORTANT]
|
||||
> If your system has an AMD processor (instead of Intel), it is not advisable to enable multiple cores before the installation is completed and you have verified that everything runs stable for a while. Because in many cases it will introduce issues, which are difficult to pinpoint if you do not have experience with its behavior on a single core first.
|
||||
|
||||
### How do I assign an individual IP address to the container?
|
||||
|
||||
By default, the container uses bridge networking, which shares the IP address with the host.
|
||||
|
||||
If you want to assign an individual IP address to the container, you can create a macvlan network as follows:
|
||||
|
||||
```bash
|
||||
docker network create -d macvlan \
|
||||
--subnet=192.168.0.0/24 \
|
||||
--gateway=192.168.0.1 \
|
||||
--ip-range=192.168.0.100/28 \
|
||||
-o parent=eth0 vlan
|
||||
```
|
||||
|
||||
Be sure to modify these values to match your local subnet.
|
||||
|
||||
Once you have created the network, change your compose file to look as follows:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
macos:
|
||||
container_name: macos
|
||||
..<snip>..
|
||||
networks:
|
||||
vlan:
|
||||
ipv4_address: 192.168.0.100
|
||||
|
||||
networks:
|
||||
vlan:
|
||||
external: true
|
||||
```
|
||||
|
||||
An added benefit of this approach is that you won't have to perform any port mapping anymore, since all ports will be exposed by default.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> This IP address won't be accessible from the Docker host due to the design of macvlan, which doesn't permit communication between the two. If this is a concern, you need to create a [second macvlan](https://blog.oddbit.com/post/2018-03-12-using-docker-macvlan-networks/#host-access) as a workaround.
|
||||
|
||||
### How can macOS acquire an IP address from my router?
|
||||
|
||||
After configuring the container for [macvlan](#how-do-i-assign-an-individual-ip-address-to-the-container), it is possible for macOS to become part of your home network by requesting an IP from your router, just like your other devices.
|
||||
|
||||
To enable this mode, in which the container and macOS will have separate IP addresses, add the following lines to your compose file:
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
DHCP: "Y"
|
||||
devices:
|
||||
- /dev/vhost-net
|
||||
device_cgroup_rules:
|
||||
- 'c *:* rwm'
|
||||
```
|
||||
|
||||
### How do I pass-through a disk?
|
||||
|
||||
It is possible to pass-through disk devices or partitions directly by adding them to your compose file in this way:
|
||||
|
||||
```yaml
|
||||
devices:
|
||||
- /dev/sdb:/disk1
|
||||
- /dev/sdc1:/disk2
|
||||
```
|
||||
|
||||
Use `/disk1` if you want it to become your main drive, and use `/disk2` and higher to add them as secondary drives.
|
||||
|
||||
### How do I pass-through a USB device?
|
||||
|
||||
To pass-through a USB device, first lookup its vendor and product id via the `lsusb` command, then add them to your compose file like this:
|
||||
|
|
@ -138,31 +223,59 @@ kubectl apply -f kubernetes.yml
|
|||
- /dev/bus/usb
|
||||
```
|
||||
|
||||
### How do I share files with the host?
|
||||
|
||||
To share files with the host, add the following volume to your compose file:
|
||||
|
||||
```yaml
|
||||
volumes:
|
||||
- ./example:/shared
|
||||
```
|
||||
|
||||
Then start macOS and execute the following command:
|
||||
|
||||
```shell
|
||||
sudo -S mount_9p shared
|
||||
```
|
||||
|
||||
In Finder’s menu bar, click on “Go – Computer” to access this shared folder, it will show the contents of `./example`.
|
||||
|
||||
### How do I verify if my system supports KVM?
|
||||
|
||||
To verify that your system supports KVM, run the following commands:
|
||||
First check if your software is compatible using this chart:
|
||||
|
||||
| **Product** | **Linux** | **Win11** | **Win10** | **macOS** |
|
||||
|---|---|---|---|---|
|
||||
| Docker CLI | ✅ | ✅ | ❌ | ❌ |
|
||||
| Docker Desktop | ❌ | ✅ | ❌ | ❌ |
|
||||
| Podman CLI | ✅ | ✅ | ❌ | ❌ |
|
||||
| Podman Desktop | ✅ | ✅ | ❌ | ❌ |
|
||||
|
||||
After that you can run the following commands in Linux to check your system:
|
||||
|
||||
```bash
|
||||
sudo apt install cpu-checker
|
||||
sudo kvm-ok
|
||||
```
|
||||
|
||||
If you receive an error from `kvm-ok` indicating that KVM acceleration can't be used, please check whether:
|
||||
If you receive an error from `kvm-ok` indicating that KVM cannot be used, please check whether:
|
||||
|
||||
- the virtualization extensions (`Intel VT-x` or `AMD SVM`) are enabled in your BIOS.
|
||||
|
||||
- you are running an operating system that supports them, like Linux or Windows 11 (macOS and Windows 10 do not unfortunately).
|
||||
|
||||
- you enabled "nested virtualization" if you are running the container inside a virtual machine.
|
||||
|
||||
- you are not using a cloud provider, as most of them do not allow nested virtualization for their VPS's.
|
||||
|
||||
If you didn't receive any error from `kvm-ok` at all, but the container still complains that `/dev/kvm` is missing, it might help to add `privileged: true` to your compose file (or `--privileged` to your `run` command), to rule out any permission issue.
|
||||
If you did not receive any error from `kvm-ok` but the container still complains about a missing KVM device, it could help to add `privileged: true` to your compose file (or `sudo` to your `docker` command) to rule out any permission issue.
|
||||
|
||||
### How do I run Windows in a container?
|
||||
|
||||
You can use [dockur/windows](https://github.com/dockur/windows) for that. It shares many of the same features, and even has completely automatic installation.
|
||||
|
||||
### How do I run a Linux desktop in a container?
|
||||
|
||||
You can use [qemus/qemu](https://github.com/qemus/qemu) in that case.
|
||||
|
||||
### Is this project legal?
|
||||
|
||||
Yes, this project contains only open-source code and does not distribute any copyrighted material. Neither does it try to circumvent any copyright protection measures. So under all applicable laws, this project will be considered legal.
|
||||
|
|
@ -171,7 +284,7 @@ kubectl apply -f kubernetes.yml
|
|||
|
||||
## Acknowledgements 🙏
|
||||
|
||||
Special thanks to [seitenca](https://github.com/seitenca), [OpenCore](https://github.com/acidanthera/OpenCorePkg), [OSX-KVM](https://github.com/kholia/OSX-KVM) and [KVM-Opencore](https://github.com/thenickdude/KVM-Opencore), this project would not exist without their invaluable work.
|
||||
Special thanks to [seitenca](https://github.com/seitenca), this project would not exist without her invaluable work.
|
||||
|
||||
## Stars 🌟
|
||||
[](https://starchart.cc/dockur/macos)
|
||||
|
|
@ -189,4 +302,4 @@ Special thanks to [seitenca](https://github.com/seitenca), [OpenCore](https://gi
|
|||
[Size]: https://img.shields.io/docker/image-size/dockurr/macos/latest?color=066da5&label=size
|
||||
[Pulls]: https://img.shields.io/docker/pulls/dockurr/macos.svg?style=flat&label=pulls&logo=docker
|
||||
[Version]: https://img.shields.io/docker/v/dockurr/macos/latest?arch=amd64&sort=semver&color=066da5
|
||||
[Package]: https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fipitio%2Fghcr-pulls%2Fmaster%2Findex.json&query=%24%5B%3F(%40.owner%3D%3D%22dockur%22%20%26%26%20%40.repo%3D%3D%22macos%22%20%26%26%20%40.image%3D%3D%22macos%22)%5D.pulls&logo=github&style=flat&color=066da5&label=pulls
|
||||
[Package]: https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fipitio.github.io%2Fbackage%2Fdockur%2Fmacos%2Fmacos.json&query=%24.downloads&logo=github&style=flat&color=066da5&label=pulls
|
||||
|
|
|
|||
210
src/boot.sh
210
src/boot.sh
|
|
@ -2,34 +2,32 @@
|
|||
set -Eeuo pipefail
|
||||
|
||||
# Docker environment variables
|
||||
: "${BOOT_MODE:="full"}" # Boot mode
|
||||
: "${SECURE:="off"}" # Secure boot
|
||||
: "${BOOT_MODE:="macos"}" # Boot mode
|
||||
|
||||
BOOT_DESC=""
|
||||
BOOT_OPTS=""
|
||||
SECURE="off"
|
||||
OVMF="/usr/share/OVMF"
|
||||
|
||||
case "${BOOT_MODE,,}" in
|
||||
"full" )
|
||||
msg="Configuring boot..."
|
||||
html "$msg"
|
||||
[[ "$DEBUG" == [Yy1]* ]] && echo "$msg"
|
||||
|
||||
case "${HEIGHT,,}" in
|
||||
"1080" )
|
||||
DEST="$PROCESS"
|
||||
BOOT_DESC=" 1920x1080"
|
||||
ROM="OVMF_CODE.fd"
|
||||
VARS="OVMF_VARS-1920x1080.fd"
|
||||
;;
|
||||
"hd" )
|
||||
"768" )
|
||||
DEST="${PROCESS}_hd"
|
||||
BOOT_DESC=" 1024x768"
|
||||
ROM="OVMF_CODE.fd"
|
||||
VARS="OVMF_VARS-1024x768.fd"
|
||||
;;
|
||||
"default" )
|
||||
BOOT_DESC=""
|
||||
*)
|
||||
ROM="OVMF_CODE.fd"
|
||||
VARS="OVMF_VARS.fd"
|
||||
DEST="${PROCESS}_default"
|
||||
;;
|
||||
*)
|
||||
error "Unknown BOOT_MODE, value \"${BOOT_MODE}\" is not recognized!" && exit 33
|
||||
DEST="${PROCESS}_${HEIGHT}"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
@ -47,49 +45,161 @@ DEST="$STORAGE/$DEST"
|
|||
|
||||
if [ ! -s "$DEST.rom" ] || [ ! -f "$DEST.rom" ]; then
|
||||
[ ! -s "$OVMF/$ROM" ] || [ ! -f "$OVMF/$ROM" ] && error "UEFI boot file ($OVMF/$ROM) not found!" && exit 44
|
||||
cp "$OVMF/$ROM" "$DEST.rom"
|
||||
if [[ "${LOGO:-}" == [Nn]* ]]; then
|
||||
cp "$OVMF/$ROM" "$DEST.tmp"
|
||||
else
|
||||
if ! /run/utk.bin "$OVMF/$ROM" replace_ffs LogoDXE "/var/www/img/${PROCESS,,}.ffs" save "$DEST.tmp"; then
|
||||
warn "failed to add custom logo to BIOS!"
|
||||
cp "$OVMF/$ROM" "$DEST.tmp"
|
||||
fi
|
||||
fi
|
||||
mv "$DEST.tmp" "$DEST.rom"
|
||||
! setOwner "$DEST.rom" && error "Failed to set the owner for \"$DEST.rom\" !"
|
||||
fi
|
||||
|
||||
if [ ! -s "$DEST.vars" ] || [ ! -f "$DEST.vars" ]; then
|
||||
[ ! -s "$OVMF/$VARS" ] || [ ! -f "$OVMF/$VARS" ]&& error "UEFI vars file ($OVMF/$VARS) not found!" && exit 45
|
||||
cp "$OVMF/$VARS" "$DEST.vars"
|
||||
cp "$OVMF/$VARS" "$DEST.tmp"
|
||||
mv "$DEST.tmp" "$DEST.vars"
|
||||
! setOwner "$DEST.vars" && error "Failed to set the owner for \"$DEST.vars\" !"
|
||||
fi
|
||||
|
||||
BOOT_OPTS+=" -drive if=pflash,format=raw,readonly=on,file=$DEST.rom"
|
||||
BOOT_OPTS+=" -drive if=pflash,format=raw,file=$DEST.vars"
|
||||
|
||||
# OpenCoreBoot
|
||||
BOOT_DRIVE_ID="OpenCore"
|
||||
BOOT_DRIVE="$STORAGE/boot.img"
|
||||
BOOT_VERSION="$STORAGE/boot.version"
|
||||
BOOT_FILE="/images/OpenCore.img.gz"
|
||||
BOOT_SIZE=$(stat -c%s "$BOOT_FILE")
|
||||
IMG="$STORAGE/boot.img"
|
||||
|
||||
CURRENT_SIZE=""
|
||||
if [ -f "$BOOT_VERSION" ]; then
|
||||
CURRENT_SIZE=$(<"$BOOT_VERSION")
|
||||
fi
|
||||
if [ ! -f "$IMG" ]; then
|
||||
|
||||
if [ "$CURRENT_SIZE" != "$BOOT_SIZE" ]; then
|
||||
rm -f "$BOOT_DRIVE" 2>/dev/null || true
|
||||
fi
|
||||
FILE="OpenCore.img"
|
||||
IMG="/tmp/$FILE"
|
||||
rm -f "$IMG"
|
||||
|
||||
if [ ! -f "$BOOT_DRIVE" ] || [ ! -s "$BOOT_DRIVE" ]; then
|
||||
msg="Extracting boot image"
|
||||
# OpenCoreBoot
|
||||
ISO="/opencore.iso"
|
||||
OUT="/tmp/extract"
|
||||
|
||||
rm -rf "$OUT"
|
||||
mkdir -p "$OUT"
|
||||
|
||||
msg="Building boot image"
|
||||
info "$msg..." && html "$msg..."
|
||||
gzip -dkc "$BOOT_FILE" > "$BOOT_DRIVE"
|
||||
echo "$BOOT_SIZE" > "$BOOT_VERSION"
|
||||
|
||||
[ ! -f "$ISO" ] && gzip -dk "$ISO.gz"
|
||||
|
||||
if [ ! -f "$ISO" ] || [ ! -s "$ISO" ]; then
|
||||
error "Could not find image file \"$ISO\"." && exit 10
|
||||
fi
|
||||
|
||||
START=$(sfdisk -l "$ISO" | grep -i -m 1 "EFI System" | awk '{print $2}')
|
||||
mcopy -bspmQ -i "$ISO@@${START}S" ::EFI "$OUT"
|
||||
|
||||
CFG="$OUT/EFI/OC/config.plist"
|
||||
|
||||
PLIST="/assets/config.plist"
|
||||
[ -f "/config.plist" ] && PLIST="/config.plist"
|
||||
|
||||
cp "$PLIST" "$CFG"
|
||||
|
||||
ROM="${MAC//[^[:alnum:]]/}"
|
||||
ROM="${ROM,,}"
|
||||
BROM=$(echo "$ROM" | xxd -r -p | base64)
|
||||
RESOLUTION="${WIDTH}x${HEIGHT}@32"
|
||||
|
||||
sed -r -i -e 's|<data>m7zhIYfl</data>|<data>'"${BROM}"'</data>|g' "$CFG"
|
||||
sed -r -i -e 's|<string>iMacPro1,1</string>|<string>'"${MODEL}"'</string>|g' "$CFG"
|
||||
sed -r -i -e 's|<string>C02TM2ZBHX87</string>|<string>'"${SN}"'</string>|g' "$CFG"
|
||||
sed -r -i -e 's|<string>C02717306J9JG361M</string>|<string>'"${MLB}"'</string>|g' "$CFG"
|
||||
sed -r -i -e 's|<string>1920x1080@32</string>|<string>'"${RESOLUTION}"'</string>|g' "$CFG"
|
||||
sed -r -i -e 's|<string>007076A6-F2A2-4461-BBE5-BAD019F8025A</string>|<string>'"${UUID}"'</string>|g' "$CFG"
|
||||
|
||||
# Build image
|
||||
|
||||
MB=256
|
||||
CLUSTER=4
|
||||
START=2048
|
||||
SECTOR=512
|
||||
FIRST_LBA=34
|
||||
|
||||
SIZE=$(( MB*1024*1024 ))
|
||||
OFFSET=$(( START*SECTOR ))
|
||||
TOTAL=$(( SIZE-(FIRST_LBA*SECTOR) ))
|
||||
LAST_LBA=$(( TOTAL/SECTOR ))
|
||||
COUNT=$(( LAST_LBA-(START-1) ))
|
||||
|
||||
if ! truncate -s "$SIZE" "$IMG"; then
|
||||
rm -f "$IMG"
|
||||
error "Could not allocate space to create image $IMG ." && exit 11
|
||||
fi
|
||||
|
||||
PART="/tmp/partition.fdisk"
|
||||
|
||||
{ echo "label: gpt"
|
||||
echo "label-id: 1ACB1E00-3B8F-4B2A-86A4-D99ED21DCAEB"
|
||||
echo "device: $FILE"
|
||||
echo "unit: sectors"
|
||||
echo "first-lba: $FIRST_LBA"
|
||||
echo "last-lba: $LAST_LBA"
|
||||
echo "sector-size: $SECTOR"
|
||||
echo ""
|
||||
echo "${FILE}1 : start=$START, size=$COUNT, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=05157F6E-0AE8-4D1A-BEA5-AC172453D02C, name=\"primary\""
|
||||
|
||||
} > "$PART"
|
||||
|
||||
sfdisk -q "$IMG" < "$PART"
|
||||
echo "drive c: file=\"$IMG\" partition=0 offset=$OFFSET" > /etc/mtools.conf
|
||||
|
||||
mformat -F -M "$SECTOR" -c "$CLUSTER" -T "$COUNT" -v "EFI" "C:"
|
||||
mcopy -bspmQ "$OUT/EFI" "C:"
|
||||
|
||||
rm -rf "$OUT"
|
||||
|
||||
info ""
|
||||
info "Model: $MODEL"
|
||||
info "Rom: $ROM"
|
||||
info "Serial: $SN"
|
||||
info "Board: $MLB"
|
||||
info ""
|
||||
|
||||
fi
|
||||
|
||||
DISK_OPTS+=" -device virtio-blk-pci,drive=${BOOT_DRIVE_ID},scsi=off,bus=pcie.0,addr=0x5,bootindex=$BOOT_INDEX"
|
||||
DISK_OPTS+=" -drive file=$BOOT_DRIVE,id=$BOOT_DRIVE_ID,format=raw,cache=unsafe,readonly=on,if=none"
|
||||
! setOwner "$IMG" && error "Failed to set the owner for \"$IMG\" !"
|
||||
|
||||
BOOT_DRIVE_ID="OpenCore"
|
||||
|
||||
DISK_OPTS+=" -device virtio-blk-pci,drive=${BOOT_DRIVE_ID},bus=pcie.0,addr=0x5,bootindex=$BOOT_INDEX"
|
||||
DISK_OPTS+=" -drive file=$IMG,id=$BOOT_DRIVE_ID,format=raw,cache=unsafe,readonly=on,if=none"
|
||||
|
||||
CPU_VENDOR=$(lscpu | awk '/Vendor ID/{print $3}')
|
||||
DEFAULT_FLAGS="vendor=GenuineIntel,vmware-cpuid-freq=on,-pdpe1gb"
|
||||
DEFAULT_FLAGS="vendor=GenuineIntel,vmx=off,vmware-cpuid-freq=on,-pdpe1gb"
|
||||
|
||||
if [[ "$CPU_VENDOR" == "AuthenticAMD" || "${KVM:-}" == [Nn]* ]]; then
|
||||
|
||||
if [ -z "${CPU_MODEL:-}" ]; then
|
||||
|
||||
case "${VERSION,,}" in
|
||||
"ventura" | "13"* )
|
||||
CPU_MODEL="Haswell-noTSX" ;;
|
||||
"monterey" | "12"* )
|
||||
CPU_MODEL="Haswell-noTSX" ;;
|
||||
"bigsur" | "big-sur" | "11"* )
|
||||
CPU_MODEL="Haswell-noTSX" ;;
|
||||
"catalina" | "10"* )
|
||||
CPU_MODEL="Haswell-noTSX" ;;
|
||||
*)
|
||||
CPU_MODEL="Skylake-Client-v4"
|
||||
DEFAULT_FLAGS+=",-spec-ctrl"
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
if [[ "${KVM:-}" == [Nn]* ]] || [[ "${ARCH,,}" != "amd64" ]] || [[ "$OSTYPE" =~ ^darwin ]]; then
|
||||
DEFAULT_FLAGS+=",-pcid,-tsc-deadline,-invpcid,-xsavec,-xsaves,+ssse3,+sse4.2,+popcnt,+avx,+avx2,+aes,+fma,+bmi1,+bmi2,+smep,+xsave,+xsaveopt,+xgetbv1,+movbe,+rdrand,check"
|
||||
else
|
||||
DEFAULT_FLAGS+=",+pcid,+ssse3,+sse4.2,+popcnt,+avx,+avx2,+aes,+fma,+bmi1,+bmi2,+smep,+xsave,+xsavec,+xsaves,+xsaveopt,+xgetbv1,+movbe,+rdrand,check"
|
||||
fi
|
||||
|
||||
if [[ "$CPU_VENDOR" != "GenuineIntel" ]] || [[ "${KVM:-}" == [Nn]* ]]; then
|
||||
[ -z "${CPU_MODEL:-}" ] && CPU_MODEL="Haswell-noTSX"
|
||||
DEFAULT_FLAGS+=",+pcid,+ssse3,+sse4.2,+popcnt,+avx,+avx2,+aes,+fma,+bmi1,+bmi2,+smep,+xsave,+xsavec,+xsaveopt,+xgetbv1,+movbe,+rdrand,check"
|
||||
fi
|
||||
|
||||
if [ -z "${CPU_FLAGS:-}" ]; then
|
||||
|
|
@ -98,12 +208,34 @@ else
|
|||
CPU_FLAGS="$DEFAULT_FLAGS,$CPU_FLAGS"
|
||||
fi
|
||||
|
||||
SM_BIOS=""
|
||||
CLOCKSOURCE="tsc"
|
||||
[[ "${ARCH,,}" == "arm64" ]] && CLOCKSOURCE="arch_sys_counter"
|
||||
CLOCK="/sys/devices/system/clocksource/clocksource0/current_clocksource"
|
||||
|
||||
if [ ! -f "$CLOCK" ]; then
|
||||
warn "file \"$CLOCK\" cannot not found?"
|
||||
else
|
||||
result=$(<"$CLOCK")
|
||||
result="${result//[![:print:]]/}"
|
||||
case "${result,,}" in
|
||||
"${CLOCKSOURCE,,}" )
|
||||
if [[ "$CPU_VENDOR" == "GenuineIntel" && "$CPU_CORES" == "1" && "${KVM:-}" != [Nn]* ]]; then
|
||||
CPU_CORES="2"
|
||||
fi ;;
|
||||
"kvm-clock" ) warn "Nested KVM virtualization detected, this might cause issues running macOS!" ;;
|
||||
"hyperv_clocksource_tsc_page" ) info "Nested Hyper-V virtualization detected, this might cause issues running macOS!" ;;
|
||||
"hpet" ) warn "unsupported clock source detected: '$result'. Please set host clock source to '$CLOCKSOURCE', otherwise it will cause issues running macOS!" ;;
|
||||
*) warn "unexpected clock source detected: '$result'. Please set host clock source to '$CLOCKSOURCE', otherwise it will cause issues running macOS!" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case "$CPU_CORES" in
|
||||
"" | "0" | "3" ) CPU_CORES="2" ;;
|
||||
"5" ) CPU_CORES="4" ;;
|
||||
"9" ) CPU_CORES="8" ;;
|
||||
esac
|
||||
|
||||
|
||||
case "$CPU_CORES" in
|
||||
"1" | "2" | "4" | "8" ) SMP="$CPU_CORES,sockets=1,dies=1,cores=$CPU_CORES,threads=1" ;;
|
||||
"6" | "7" ) SMP="$CPU_CORES,sockets=3,dies=1,cores=2,threads=1" ;;
|
||||
|
|
|
|||
77
src/build.sh
77
src/build.sh
|
|
@ -1,77 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
DST="/images"
|
||||
OUT="/tmp/extract"
|
||||
|
||||
rm -rf "$OUT"
|
||||
rm -rf "$DST"
|
||||
|
||||
mkdir -p "$OUT"
|
||||
mkdir -p "$DST"
|
||||
|
||||
echo "Extracting template image..."
|
||||
|
||||
if [ ! -f "$1" ] || [ ! -s "$1" ]; then
|
||||
echo "Could not find image file \"$1\"." && exit 10
|
||||
fi
|
||||
|
||||
START=$(sfdisk -l "$1" | grep -i -m 1 "EFI System" | awk '{print $2}')
|
||||
mcopy -bspmQ -i "$1@@${START}S" ::EFI "$OUT"
|
||||
|
||||
echo "Building OpenCore image..."
|
||||
|
||||
cp "$2" "$OUT/EFI/OC/"
|
||||
|
||||
MB=256
|
||||
CLUSTER=4
|
||||
START=2048
|
||||
SECTOR=512
|
||||
FIRST_LBA=34
|
||||
|
||||
SIZE=$(( MB*1024*1024 ))
|
||||
OFFSET=$(( START*SECTOR ))
|
||||
TOTAL=$(( SIZE-(FIRST_LBA*SECTOR) ))
|
||||
LAST_LBA=$(( TOTAL/SECTOR ))
|
||||
COUNT=$(( LAST_LBA-(START-1) ))
|
||||
|
||||
FILE="OpenCore.img"
|
||||
IMG="/tmp/$FILE"
|
||||
rm -f "$IMG"
|
||||
|
||||
if ! truncate -s "$SIZE" "$IMG"; then
|
||||
rm -f "$IMG"
|
||||
echo "Could not allocate file $IMG for the OpenCore image." && exit 11
|
||||
fi
|
||||
|
||||
PART="/tmp/partition.fdisk"
|
||||
|
||||
{ echo "label: gpt"
|
||||
echo "label-id: 1ACB1E00-3B8F-4B2A-86A4-D99ED21DCAEB"
|
||||
echo "device: $FILE"
|
||||
echo "unit: sectors"
|
||||
echo "first-lba: $FIRST_LBA"
|
||||
echo "last-lba: $LAST_LBA"
|
||||
echo "sector-size: $SECTOR"
|
||||
echo ""
|
||||
echo "${FILE}1 : start=$START, size=$COUNT, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=05157F6E-0AE8-4D1A-BEA5-AC172453D02C, name=\"primary\""
|
||||
|
||||
} > "$PART"
|
||||
|
||||
sfdisk -q "$IMG" < "$PART"
|
||||
|
||||
echo "drive c: file=\"$IMG\" partition=0 offset=$OFFSET" > /etc/mtools.conf
|
||||
|
||||
mformat -F -M "$SECTOR" -c "$CLUSTER" -T "$COUNT" -v "EFI" "C:"
|
||||
|
||||
echo "Copying files to image..."
|
||||
|
||||
mcopy -bspmQ "$OUT/EFI" "C:"
|
||||
rm -rf "$OUT"
|
||||
|
||||
echo "Compressing image..."
|
||||
|
||||
gzip -c "$IMG" > "$DST/$FILE.gz"
|
||||
rm -f "$IMG"
|
||||
|
||||
echo "Finished succesfully!"
|
||||
11
src/entry.sh
11
src/entry.sh
|
|
@ -1,22 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
: "${APP:="macOS"}"
|
||||
: "${VGA:="vmware"}"
|
||||
: "${DISK_TYPE:="blk"}"
|
||||
|
||||
APP="macOS"
|
||||
SUPPORT="https://github.com/dockur/macos"
|
||||
: "${PLATFORM:="x64"}"
|
||||
: "${SUPPORT:="https://github.com/dockur/macos"}"
|
||||
|
||||
cd /run
|
||||
|
||||
. start.sh # Startup hook
|
||||
. utils.sh # Load functions
|
||||
. reset.sh # Initialize system
|
||||
. server.sh # Start webserver
|
||||
. install.sh # Get the OSX images
|
||||
. disk.sh # Initialize disks
|
||||
. display.sh # Initialize graphics
|
||||
. network.sh # Initialize network
|
||||
. boot.sh # Configure boot
|
||||
. proc.sh # Initialize processor
|
||||
. memory.sh # Check available memory
|
||||
. config.sh # Configure arguments
|
||||
. finish.sh # Finish initialization
|
||||
|
||||
trap - ERR
|
||||
|
||||
|
|
|
|||
285
src/install.sh
285
src/install.sh
|
|
@ -2,23 +2,145 @@
|
|||
set -Eeuo pipefail
|
||||
|
||||
# Docker environment variables
|
||||
: "${VERSION:="ventura"}" # OSX Version
|
||||
|
||||
TMP="$STORAGE/tmp"
|
||||
: "${SN:=""}" # Device serial
|
||||
: "${MLB:=""}" # Board serial
|
||||
: "${MAC:=""}" # MAC address
|
||||
: "${UUID:=""}" # Unique ID
|
||||
: "${VERSION:=""}" # OSX Version
|
||||
: "${WIDTH:="1920"}" # Horizontal
|
||||
: "${HEIGHT:="1080"}" # Vertical
|
||||
: "${MODEL:="iMacPro1,1"}" # Device model
|
||||
|
||||
BASE_IMG_ID="InstallMedia"
|
||||
BASE_IMG="$STORAGE/base.dmg"
|
||||
BASE_VERSION="$STORAGE/$PROCESS.version"
|
||||
|
||||
downloadImage() {
|
||||
function getRandom() {
|
||||
local length="${1}"
|
||||
local result=""
|
||||
local chars=("0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F")
|
||||
|
||||
for ((i=0; i<length; i++)); do
|
||||
result+="${chars[$((RANDOM % 16))]}"
|
||||
done
|
||||
|
||||
echo "$result"
|
||||
return 0
|
||||
}
|
||||
|
||||
delay() {
|
||||
|
||||
local i
|
||||
local delay="$1"
|
||||
local msg="Retrying failed download in X seconds..."
|
||||
|
||||
info "${msg/X/$delay}"
|
||||
|
||||
for i in $(seq "$delay" -1 1); do
|
||||
html "${msg/X/$i}"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function download() {
|
||||
local info=""
|
||||
local dest="$1"
|
||||
local board="$2"
|
||||
local version="$3"
|
||||
local type="latest"
|
||||
local appleSession=""
|
||||
local downloadLink=""
|
||||
local downloadSession=""
|
||||
local mlb="00000000000000000"
|
||||
local rc total size progress
|
||||
|
||||
local msg="Downloading macOS ${version^}"
|
||||
info "$msg recovery image..." && html "$msg..."
|
||||
|
||||
appleSession=$(curl --disable -v -H "Host: osrecovery.apple.com" \
|
||||
-H "Connection: close" \
|
||||
-A "InternetRecovery/1.0" https://osrecovery.apple.com/ 2>&1 | tr ';' '\n' | awk -F'session=|;' '{print $2}' | grep 1)
|
||||
info=$(curl --disable -s -X POST -H "Host: osrecovery.apple.com" \
|
||||
-H "Connection: close" \
|
||||
-A "InternetRecovery/1.0" \
|
||||
-b "session=\"${appleSession}\"" \
|
||||
-H "Content-Type: text/plain" \
|
||||
-d $'cid='"$(getRandom 16)"$'\nsn='"${mlb}"$'\nbid='"${board}"$'\nk='"$(getRandom 64)"$'\nfg='"$(getRandom 64)"$'\nos='"${type}" \
|
||||
https://osrecovery.apple.com/InstallationPayload/RecoveryImage | tr ' ' '\n')
|
||||
|
||||
downloadLink=$(echo "$info" | grep 'oscdn' | grep 'dmg')
|
||||
downloadSession=$(echo "$info" | grep 'expires' | grep 'dmg')
|
||||
|
||||
if [ -z "$downloadLink" ] || [ -z "$downloadSession" ]; then
|
||||
|
||||
local code="99"
|
||||
msg="Failed to connect to the Apple servers, reason:"
|
||||
|
||||
curl --silent --max-time 10 --output /dev/null --fail -H "Host: osrecovery.apple.com" -H "Connection: close" -A "InternetRecovery/1.0" https://osrecovery.apple.com/ || {
|
||||
code="$?"
|
||||
}
|
||||
|
||||
case "${code,,}" in
|
||||
"6" ) error "$msg could not resolve host!" ;;
|
||||
"7" ) error "$msg no internet connection available!" ;;
|
||||
"28" ) error "$msg connection timed out!" ;;
|
||||
"99" )
|
||||
[ -n "$info" ] && echo "$info" && echo
|
||||
error "$msg unknown error" ;;
|
||||
*) error "$msg $code" ;;
|
||||
esac
|
||||
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check if running with interactive TTY or redirected to docker log
|
||||
if [ -t 1 ]; then
|
||||
progress="--progress=bar:noscroll"
|
||||
else
|
||||
progress="--progress=dot:giga"
|
||||
fi
|
||||
|
||||
rm -f "$dest"
|
||||
/run/progress.sh "$dest" "0" "$msg ([P])..." &
|
||||
|
||||
{ wget "$downloadLink" -O "$dest" -q --header "Host: oscdn.apple.com" --header "Connection: close" --header "User-Agent: InternetRecovery/1.0" --header "Cookie: AssetToken=${downloadSession}" --timeout=30 --no-http-keep-alive --show-progress "$progress"; rc=$?; } || :
|
||||
|
||||
fKill "progress.sh"
|
||||
|
||||
if (( rc == 0 )) && [ -f "$dest" ]; then
|
||||
total=$(stat -c%s "$dest")
|
||||
size=$(formatBytes "$total")
|
||||
if [ "$total" -lt 100000 ]; then
|
||||
error "Invalid recovery image, file is only $size ?" && return 1
|
||||
fi
|
||||
html "Download finished successfully..."
|
||||
return 0
|
||||
fi
|
||||
|
||||
msg="Failed to download $downloadLink"
|
||||
(( rc == 3 )) && error "$msg , cannot write file (disk full?)" && return 1
|
||||
(( rc == 4 )) && error "$msg , network failure!" && return 1
|
||||
(( rc == 8 )) && error "$msg , server issued an error response!" && return 1
|
||||
|
||||
error "$msg , reason: $rc"
|
||||
return 1
|
||||
}
|
||||
|
||||
install() {
|
||||
|
||||
local board
|
||||
local version="$1"
|
||||
local file="BaseSystem"
|
||||
local path="$TMP/$file.dmg"
|
||||
local dest="$2"
|
||||
|
||||
case "${version,,}" in
|
||||
"tahoe" | "26"* | "16"* )
|
||||
board="Mac-CFF7D910A743CAAF" ;;
|
||||
"sequoia" | "15"* )
|
||||
board="Mac-937A206F2EE63C01" ;;
|
||||
"sonoma" | "14"* )
|
||||
board="Mac-A61BADE1FDAD7B05" ;;
|
||||
board="Mac-827FAC58A8FDFA22" ;;
|
||||
"ventura" | "13"* )
|
||||
board="Mac-4B682C642B45593E" ;;
|
||||
"monterey" | "12"* )
|
||||
|
|
@ -32,55 +154,142 @@ downloadImage() {
|
|||
return 1 ;;
|
||||
esac
|
||||
|
||||
local msg="Downloading macOS ${version^}"
|
||||
info "$msg recovery image..." && html "$msg..."
|
||||
rm -f "$dest"
|
||||
|
||||
rm -rf "$TMP"
|
||||
mkdir -p "$TMP"
|
||||
|
||||
/run/progress.sh "$path" "" "$msg ([P])..." &
|
||||
|
||||
if ! /run/macrecovery.py -b "$board" -n "$file" -o "$TMP" download; then
|
||||
error "Failed to fetch macOS \"${version^}\" recovery image with board id \"$board\"!"
|
||||
fKill "progress.sh"
|
||||
return 1
|
||||
if ! makeDir "$STORAGE"; then
|
||||
error "Failed to create directory \"$STORAGE\" !" && return 1
|
||||
fi
|
||||
|
||||
fKill "progress.sh"
|
||||
find "$STORAGE" -maxdepth 1 -type f \( -iname '*.rom' -or -iname '*.vars' \) -delete
|
||||
find "$STORAGE" -maxdepth 1 -type f \( -iname 'data.*' -or -iname 'macos.*' \) -delete
|
||||
|
||||
if [ ! -f "$path" ] || [ ! -s "$path" ]; then
|
||||
error "Failed to find file \"$path\" !"
|
||||
return 1
|
||||
if [ -f "/boot.dmg" ]; then
|
||||
cp "/boot.dmg" "$dest"
|
||||
return 0
|
||||
fi
|
||||
|
||||
mv -f "$path" "$BASE_IMG"
|
||||
rm -rf "$TMP"
|
||||
local file="$STORAGE/boot.dmg"
|
||||
|
||||
if ! download "$file" "$board" "$version"; then
|
||||
delay 5
|
||||
if ! download "$file" "$board" "$version"; then
|
||||
rm -f "$file"
|
||||
exit 60
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$version" > "$BASE_VERSION"
|
||||
mv -f "$file" "$dest"
|
||||
return 0
|
||||
}
|
||||
|
||||
generateID() {
|
||||
|
||||
local file="$STORAGE/$PROCESS.id"
|
||||
|
||||
[ -n "$UUID" ] && return 0
|
||||
[ -s "$file" ] && UUID=$(<"$file")
|
||||
UUID="${UUID//[![:print:]]/}"
|
||||
[ -n "$UUID" ] && return 0
|
||||
|
||||
UUID=$(cat /proc/sys/kernel/random/uuid 2> /dev/null || uuidgen --random)
|
||||
UUID="${UUID^^}"
|
||||
UUID="${UUID//[![:print:]]/}"
|
||||
|
||||
echo "$UUID" > "$file"
|
||||
! setOwner "$file" && error "Failed to set the owner for \"$file\" !"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
generateAddress() {
|
||||
|
||||
local file="$STORAGE/$PROCESS.mac"
|
||||
|
||||
[ -n "$MAC" ] && return 0
|
||||
[ -s "$file" ] && MAC=$(<"$file")
|
||||
MAC="${MAC//[![:print:]]/}"
|
||||
[ -n "$MAC" ] && return 0
|
||||
|
||||
# Generate Apple MAC address based on Docker container ID in hostname
|
||||
MAC=$(echo "$HOST" | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/00:16:cb:\3:\4:\5/')
|
||||
MAC="${MAC^^}"
|
||||
|
||||
echo "$MAC" > "$file"
|
||||
! setOwner "$file" && error "Failed to set the owner for \"$file\" !"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
generateSerial() {
|
||||
|
||||
local file="$STORAGE/$PROCESS.sn"
|
||||
local file2="$STORAGE/$PROCESS.mlb"
|
||||
|
||||
[ -n "$SN" ] && [ -n "$MLB" ] && return 0
|
||||
[ -s "$file" ] && SN=$(<"$file")
|
||||
[ -s "$file2" ] && MLB=$(<"$file2")
|
||||
SN="${SN//[![:print:]]/}"
|
||||
MLB="${MLB//[![:print:]]/}"
|
||||
[ -n "$SN" ] && [ -n "$MLB" ] && return 0
|
||||
|
||||
# Generate unique serial numbers for machine
|
||||
SN=$(/usr/local/bin/macserial --num 1 --model "${MODEL}" 2>/dev/null)
|
||||
|
||||
SN="${SN##*$'\n'}"
|
||||
[[ "$SN" != *" | "* ]] && error "$SN" && return 1
|
||||
|
||||
MLB=${SN#*|}
|
||||
MLB="${MLB#"${MLB%%[![:space:]]*}"}"
|
||||
SN="${SN%%|*}"
|
||||
SN="${SN%"${SN##*[![:space:]]}"}"
|
||||
|
||||
echo "$SN" > "$file"
|
||||
echo "$MLB" > "$file2"
|
||||
|
||||
! setOwner "$file" && error "Failed to set the owner for \"$file\" !"
|
||||
! setOwner "$file2" && error "Failed to set the owner for \"$file2\" !"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
if [[ "${VERSION}" == \"*\" || "${VERSION}" == \'*\' ]]; then
|
||||
VERSION="${VERSION:1:-1}"
|
||||
fi
|
||||
|
||||
VERSION=$(expr "$VERSION" : "^\ *\(.*[^ ]\)\ *$")
|
||||
|
||||
if [ -z "$VERSION" ]; then
|
||||
|
||||
VERSION="14"
|
||||
warn "no value specified for the VERSION variable, defaulting to \"${VERSION}\"."
|
||||
|
||||
fi
|
||||
|
||||
if [ ! -f "$BASE_IMG" ] || [ ! -s "$BASE_IMG" ]; then
|
||||
if ! downloadImage "$VERSION"; then
|
||||
rm -rf "$TMP"
|
||||
exit 34
|
||||
|
||||
STORAGE="$STORAGE/${VERSION,,}"
|
||||
BASE_IMG="$STORAGE/base.dmg"
|
||||
|
||||
if [ ! -f "$BASE_IMG" ] || [ ! -s "$BASE_IMG" ]; then
|
||||
! install "$VERSION" "$BASE_IMG" && exit 34
|
||||
! setOwner "$BASE_IMG" && error "Failed to set the owner for \"$BASE_IMG\" !"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
STORED_VERSION=""
|
||||
if [ -f "$BASE_VERSION" ]; then
|
||||
STORED_VERSION=$(<"$BASE_VERSION")
|
||||
if ! generateID; then
|
||||
error "Failed to generate UUID!" && exit 35
|
||||
fi
|
||||
|
||||
if [ "$VERSION" != "$STORED_VERSION" ]; then
|
||||
info "Different version detected, switching base image from \"$STORED_VERSION\" to \"$VERSION\""
|
||||
if ! downloadImage "$VERSION"; then
|
||||
rm -rf "$TMP"
|
||||
exit 34
|
||||
fi
|
||||
if ! generateSerial; then
|
||||
error "Failed to generate serial number!" && exit 36
|
||||
fi
|
||||
|
||||
DISK_OPTS="-device virtio-blk-pci,drive=${BASE_IMG_ID},scsi=off,bus=pcie.0,addr=0x6"
|
||||
if ! generateAddress; then
|
||||
error "Failed to generate MAC address!" && exit 37
|
||||
fi
|
||||
|
||||
DISK_OPTS="-device virtio-blk-pci,drive=${BASE_IMG_ID},bus=pcie.0,addr=0x6"
|
||||
DISK_OPTS+=" -drive file=$BASE_IMG,id=$BASE_IMG_ID,format=dmg,cache=unsafe,readonly=on,if=none"
|
||||
|
||||
return 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue