mirror of
https://github.com/dockur/macos.git
synced 2026-03-11 08:34:24 +00:00
feat: Generate Apple MAC address (#124)
This commit is contained in:
parent
f6831a5ba6
commit
fba0a66658
2 changed files with 47 additions and 2 deletions
|
|
@ -86,7 +86,9 @@ kubectl apply -f https://raw.githubusercontent.com/dockur/macos/refs/heads/maste
|
|||
|
||||
### How do I select the macOS version?
|
||||
|
||||
By default, macOS 13 (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 13 (Ventura) will be installed, as it offers the best performance.
|
||||
|
||||
But you can add the `VERSION` environment variable to your compose file, in order to specify an alternative macOS version to be downloaded:
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
|
|
|
|||
|
|
@ -2,7 +2,13 @@
|
|||
set -Eeuo pipefail
|
||||
|
||||
# Docker environment variables
|
||||
: "${VERSION:="ventura"}" # OSX Version
|
||||
|
||||
: "${SN:=""}"
|
||||
: "${MLB:=""}"
|
||||
: "${MAC:=""}"
|
||||
: "${UUID:=""}"
|
||||
: "${MODEL:="iMacPro1,1"}"
|
||||
: "${VERSION:="13"}" # OSX Version
|
||||
|
||||
TMP="$STORAGE/tmp"
|
||||
BASE_IMG_ID="InstallMedia"
|
||||
|
|
@ -62,6 +68,35 @@ downloadImage() {
|
|||
return 0
|
||||
}
|
||||
|
||||
generateID() {
|
||||
|
||||
local file="$STORAGE/$PROCESS.id"
|
||||
|
||||
[ -n "$UUID" ] && return 0
|
||||
[ -s "$file" ] && UUID=$(<"$file")
|
||||
[ -n "$UUID" ] && return 0
|
||||
|
||||
UUID=$(cat /proc/sys/kernel/random/uuid)
|
||||
echo "${UUID^^}" > "$file"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
generateAddress() {
|
||||
|
||||
local file="$STORAGE/$PROCESS.mac"
|
||||
|
||||
[ -n "$MAC" ] && return 0
|
||||
[ -s "$file" ] && MAC=$(<"$file")
|
||||
[ -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/')
|
||||
echo "${MAC^^}" > "$file"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
if [ ! -f "$BASE_IMG" ] || [ ! -s "$BASE_IMG" ]; then
|
||||
if ! downloadImage "$VERSION"; then
|
||||
rm -rf "$TMP"
|
||||
|
|
@ -82,6 +117,14 @@ if [ "$VERSION" != "$STORED_VERSION" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
if !generateID; then
|
||||
error "Failed to generate UUID!" && exit 35
|
||||
fi
|
||||
|
||||
if !generateAddress; then
|
||||
error "Failed to generate MAC address!" && exit 36
|
||||
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"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue