Skip to content

Instantly share code, notes, and snippets.

@jkmathew
Last active December 17, 2019 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkmathew/93f84b5f92ba32f8062a to your computer and use it in GitHub Desktop.
Save jkmathew/93f84b5f92ba32f8062a to your computer and use it in GitHub Desktop.
Shell script to create USB installer for OS X Yosemite
#!/bin/sh
# MakeYosemite.sh
#
#
# Created by Johnykutty on 12/24/14.
#
red_color='\033[1;31m'
green_color='\033[0;32m'
endColor='\033[0m' # No Color
diskutil list
echo "Enter name of the disc you want to make bootable (choose from above): "
read usb_flash_drive
if disk_info=$(diskutil list $usb_flash_drive) ; then
echo "${green_color}Disk exists${endColor}"
else
echo "${red_color}$disk_info ${endColor}"
exit
fi
#Make sure user allows to erase the contents
echo "Do you want to erase all contents of $usb_flash_drive ? ${green_color}Y${endColor}/${red_color}N${endColor}"
read -p "" RESP
YES="y"
if echo $RESP | grep -i "^${YES}$" > /dev/null ; then
echo "${green_color}Erasing $usb_flash_drive .... "
else
echo "${red_color}Exiting...${endColor}"
exit
fi
echo "${green_color}Erasing $usb_flash_drive .... "
disk_name='Install_OS_X_Yosemite'
diskutil eraseDisk JHFS+ $disk_name $usb_flash_drive
echo "Enter full path to OS X Yosemite installer : ${end_color}"
read -r installer_path
if result=$(sudo "$installer_path"/Contents/Resources/createinstallmedia --volume /Volumes/$disk_name --applicationpath "$installer_path" --nointeraction) ; then
echo "${green_color}Completed process use $disk_name to install OS X Yosemite and have fun :) ${endColor}"
else
echo "${red_color}Failed to create installer $result ${endColor}"
fi
@jkmathew
Copy link
Author

For and later use
sudo "$installer_path"/Contents/Resources/createinstallmedia --volume /Volumes/$disk_name
That is, we can skip --applicationpath "$installer_path"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment