Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###########################################################
- # ABOUT
- ###########################################################
- (*
- Phil Stokes -- 2016
- applehelpwriter.com
- sqwarq.com
- *)
- ###########################################################
- # DESCRIPTION
- ###########################################################
- (*
- This script will make a bootable USB installer from a Sierra beta installer
- Requires Admin privileges
- *)
- ###########################################################
- # USAGE
- ###########################################################
- (*
- Download the installer made available to you by Apple
- Insert a blank 16GB USB into your mac
- Run the script and specify the locations of the installer and the USB
- Note the script continues to run until the installer has been created.
- It sleeps for an interval of 10 secs between checking the job status.
- *)
- ###########################################################
- # IMPORT STATEMENTS
- ###########################################################
- use AppleScript version "2.5"
- use scripting additions
- use framework "Foundation"
- ###########################################################
- # VARIABLES
- ###########################################################
- property NSString : a reference to current application's NSString
- property NSCaseInsensitiveSearch : a reference to 1
- set isDone to false
- ###########################################################
- # HANDLERS
- ###########################################################
- on escapeSpaces(aString)
- set this_string to aString as text
- if this_string contains " " then
- set theReplace to "\\ "
- set theFind to " "
- set str to NSString's stringWithString:this_string
- set this_string to (str's stringByReplacingOccurrencesOfString:theFind withString:theReplace options:NSCaseInsensitiveSearch range:{0, str's |length|()}) as text
- set aString to this_string
- end if
- return aString
- end escapeSpaces
- ###########################################################
- # COMMANDS
- ###########################################################
- set theInstaller to POSIX path of (choose file with prompt "Choose the Installer app" default location (path to applications folder) without showing package contents)
- set theThumb to POSIX path of (choose folder with prompt "Choose the USB drive" default location (path to startup disk))
- set theThumb to theThumb's text 1 thru -2
- set confirmMsg to "Are you sure you want to create a bootable USB drive with " & return & theInstaller & " on " & theThumb & "?"
- if button returned of (display dialog confirmMsg buttons {"Cancel", "OK"} default button "OK" with title "MakeUSBInstaller script" with icon 1) is "OK" then
- set theThumb to escapeSpaces(theThumb)
- set theThumb to " --volume " & theThumb
- set theInstaller to escapeSpaces(theInstaller)
- set appPath to " --applicationpath " & theInstaller & " --nointeraction"
- set inBackground to " &> /dev/null &"
- set execPath to "Contents/Resources/createinstallmedia"
- set theInstaller to theInstaller & execPath
- set createInstallMedia to theInstaller & theThumb & appPath
- do shell script createInstallMedia & inBackground with administrator privileges
- delay 10
- repeat while isDone is false
- try
- do shell script "ps ax | grep -v grep | grep createinstallmedia"
- if the result contains "createInstallMedia" then
- delay 10
- else
- set isDone to true
- end if
- on error
- set isDone to true
- end try
- end repeat
- if isDone is true then
- display dialog "USB Install Media is done" buttons "OK" default button "OK" with title "MakeUSBInstaller script" with icon 1
- end if
- end if
- ###########################################################
- #EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement