Forked from niw/download_macos_and_create_install_disk.sh
Created
June 13, 2021 15:39
-
-
Save zchee/c74cf028836e091992efadef50e9f448 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 hidden or 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 | |
| while getopts ":h" opts; do | |
| case $opts in | |
| h) | |
| echo "Usage: $0 [-h] name" | |
| echo "name is either mojave, mojave_beta, or catalina_beta" | |
| echo " -h show this help message" | |
| exit 0 | |
| ;; | |
| esac | |
| done | |
| shift $((OPTIND - 1)) | |
| readonly NAME=$1 | |
| case $NAME in | |
| mojave) | |
| INSTALL_APP_PATH="/Applications/Install macOS Mojave.app" | |
| MAC_APP_STORE_ID="id1398502828" | |
| ;; | |
| mojave_beta) | |
| INSTALL_APP_PATH="/Applications/Install macOS Mojave Beta.app" | |
| MAC_APP_STORE_ID="id1354523149" | |
| REQUIRE_ENROLL=1 | |
| ;; | |
| catalina_beta) | |
| INSTALL_APP_PATH="/Applications/Install macOS 10.15 Beta.app" | |
| MAC_APP_STORE_ID="id1455661060" | |
| REQUIRE_ENROLL=1 | |
| ;; | |
| *) | |
| echo "Unknown name '$NAME'" >&2 | |
| exit 1 | |
| ;; | |
| esac | |
| readonly INSTALL_APP_PATH | |
| readonly MAC_APP_STORE_ID | |
| readonly REQUIRE_ENROLL | |
| if [[ -r "$INSTALL_APP_PATH/Contents/SharedSupport/InstallESD.dmg" ]]; then | |
| echo "Found the install app, create an install disk image." | |
| # Mojave install disk image requires about 7GB space. | |
| hdiutil create -o untitled.dmg -size 7G -layout SPUD -fs HFS+J && \ | |
| hdiutil attach untitled.dmg | |
| # Create an install disk image. | |
| sudo "$INSTALL_APP_PATH/Contents/Resources/createinstallmedia" \ | |
| --volume /Volumes/untitled \ | |
| --downloadassets | |
| 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 | |
| # 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." | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment