prasand

Q: Auto Mount Time Capsule

As I scoured the internet to find an method of auto mounting my Time Capsule's drive upon startup, without dragging the drive to the Startup Items (which results in a window being opened every time one logs in), and without using something like Automator. I discovered seemingly obscure technique using pure AppleScript. So I wanted to share that method, in hope that it might benefit someone in the future.

 

This method covers pure AppleScript.

 

  1. Open the Apple Script Editor.
  2. Create a new document.
  3. Paste the following line into that new document (as one line):

    tell application "Finder" to mount volume "afp://AirPort._afpovertcp._tcp.local/Data"

  4. Mount your Time Capsule drive if it is not already.
  5. Right-click on your mounted drive, and "Get Info".
  6. Copy the server address from the info window.
  7. Paste that server address into the Apple Script, replacing the existing URL that was pasted in step 3.
  8. In the menu bar go to: File > Export
  9. Choose "Application" as the file format to export to (do not select any items under the file format).
  10. Enter a name for the application you are creating, and save it to the location you desire.
  11. Drag the resulting application into your startup items, and you're done.

 

 

 

If you do not know of an appropriate place to put your created application, I recommend using an "Applications" folder within your home directory.

 

If you do not know how to add an application to your startup items, go to: System Preferences > Users & Groups. Choose your username, and then click the login items tab. You can drag your script to that section (after having added your Application to your chosen folder), or you can click the "+" sign below that section to navigate and find it on your drive.

 

I hope this helps.

 

Sincerely,

 

- Prasand J.

Airport Time Capsule 802.11ac, OS X Mavericks (10.9.2)

Posted on Apr 9, 2014 5:31 PM

Close

Q: Auto Mount Time Capsule

  • All replies
  • Helpful answers

  • by Slydude,

    Slydude Slydude Apr 12, 2014 5:07 PM in response to prasand
    Level 2 (224 points)
    Apr 12, 2014 5:07 PM in response to prasand

    Thanks for this. I scoured the Internet looking for something like this couple weeks ago to mount my iTunes library. I had difficulty getting the script to work based on the name of my network here. I eventually resorted to using the IP address of my share. I'll definitely give this a try. I think it will allow me to mount the share based on its name.

     

    .

  • by prasand,

    prasand prasand Apr 13, 2014 12:58 PM in response to Slydude
    Level 1 (0 points)
    Apr 13, 2014 12:58 PM in response to Slydude

    You're welcome. I currently have my iTunes library on my Time Capsule, and it works like a charm. Hope it works for you also.)

  • by Slydude,

    Slydude Slydude Apr 13, 2014 1:50 PM in response to prasand
    Level 2 (224 points)
    Apr 13, 2014 1:50 PM in response to prasand

    Here's the script I am using a the moment. The two folders are iTunes Meda and a separate folder of movies I often play through iTunes.

     

    tell application "Finder"

      --Mounts the iTunes folder and extra "iTunes Movies" folder if the iTunes folder isn't mounted

              if (folder "[iTunes]" exists) is false then

                        mount volume "afp://xxx.xxx.x.x/Media/iTunes"

                        mount volume "afp://xxx.xxx.x.x/Media/iTunes Movies"

              end if

    end tell

     

    My current setup uses a static IP address for the network device. I couldn't seem to work out the kinks mounting it by name. This works but just seemed a little inellegant to me.

     

    There is one problem that I just noticed a few days ago. The script is saved as an application and loads as a login item. Everything works well unless iTunes is open when I shut down the Mac. Because of the "Reopen items on login" feature of OS X iTunes opens before the login item to mount the share executes. The result is that iTunes looks in the default user folder location.

     

    I'm pretty new to scripting so any thoughts you have would be appreciated. Right now I can think of two solutions to the problem.

     

    1. Always quit iTunes before shutting down/restarting. Not likely to happen.

    2. Add a line to the beginning of the script to check and see if iTunes is already open. (Think I have code for that from a previous script that skips forward one track). If iTunes is already open, close it then execute the share mounting portion of the script.

  • by prasand,

    prasand prasand Apr 13, 2014 5:30 PM in response to Slydude
    Level 1 (0 points)
    Apr 13, 2014 5:30 PM in response to Slydude

    To shut down iTunes add the following line, on it's own line, before your first "tell":

     

    tell application "iTunes" to quit


  • by Slydude,

    Slydude Slydude Apr 13, 2014 6:22 PM in response to prasand
    Level 2 (224 points)
    Apr 13, 2014 6:22 PM in response to prasand

    After i posted my reply I thought about that being one way to go. I almost included it as part of a routine that collects the name of every running process to see if iTunes is open but that really is unnecessay in this case.

    The line of code you listed should do things nicely.

     

    EDIT: Right now what I have mounts fine. My next project is to work on mounting the drive so that others cannot modify it once its mounted. Ultimately I want to create something where guest users/others can play items in the library but not modify it at all.

  • by prasand,

    prasand prasand Apr 15, 2014 9:05 PM in response to Slydude
    Level 1 (0 points)
    Apr 15, 2014 9:05 PM in response to Slydude

    The Time Capsule has built-in options for adding user accounts and limiting their access (AirPort Utility > Disks tab). Depending on how you want the experience for others to be, there's a few ways to approach the situation. Well one core step, and two additional options.

     

     

    1. Create user account on the TC for yourself.

     

    2.

    a. Then create a universal account for guests ('Public', of 'Guest' account) with only read access and an easy (or secure) password.

     

    b. If you don't want people to have to type in a password, when they access the TC drive, you can use the command line / terminal to set the permissions of the files to world-readable only, by using the: CHMOD command.

     

     

    I do not know if the latter situation would still prompt the person for the password. Logically if the files are world readable, then they should not be prompted to read / access the files, and only require a permissions validation when attempting to write. However, access to the drive itself may still invoke a login prompt to the user, despite that said user should technically be allowed to read the files without using a password. I do not know which is the case, as I've never tried it and do not know the negotiation / security scheme that occurs upon connecting to the TC in the first place.

     

    But from what I gleaned, it seems that caveat of either situation is that if one is using a disk password priior and then switches to user accounts, they lose access to the files that were added prior to the addition of the user account to TC. That to me is counter-intuitive, but I imagine that the situation was a matter of "which came first". Since the account used to secure the drive using the Disk Password method, would be a different account than what was added later. That is logical, but it's counter-intuitive. However, to mitigate the issue others have copied the files on the TC onto another drive, then loggedin as the new TC user ... copying the files onto the drive under that new TC user, so the files now have the new TC user's ownership permissions.

     

    That to me, is a tedious process. I would rather CHOWN the files from a command-line accordingly.

     

     

    I hope that makes sense.

     

    I also hope that's no longer the case @ having to acquire permission to the old files. It is more intuitive that the files are written to TC drive using a "group" with write access, and then when someone is added with write permissions, then they are added to group that has write access. Although the creator of the file name may change in a situation of it previously using a disk password, to then using a user account. Both should be in the same write group, and thus both would have write permissions as they should. That to me is more logical, but I cannot say whether that was actually done.

     

     

    I hope that was changed, because now I'm considering doing it also. As it's far too easy to delete things irreversably on the Time Capsule.

  • by Slydude,

    Slydude Slydude Apr 15, 2014 9:15 PM in response to prasand
    Level 2 (224 points)
    Apr 15, 2014 9:15 PM in response to prasand

    Thanks for the thoughts. I haven't set up user accounts on the TC but might go that way. I'll have to give your thoughts some serious consideration. My media files are acutally stored on an Iomega EZ Backup (last device I buy from them but that's another matter). For all practical purposes it behaves like a TC.

     

    The Iomega device has a means of setting password protected shares as well as an administrator level password if I choose to set one up. One thing I don't like is some of the support procedures - invcluding the fact that under some circumstances you have to contact tech support just to find out the password recovery procedure.

     

    Thanks for all the help.

  • by prasand,

    prasand prasand Apr 16, 2014 4:30 PM in response to Slydude
    Level 1 (0 points)
    Apr 16, 2014 4:30 PM in response to Slydude

    You're very welcome.)

  • by the Wong and only,

    the Wong and only the Wong and only May 19, 2016 12:09 PM in response to prasand
    Level 1 (4 points)
    May 19, 2016 12:09 PM in response to prasand

    I have bought a Time Capsule recently. Perhaps a stupid question, but why would one like to mount the Time Capsule disk? Is it for using it for storage of other files (via the method od creating a disc image or just directly putting files on the TC HD)?

  • by spiderguy84,

    spiderguy84 spiderguy84 Jul 29, 2016 1:12 PM in response to prasand
    Level 1 (15 points)
    Wireless
    Jul 29, 2016 1:12 PM in response to prasand

    Thanks for this, and it does work for mounting the TC, but I have an issue with finding the library for iTunes to open.  When I click "Choose Library" in iTunes, the mount on my desktop is not visible for me to open and choose.  How do you get around this?