Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mattintosh4/6db53c2ce2bf1327f05e14e82216356a to your computer and use it in GitHub Desktop.
Save mattintosh4/6db53c2ce2bf1327f05e14e82216356a to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
set -u
set -x
name="High Sierra"
tempfile=$(mktemp -u)
hdiutil create -size 8g -fs HFS+J -layout SPUD ${tempfile}
hdiutil attach ${tempfile}.dmg -noverify -nobrowse -mountpoint "/Volumes/Install macOS ${name}"
sudo "/Applications/Install macOS ${name}.app/Contents/Resources/createinstallmedia" --volume "/Volumes/Install macOS ${name}"
hdiutil detach "/Volumes/Install macOS ${name}"
hdiutil resize -size $(hdiutil resize -limits ${tempfile}.dmg | awk 'END { print $1 }')b ${tempfile}.dmg
hdiutil convert ${tempfile}.dmg -ov -format UDTO -o "Install macOS ${name}"
rm ${tempfile}.dmg
mv "Install macOS ${name}".{cdr,iso}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment