Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 31 additions & 22 deletions src/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -117,7 +116,8 @@ download() {

local board
local version="$1"

local dest="$2"

case "${version,,}" in
"sequoia" | "15"* )
board="Mac-937A206F2EE63C01" ;;
Expand All @@ -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
}

Expand Down Expand Up @@ -215,22 +221,25 @@ if [[ "${VERSION}" == \"*\" || "${VERSION}" == \'*\' ]]; then
VERSION="${VERSION:1:-1}"
fi

VERSION=`expr "$VERSION" : "^\ *\(.*[^ ]\)\ *$"`
[ -z "$VERSION" ] && VERSION="13"
if [ ! -f "$BASE_IMG" ] || [ ! -s "$BASE_IMG" ]; then
! download "$VERSION" && exit 34
fi
VERSION=$(expr "$VERSION" : "^\ *\(.*[^ ]\)\ *$")

if [ -z "$VERSION" ]; then

VERSION="13"
warn "no value specified for the VERSION variable, defaulting to \"${VERSION}\"."

STORED_VERSION=""
if [ -f "$BASE_VERSION" ]; then
STORED_VERSION=$(<"$BASE_VERSION")
STORED_VERSION="${STORED_VERSION//[![:print:]]/}"
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
Expand Down