Last active
October 23, 2024 03:20
-
-
Save niw/1bac63d716f71555fa6bbda43ddfc504 to your computer and use it in GitHub Desktop.
A script to download macOS install image and create an install disk image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
VOLUME_PATH=/Volumes/installer | |
while getopts ":d:h" opts; do | |
case $opts in | |
d) | |
VOLUME_PATH=$OPTARG | |
;; | |
h) | |
echo "Usage: $0 [-h] [-d disk] name" | |
echo "name is either mojave, mojave_beta, catalina, catalina_beta, bigsur, bigsur_beta, monterey, monterey_beta, ventura, or ventura_beta" | |
echo " -h Show this help message" | |
echo " -d /Volumes path to where it makes a bootable disk." | |
echo " If it doesn't exist, it will create a disk image." | |
exit 0 | |
;; | |
esac | |
done | |
readonly VOLUME_PATH | |
shift $((OPTIND - 1)) | |
readonly NAME=$1 | |
if [[ $(dirname "$VOLUME_PATH") != "/Volumes" ]]; then | |
echo "Invalid volume path '$VOLUME_PATH'" >&2 | |
exit 1 | |
fi | |
case $NAME in | |
highsierra) | |
INSTALL_APP_PATH="/Applications/Install macOS High Sierra.app" | |
MAC_APP_STORE_ID="id1246284741" | |
DISK_IMAGE_SIZE="8G" | |
;; | |
mojave) | |
INSTALL_APP_PATH="/Applications/Install macOS Mojave.app" | |
MAC_APP_STORE_ID="id1398502828" | |
DISK_IMAGE_SIZE="8G" | |
DOWNLOAD_ASSETS=1 | |
;; | |
mojave_beta) | |
INSTALL_APP_PATH="/Applications/Install macOS Mojave Beta.app" | |
MAC_APP_STORE_ID="id1354523149" | |
DISK_IMAGE_SIZE="8G" | |
REQUIRE_ENROLL=1 | |
DOWNLOAD_ASSETS=1 | |
;; | |
catalina) | |
INSTALL_APP_PATH="/Applications/Install macOS Catalina.app" | |
MAC_APP_STORE_ID="id1466841314" | |
DISK_IMAGE_SIZE="10G" | |
DOWNLOAD_ASSETS=1 | |
;; | |
catalina_beta) | |
INSTALL_APP_PATH="/Applications/Install macOS Catalina Beta.app" | |
MAC_APP_STORE_ID="id1455661060" | |
DISK_IMAGE_SIZE="10G" | |
REQUIRE_ENROLL=1 | |
DOWNLOAD_ASSETS=1 | |
;; | |
bigsur) | |
INSTALL_APP_PATH="/Applications/Install macOS Big Sur.app" | |
MAC_APP_STORE_ID="id1526878132" | |
DISK_IMAGE_SIZE="10G" | |
DOWNLOAD_ASSETS=1 | |
;; | |
bigsur_beta) | |
INSTALL_APP_PATH="/Applications/Install macOS Big Sur Beta.app" | |
BUNDLE_ID="com.apple.InstallAssistant.Seed.macOS1016Seed1" | |
DISK_IMAGE_SIZE="10G" | |
REQUIRE_ENROLL=1 | |
DOWNLOAD_ASSETS=1 | |
;; | |
monterey) | |
INSTALL_APP_PATH="/Applications/Install macOS Monterey.app" | |
MAC_APP_STORE_ID="id1576738294" | |
DISK_IMAGE_SIZE="14G" | |
DOWNLOAD_ASSETS=1 | |
;; | |
monterey_beta) | |
INSTALL_APP_PATH="/Applications/Install macOS Monterey Beta.app" | |
MAC_APP_STORE_ID="id1556159220" | |
BUNDLE_ID="com.apple.InstallAssistant.Seed.macOS12Seed1" | |
DISK_IMAGE_SIZE="14G" | |
REQUIRE_ENROLL=1 | |
DOWNLOAD_ASSETS=1 | |
;; | |
ventura) | |
INSTALL_APP_PATH="/Applications/Install macOS Ventura.app" | |
MAC_APP_STORE_ID="id1638787999" | |
DISK_IMAGE_SIZE="14G" | |
DOWNLOAD_ASSETS=1 | |
;; | |
ventura_beta) | |
INSTALL_APP_PATH="/Applications/Install macOS Ventura Beta.app" | |
MAC_APP_STORE_ID="id1616785793" | |
BUNDLE_ID="com.apple.InstallAssistant.Seed.macOS13Seed1" | |
DISK_IMAGE_SIZE="14G" | |
REQUIRE_ENROLL=1 | |
DOWNLOAD_ASSETS=1 | |
;; | |
*) | |
echo "Unknown name '$NAME'. See usage by give -h." >&2 | |
exit 1 | |
;; | |
esac | |
readonly INSTALL_APP_PATH | |
readonly MAC_APP_STORE_ID | |
readonly BUNDLE_ID | |
readonly DISK_IMAGE_SIZE | |
readonly REQUIRE_ENROLL | |
readonly DOWNLOAD_ASSETS | |
if [[ -r "$INSTALL_APP_PATH/Contents/SharedSupport/InstallESD.dmg" || \ | |
-r "$INSTALL_APP_PATH/Contents/SharedSupport/SharedSupport.dmg" ]]; then | |
echo "Found the install app, create an install disk." | |
if [[ ! -e $VOLUME_PATH ]]; then | |
readonly DISK_IMAGE_NAME=$(basename "$VOLUME_PATH") | |
echo "Creating a disk image '$DISK_IMAGE_NAME' size $DISK_IMAGE_SIZE" | |
hdiutil create -o "$DISK_IMAGE_NAME.dmg" -volname "$DISK_IMAGE_NAME" -size $DISK_IMAGE_SIZE -layout SPUD -fs HFS+J && \ | |
hdiutil attach "$DISK_IMAGE_NAME.dmg" | |
fi | |
ARGS=(--volume ${VOLUME_PATH}) | |
if ((DOWNLOAD_ASSETS)); then | |
ARGS=("${ARGS[@]}" --downloadassets) | |
fi | |
readonly ARGS | |
# Create an install disk. | |
sudo "$INSTALL_APP_PATH/Contents/Resources/createinstallmedia" "${ARGS[@]}" | |
else | |
if ((REQUIRE_ENROLL)); then | |
echo "Enroll developer seed and open Mac App Store." | |
echo "You can unenroll after downloading the install app by next command:" | |
echo "sudo /System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil unenroll" | |
# Tell Mac App Store that we've enrolled `DeveloperSeed`. | |
# Actual `enroll` is needed to download a complete install image from Mac App Store. | |
sudo /System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil enroll DeveloperSeed | |
/usr/libexec/PlistBuddy -c "clear dict" -c "add :SeedProgram string DeveloperSeed" /Users/Shared/.SeedEnrollment.plist | |
fi | |
if [[ ! -z $BUNDLE_ID ]]; then | |
# Open Preferences to download macOS installer app. | |
/usr/bin/open "x-apple.systempreferences:com.apple.preferences.softwareupdate?client=bau&installMajorOSBundle=$BUNDLE_ID" | |
echo "Click Download to download installer app, then run this script again to create an install disk image." | |
elif [[ ! -z $MAC_APP_STORE_ID ]]; then | |
# Open Mac App Store to download macOS installer app. | |
/usr/bin/open "macappstores://itunes.apple.com/app/$MAC_APP_STORE_ID" | |
echo "Click Get on Mac App Store to download installer app, then run this script again to create an install disk image." | |
else | |
echo "Mising both Bundle ID and Mac App Store ID." >&2 | |
exit 1 | |
fi | |
fi |
not sure if this will be useful to you but after the journey i went on to find them i wanted to share them with someone. here are the Bundle IDs for some MacOS non beta versions
com.apple.InstallAssistant.Catalina
com.apple.InstallAssistant.macOSVentura
com.apple.InstallAssistant.macOSBigSur
com.apple.InstallAssistant.macOSMonterey
i was able to find these based on what i read here https://pspdfkit.com/guides/ios/faq/finding-the-app-bundle-id/
On any recent new macOS, likely using softwareupdate
command would be better solution to download installer. For example,
$ softwareupdate --list-full-installers
$ softwareupdate --fetch-full-installer --full-installer-version 14.0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah, actually it's default to
untitled
but if not, it should given. Let me change it.