From d81b960b1a7b483371322e3823eb949d516cf1cb Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 15 Sep 2025 17:34:04 +0200 Subject: [PATCH 1/2] feat: Seperate subfolders for each version Allows for easier version management as there is no need to clear the /storage folder anymore when switching between macOS releases. --- src/install.sh | 51 +++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/src/install.sh b/src/install.sh index 82943f0b..379dd672 100644 --- a/src/install.sh +++ b/src/install.sh @@ -7,14 +7,13 @@ set -Eeuo pipefail : "${MLB:=""}" # Board serial : "${MAC:=""}" # MAC address : "${UUID:=""}" # Unique ID +: "${VERSION:=""}" # OSX Version : "${WIDTH:="1920"}" # Horizontal : "${HEIGHT:="1080"}" # Vertical -: "${VERSION:="13"}" # OSX Version : "${MODEL:="iMacPro1,1"}" # Device model BASE_IMG_ID="InstallMedia" BASE_IMG="$STORAGE/base.dmg" -BASE_VERSION="$STORAGE/$PROCESS.version" function getRandom() { local length="${1}" @@ -117,7 +116,8 @@ download() { local board local version="$1" - + local dest="$2" + case "${version,,}" in "sequoia" | "15"* ) board="Mac-937A206F2EE63C01" ;; @@ -136,15 +136,21 @@ download() { return 1 ;; esac + rm -f "$dest" + if [ -f "/boot.dmg" ]; then - cp "/boot.dmg" "$BASE_IMG" - else - local file="/BaseSystem.dmg" - ! downloadImage "$file" "$board" "$version" && exit 60 - mv -f "$file" "$BASE_IMG" + cp "/boot.dmg" "$dest" + return 0 + fi + + local file="$STORAGE/boot.dmg" + + if ! downloadImage "$file" "$board" "$version"; then + rm -f "$file" + exit 60 fi - echo "$version" > "$BASE_VERSION" + mv -f "$file" "$dest" return 0 } @@ -216,21 +222,24 @@ if [[ "${VERSION}" == \"*\" || "${VERSION}" == \'*\' ]]; then fi VERSION=`expr "$VERSION" : "^\ *\(.*[^ ]\)\ *$"` -[ -z "$VERSION" ] && VERSION="13" - -if [ ! -f "$BASE_IMG" ] || [ ! -s "$BASE_IMG" ]; then - ! download "$VERSION" && exit 34 -fi -STORED_VERSION="" -if [ -f "$BASE_VERSION" ]; then - STORED_VERSION=$(<"$BASE_VERSION") - STORED_VERSION="${STORED_VERSION//[![:print:]]/}" +if [ -z "$VERSION" ]; then + + VERSION="13" + warn "no value specified for the VERSION variable, defaulting to \"${VERSION}\"." + fi -if [ "$VERSION" != "$STORED_VERSION" ]; then - info "Different version detected, switching base image from \"$STORED_VERSION\" to \"$VERSION\"" - ! download "$VERSION" && exit 34 +if [ ! -f "$BASE_IMG" ] || [ ! -s "$BASE_IMG" ]; then + + STORAGE="$STORAGE/${VERSION,,}" + mkdir -p "$STORAGE" + BASE_IMG="$STORAGE/base.dmg" + + if [ ! -f "$BASE_IMG" ] || [ ! -s "$BASE_IMG" ]; then + ! download "$VERSION" "$BASE_IMG" && exit 34 + fi + fi if ! generateID; then From a0fe4c91e21a98a96356f5f8c8a64cfb59d2fbd7 Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 15 Sep 2025 17:37:26 +0200 Subject: [PATCH 2/2] fix: Shellcheck warnings --- src/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.sh b/src/install.sh index 379dd672..87eafa40 100644 --- a/src/install.sh +++ b/src/install.sh @@ -221,7 +221,7 @@ if [[ "${VERSION}" == \"*\" || "${VERSION}" == \'*\' ]]; then VERSION="${VERSION:1:-1}" fi -VERSION=`expr "$VERSION" : "^\ *\(.*[^ ]\)\ *$"` +VERSION=$(expr "$VERSION" : "^\ *\(.*[^ ]\)\ *$") if [ -z "$VERSION" ]; then