Posted on
07-01-2016
10:05 AM
- last edited
a week ago
by
kh-richa_mig
Hello everyone- I have a very ultra noobish question. I'm using hdiutil in a script to mount installation DMG's on a system for imaging, but when I call it within my script, it shows the DMG contents on the desktop. I would like to know how to go about suppressing that, I'd like to have one less thing for them to mess with.
command that I am using is hdiutil attach /path/to/dmg
then I run it, and
hdiutil detach /path/to/dmg
Posted on 07-01-2016 10:29 AM
So close...
hdiutil attach /path/to/dmg -nobrowse
Posted on 07-01-2016 11:12 AM
Thank you so much. Greatly appreciated. The growing pains of a novice scripter:)
Posted on 07-01-2016 11:19 AM
@rbingham917 I admit I didn't know the answer to this question, but I knew it was possible. So 'man hdiutil' and read the man(ual) page and notice the following line.
-nobrowse render any volumes invisible in applications such as the OS X Finder.
The real power in scripting is not remembering command and parameters, but knowing where to find them. Good luck with your coding.
Posted on 07-01-2016 08:07 PM
Maybe I can pick some brains here... am I doing way too much work with how I've always done silent mounting? My typical script would look something like this:
#!/bin/bash
url="http://www.server.com/path/to/file.dmg"
dmgPath="/tmp/file.dmg"
/usr/bin/curl -s --output "$dmgPath" "$url"
mountPoint=$(/usr/bin/mktemp -d /tmp/file.XXXX)
/usr/bin/hdiutil attach "$dmgPath" -mountpoint "$mountPoint" -noverify -nobrowse -noautoopen
# /usr/sbin/installer or whatever else you are doing with the contents in the dmg
/usr/bin/hdiutil detach "$mountPoint"
/bin/rm -rf "$mountPoint"
/bin/rm -rf "$dmgPath"
exit 0
Do I really only need to add the -nobrowse option and avoid all the mktemp work?
Posted on 07-01-2016 11:51 PM
@grepoli Not really.
The mktemp does make sure that the DMG mounts at a random path.
Tbh, I'd stay with what your doing. :)