This hint deals with scripting the mounting and unmounting of a backup volume for use with Retrospect Express (RE), whose options are limited.
While there have been a bundle of handy automount and unmount scripts posted here, I had to tinker (and predominantly borrow, cut, and paste, as I know next to nothing of AppleScript and shell scripts) to get this: a script to automount the partition containing my cloned hard drive when RE autolaunches, then unmount it when RE is finished. (RE doesn't allow for scripting or automounts, it seems). The script also works to unmount the volume at startup as well.
Is this necessary? I don't know. I just wanted the capability.
I tried several previous hints, particularly this one from emendelson, but also this one, this one, this one, and finally, this one.
Emendelson's and the other hints were designed to automount and then run an app, but I needed something that would automount when an app (RE) started up, so the script had to be watching for RE to start running. Telling the Finder (as in Emendelson's script) to watch doesn't work since RE runs as root, so I tell System Events instead.
There seem to be a wide variety of mounting and unmounting shell scripts available, but the only one I was able to make my partition consistently mount with (hdiutil gave error of no such file) was from this tip by John F. Whitehead:
The script must be saved with option to "stay open." To set the script so that it runs in the background, I consulted this tip and saved it as an application bundle, edited the Info.plist in the bundle's Contents folder to add the following (between existing and tags):
I have no idea yet if there are any security or stability issues involved here. If anyone has suggestions or input, fire away.
While there have been a bundle of handy automount and unmount scripts posted here, I had to tinker (and predominantly borrow, cut, and paste, as I know next to nothing of AppleScript and shell scripts) to get this: a script to automount the partition containing my cloned hard drive when RE autolaunches, then unmount it when RE is finished. (RE doesn't allow for scripting or automounts, it seems). The script also works to unmount the volume at startup as well.
Is this necessary? I don't know. I just wanted the capability.
I tried several previous hints, particularly this one from emendelson, but also this one, this one, this one, and finally, this one.
Emendelson's and the other hints were designed to automount and then run an app, but I needed something that would automount when an app (RE) started up, so the script had to be watching for RE to start running. Telling the Finder (as in Emendelson's script) to watch doesn't work since RE runs as root, so I tell System Events instead.
There seem to be a wide variety of mounting and unmounting shell scripts available, but the only one I was able to make my partition consistently mount with (hdiutil gave error of no such file) was from this tip by John F. Whitehead:
disktool -l | egrep -i "Mountpoint = '', fsType = 'hfs', volName = '.*name" | \
cut -d\' -f2 | xargs -n1 disktool -m
And I used his unmounting code as well:
disktool -l | egrep -i "Mountpoint = '/Volumes/.*name" | cut -d\' -f2 | \
xargs -n1 disktool -p
Here's my script:property diskname : "TheClone"
property appname : "Retrospect Express"
on idle
tell application "System Events"
set x to the name of every process
if appname is not in x then
if (exists the disk diskname) then
do shell script "disktool -l | egrep -i \"Mountpoint = '/Volumes/" & diskname & "\" | cut -d\\' -f2 | xargs -n1 disktool -p"
end if
else
do shell script "disktool -l | egrep -i \"Mountpoint = '', fsType = 'hfs', volName = '" & diskname & "\" | cut -d\\' -f2 | xargs -n1 disktool -m"
end if
end tell
end idleThe script must be saved with option to "stay open." To set the script so that it runs in the background, I consulted this tip and saved it as an application bundle, edited the Info.plist in the bundle's Contents folder to add the following (between existing and tags):
<key>LSBackgroundOnly</key>
<string>1</string>
<key>CFBundleAllowMixedLocalizations</key>
<true/>
To have the script run for any and all users, I followed this tip. Modify /Library -> Preferences -> loginwindow.plist (or if there isn't one, create one based on your user's one) and add this:
<dict>
<key>Hide</key>
<false/>
<key>Path</key>
<string>/Library/Scripts/CloneMountHandler.app/</string>
</dict>
CloneMountHandler.app is the name of the script saved in /Library/Scripts.
I have no idea yet if there are any security or stability issues involved here. If anyone has suggestions or input, fire away.
•
[14,714 views]

