Skip to content

Instantly share code, notes, and snippets.

@macmule
Created June 12, 2014 07:52
Show Gist options
  • Save macmule/014b3a1da1e0b43c0f06 to your computer and use it in GitHub Desktop.
Save macmule/014b3a1da1e0b43c0f06 to your computer and use it in GitHub Desktop.
on mountOSDMG_(sender)
log "Trying to mount:" & droppedOSdmgPath
-- the below doesn't update
set my droppedOSDMGTextField to "Examining..."
-- Try & mount dropped file
set droppedOSdmgMountPath to do shell script "hdiutil attach " & droppedOSdmgPath & " -owners on | grep \"Volumes\" | awk '{print substr($0, index($0,$3))}' " as quoted form
if droppedOSdmgMountPath is equal to "" then
set my droppedOSDMGTextField to "Error: Cannot mount " & droppedOSdmgPath
-- Reset droppedOSdmgMountPath
set droppedOSdmgMountPath to ""
else
-- if a dmg, mount & try & read /System/Library/CoreServices/SystemVersion.plist
try
set droppedOSVersion to do shell script "defaults read " & quoted form of droppedOSdmgMountPath & "/System/Library/CoreServices/SystemVersion.plist ProductVersion"
set droppedOSBuildVersion to do shell script "defaults read " & quoted form of droppedOSdmgMountPath & "/System/Library/CoreServices/SystemVersion.plist ProductBuildVersion"
set my droppedOSDMGTextField to "Mac OS " & droppedOSVersion & " (" & droppedOSBuildVersion & ")"
on error
set my droppedOSDMGTextField to "Error: Cannot read OS Version from " & droppedOSdmgPath
do shell script "hdiutil unmount " & quoted form of droppedOSdmgMountPath
end try
end if
log "Mount Path:" & droppedOSdmgMountPath
end mountOSDMG_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment