Last active
July 2, 2018 19:43
-
-
Save MCJack123/72914d2778626b2bdd20de0fdca441a0 to your computer and use it in GitHub Desktop.
Automatically generates macOS High Sierra (and higher?) DVD images
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
#!/bin/bash | |
if [ $# -lt 1 ]; then | |
echo "Usage: macOSDiscCreator <path to Install macOS.app>"; | |
exit 1; | |
fi; | |
echo "Your password is needed to create the macOS Installer image."; | |
sudo -v; | |
echo "Creating temporary macOS Installer image..."; | |
hdiutil create -layout GPTSPUD -fs HFS+ -volname Install\ macOS -attach -type UDIF -size 8g /tmp/InstallmacOS.dmg; | |
sudo "$1/Contents/Resources/createinstallmedia" --nointeraction --volume /Volumes/Install\ macOS/; | |
volname="$(osascript -l JavaScript -e "(new RegExp('\^\[\^.\]+')).exec((new RegExp('(?:(?!\\/).)+\$')).exec('$1'))")"; | |
echo "Copying InstallESD.dmg..."; | |
mv "/Volumes/$volname/$volname.app/Contents/SharedSupport/InstallESD.dmg" ./; | |
fs=$(wc -c <InstallESD.dmg); | |
if [ $fs -gt 4600372992 ]; then | |
if [ $fs -gt 4700372992 ]; then | |
if [ $fs -gt 4707319808 ]; then | |
if [ $fs -gt 8443666176 ]; then | |
if [ $fs -gt 8543666176 ]; then | |
if [ $fs -gt 8547991552 ]; then | |
hdiutil detach /Volumes/$volname/; | |
rm /Volumes/InstallmacOS.dmg; | |
rm InstallESD.dmg; | |
echo "Error: The InstallESD will not fit onto any type of disc."; | |
exit 2; | |
fi; | |
echo "Warning: The InstallESD disc will require a dual-layer DVD+R to be able to burn."; | |
else | |
echo "Warning: The InstallESD disc will require a dual-layer DVD to be able to burn."; | |
fi; | |
else | |
echo "Warning: The InstallESD disc will require a dual layer DVD, and a DVD-R DL may not work."; | |
fi; | |
else | |
echo "Warning: The InstallESD disc will not burn on a single layer DVD+R."; | |
fi; | |
else | |
echo "Warning: The InstallESD disc may have trouble burning to a single layer DVD+R."; | |
fi; | |
fi; | |
echo "Creating InstallESD symlink on BaseSystem..."; | |
mkdir /Volumes/InstallESD; | |
touch /Volumes/InstallESD/InstallESD.dmg; | |
ln -s /Volumes/InstallESD/InstallESD.dmg "/Volumes/$volname/$volname.app/Contents/SharedSupport/InstallESD.dmg"; | |
rm -r /Volumes/InstallESD; | |
echo "Resizing BaseSystem..."; | |
sudo hdiutil create -srcfolder "/Volumes/$volname/" -fs HFS+ -format UDRO -volname "$volname" -layout ISOCD "$volname.dmg"; | |
echo "Cleaning up..."; | |
hdiutil detach "/Volumes/$volname/"; | |
rm /tmp/InstallmacOS.dmg; | |
echo "Created InstallESD.dmg and $volname.dmg in the current directory. Please burn InstallESD.dmg as a file (so the disc has the InstallESD.dmg file inside) and $volname.dmg as an image (so the disc has the contents of $volname.dmg inside)."; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment