adamchilcott icon

createinstallmedia_-_mac.sh

adamchilcott | PRO | 08/20/17 04:16:09 PM UTC | 0 ⭐ | 947 👁️ | Never ⏰ | []
Bash |

4.04 KB

|

None

|

0 👍

/

0 👎

#!/usr/bin/env bash
 
#######################################
# Create a bootable installer for macOS
#######################################
 
while true; do
 
cat << BANNER
 
################################
# 1. Format An External Drive
# 2. Install MacOS Sierra
# 3. Install Mac OS X EL Capitan
# 4. Install Mac OS X Yosemite
# 5. Install Mac OS X Mavericks
# 6. Drop Back To The Shell
################################
 
BANNER
 
printf "Please Select An Option: "
read -r userOption
 
case $userOption in
 
"1")
diskutil list
printf "Please Enter A Disk Node e.g. /dev/disk1: "
read -r diskNode
printf "Please Enter A New Disk Name e.g. SANDISK: "
read -r diskName
sudo diskutil eraseDisk JHFS+ "$diskName" "$diskNode"
;;
 
"2")
printf "Please Enter A Volume Name e.g. SANDISK: "
read -r volumeName
declare binSierra='/Applications/Install macOS Sierra.app/Contents/Resources/createinstallmedia'
declare appSierra='/Applications/Install macOS Sierra.app'
sudo "$binSierra" --volume /Volumes/"$volumeName" --applicationpath "$appSierra"
;;
 
"3")
printf "Please Enter A Volume Name e.g. SANDISK: "
read -r volumeName
declare binELcap='/Applications/Install OS X El Capitan.app/Contents/Resources/createinstallmedia'
declare appELcap='/Applications/Install OS X El Capitan.app'
sudo "$binELcap" --volume /Volumes/"$volumeName" --applicationpath "$appELcap"
;;
 
"4")
printf "Please Enter A Volume Name e.g. SANDISK: "
read -r volumeName
declare binYosemite='/Applications/Install OS X Yosemite.app/Contents/Resources/createinstallmedia'
declare appYosemite='/Applications/Install OS X Yosemite.app'
sudo "$binYosemite" --volume /Volumes/"$volumeName" --applicationpath "$appYosemite"
;;
 
"5")
printf "Please Enter A Volume Name e.g. SANDISK: "
read -r volumeName
declare binMavericks='/Applications/Install OS X Mavericks.app/Contents/Resources/createinstallmedia'
declare appMavericks='/Applications/Install OS X Mavericks.app'
sudo "$binMavericks" --volume /Volumes/"$volumeName" --applicationpath "$appMavericks"
;;
 
"6")
exit
;;
 
*) printf "Invalid Option";;
 
esac
 
done
 
#############
# START NOTES
#############
 
## Reference:
## <https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/echo.1.html>
## "Applications aiming for maximum portability are strongly encouraged to use printf(1) to suppress the newline character."
 
# 2-clause license ("Simplified BSD License" or "FreeBSD License")
#
# Copyright © 2018, Adam Brian Chilcott
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and documentation are those
# of the authors and should not be interpreted as representing official policies,
# either expressed or implied, of the FreeBSD Project.
 
###########
# END NOTES
###########

Comments