Last active
October 31, 2024 11:39
-
-
Save alex-salnikov/b3512c11c4482c5b4700354156699413 to your computer and use it in GitHub Desktop.
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 -x | |
## Get available distros | |
# softwareupdate --list-full-installers | |
# softwareupdate --fetch-full-installer --full-installer-version 13.0.1 | |
# Default size ~16 GB | |
DISK_SIZE="15361m" | |
STORAGE="/Users/${USER}/Downloads/macos_distro" | |
VERSION="Monterey" # Monterey, Version: 12.7.6, Size: 12118346KiB, Build: 21H1320 | |
#VERSION="Ventura" # Ventura, Version: 13.7, Size: 11922748KiB, Build: 22H123 | |
#VERSION="Sonoma" # Sonoma, Version: 14.7, Size: 13343514KiB, Build: 23H124 | |
# Create storage target | |
mkdir -p "${STORAGE}" | |
ls -la "${STORAGE}" | |
## Check downloaded distros | |
APP="Install macOS ${VERSION}.app" | |
echo "Locating installer .." | |
if ! ls -la /Applications/ | grep -q "$APP"; then | |
echo "Installer not found: $APP" | |
exit 1 | |
fi | |
echo "- found installer '$APP'" | |
## Create ISO from installer | |
echo "Creating blank image .." | |
hdiutil create -o "${STORAGE}/${VERSION}.cdr" -size $DISK_SIZE -layout SPUD -fs HFS+J | |
echo "Attaching blank image .." | |
hdiutil attach "${STORAGE}/${VERSION}.cdr.dmg" -noverify -mountpoint /Volumes/install_build | |
echo "Creating installation media .." | |
sudo "/Applications/${APP}/Contents/Resources/createinstallmedia" --volume /Volumes/install_build --nointeraction | |
echo "detaching volumes .." | |
hdiutil detach "/Volumes/Shared Support" | |
hdiutil detach "/Volumes/Install macOS ${VERSION}" | |
echo "converting from DMG to ISO .." | |
hdiutil convert "${STORAGE}/${VERSION}.cdr.dmg" -format UDTO -o "${STORAGE}/${VERSION}.iso" | |
mv "${STORAGE}/${VERSION}.iso.cdr" "${STORAGE}/${VERSION}.iso" | |
echo "removing temporary files .." | |
rm "${STORAGE}/${VERSION}.cdr.dmg" | |
echo "done." | |
# References | |
# - https://support.apple.com/en-us/101578 | |
# - https://gist.github.com/julianxhokaxhiu/42332e67640daad8f18386eeec43ea73 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment