Advertisement
adamchilcott

createinstallmedia_-_mac.sh

Aug 20th, 2017
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.04 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. #######################################
  4. # Create a bootable installer for macOS
  5. #######################################
  6.  
  7. while true; do
  8.  
  9. cat << BANNER
  10.  
  11. ################################
  12. # 1. Format An External Drive
  13. # 2. Install MacOS Sierra
  14. # 3. Install Mac OS X EL Capitan
  15. # 4. Install Mac OS X Yosemite
  16. # 5. Install Mac OS X Mavericks
  17. # 6. Drop Back To The Shell
  18. ################################
  19.  
  20. BANNER
  21.  
  22. printf "Please Select An Option: "
  23. read -r userOption
  24.  
  25. case $userOption in
  26.  
  27. "1")
  28. diskutil list
  29. printf "Please Enter A Disk Node e.g. /dev/disk1: "
  30. read -r diskNode
  31. printf "Please Enter A New Disk Name e.g. SANDISK: "
  32. read -r diskName
  33. sudo diskutil eraseDisk JHFS+ "$diskName" "$diskNode"
  34. ;;
  35.  
  36. "2")
  37. printf "Please Enter A Volume Name e.g. SANDISK: "
  38. read -r volumeName
  39. declare binSierra='/Applications/Install macOS Sierra.app/Contents/Resources/createinstallmedia'
  40. declare appSierra='/Applications/Install macOS Sierra.app'
  41. sudo "$binSierra" --volume /Volumes/"$volumeName" --applicationpath "$appSierra"
  42. ;;
  43.  
  44. "3")
  45. printf "Please Enter A Volume Name e.g. SANDISK: "
  46. read -r volumeName
  47. declare binELcap='/Applications/Install OS X El Capitan.app/Contents/Resources/createinstallmedia'
  48. declare appELcap='/Applications/Install OS X El Capitan.app'
  49. sudo "$binELcap" --volume /Volumes/"$volumeName" --applicationpath "$appELcap"
  50. ;;
  51.  
  52. "4")
  53. printf "Please Enter A Volume Name e.g. SANDISK: "
  54. read -r volumeName
  55. declare binYosemite='/Applications/Install OS X Yosemite.app/Contents/Resources/createinstallmedia'
  56. declare appYosemite='/Applications/Install OS X Yosemite.app'
  57. sudo "$binYosemite" --volume /Volumes/"$volumeName" --applicationpath "$appYosemite"
  58. ;;
  59.  
  60. "5")
  61. printf "Please Enter A Volume Name e.g. SANDISK: "
  62. read -r volumeName
  63. declare binMavericks='/Applications/Install OS X Mavericks.app/Contents/Resources/createinstallmedia'
  64. declare appMavericks='/Applications/Install OS X Mavericks.app'
  65. sudo "$binMavericks" --volume /Volumes/"$volumeName" --applicationpath "$appMavericks"
  66. ;;
  67.  
  68. "6")
  69. exit
  70. ;;
  71.  
  72. *) printf "Invalid Option";;
  73.  
  74. esac
  75.  
  76. done
  77.  
  78. #############
  79. # START NOTES
  80. #############
  81.  
  82. ## Reference:
  83. ## <https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/echo.1.html>
  84. ## "Applications aiming for maximum portability are strongly encouraged to use printf(1) to suppress the newline character."
  85.  
  86. # 2-clause license ("Simplified BSD License" or "FreeBSD License")
  87. #
  88. # Copyright © 2018, Adam Brian Chilcott
  89. # All rights reserved.
  90. #
  91. # Redistribution and use in source and binary forms, with or without
  92. # modification, are permitted provided that the following conditions are met:
  93. #
  94. # 1. Redistributions of source code must retain the above copyright notice, this
  95. # list of conditions and the following disclaimer.
  96. # 2. Redistributions in binary form must reproduce the above copyright notice,
  97. # this list of conditions and the following disclaimer in the documentation
  98. # and/or other materials provided with the distribution.
  99. #
  100. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  101. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  102. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  103. # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  104. # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  105. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  106. # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  107. # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  108. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  109. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  110. #
  111. # The views and conclusions contained in the software and documentation are those
  112. # of the authors and should not be interpreted as representing official policies,
  113. # either expressed or implied, of the FreeBSD Project.
  114.  
  115. ###########
  116. # END NOTES
  117. ###########
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement