Skip to content

Instantly share code, notes, and snippets.

@mattintosh4
Created November 28, 2019 13:41
Show Gist options
  • Save mattintosh4/7aead65bddf5995f558ce0cbb67d4de1 to your computer and use it in GitHub Desktop.
Save mattintosh4/7aead65bddf5995f558ce0cbb67d4de1 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
set -u
set -x
name="El Capitan"
tempfile=$(mktemp -u)
hdiutil create -size 8g -fs HFS+J -layout SPUD ${tempfile}
hdiutil attach ${tempfile}.dmg -noverify -nobrowse -mountpoint "/Volumes/Install OS X ${name}"
sudo "/Applications/Install OS X ${name}.app/Contents/Resources/createinstallmedia" --volume "/Volumes/Install OS X ${name}" --applicationpath "/Applications/Install OS X ${name}.app" --nointeraction
hdiutil detach "/Volumes/Install OS X ${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 OS X ${name}"
rm ${tempfile}.dmg
mv "Install OS X ${name}".{cdr,iso}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment