Script it
I had another IcyDock, firewire, external, drive enclosure fail again. So instead of throwing good money after bad, I instead acquired a NAS (network attached storage) device. Specifically, I got a Synology DS211J from Amazon with reward points on my credit card. Yes, I paid $0 for it and it’s the best money I never spent.
The NAS, which I named NASty, holds two SATA drives and has a host of RAID configurations available. I have two 2TB drives mirrored, split into three Volumes, with access controls, users, passwords, and a smorgasbord of applications, not the least of is a VPN server so I can access my files remotely when I’m away from home. On one Volume I moved all of my Music, and set iTunes to look on the remote drive for my music database. Which is good for sharing my music through the house, but was causing me some pain and mental anguish on my laptop when I forgot to first ‘mount’ the drive before opening iTunes.
When opening iTunes prematurely, as the case is, my podcasts would download to the local drive and I would have to clean it up manually to get it back onto the NAS and have it recognized in the iTunes program. Annoying. So, I thought to myself, I should script it so the NAS music share mounts first, then iTunes opens. So… I programmed an iTunes Launcher for my new setup.
-- iTunes Launcher -- for use with a music database stored on a remote NAS
-- define our Function to check if an application is running on appIsRunning(appName) tell application "System Events" to (name of processes) contains appName end appIsRunning
-- check for the existence of our music share try alias "/Volumes/music" on error
-- if the share doesn't exist mount it
tell application "Finder"
mount volume "music" on server "NASty" in AppleTalk zone¬
"*"Â as user name "music-user" with password "pass-word"
-- not my username nor my password…
end tell end try
-- Test to see if our mount is really there.
tell application "Finder"Â
if not (exists POSIX file "/Volumes/music/itunes/.NAStyIsMounted") then display alert "NASty Music Share not Mounted!" as critical giving up after 90 return end if end tell
-- Is iTunes runningÂ
if appIsRunning("iTunes") then -- if so, do nothing else -- otherwise start iTunes launch application "iTunes" end if
-- bring iTunes window to the foreground tell application "iTunes" activate tell window 1 if not visible then set visible to true end tell end tell
So just a tiny little script that checks to see if the music share is mounted already. If not, I mount it. I then make sure it mounted, if I can’t see the hidden file on the share I go OLD SCHOOL and ABEND. Otherwise I continue and check to see if iTunes is running. If not, I start it. And to finish up, now that I know iTunes is running, I bring it to the front.
I saved the script as an application. I changed the icon from the default AppleScript icon to a custom icon. Then I dropped the Launcher program onto my dock. So now I not only have a graphical reminder on my dock, but I removed the iTunes icon so I can’t accidentally open just the program without mounting the share first.
Amazingly, it works like a charm.