Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Is there a way to mount an AFP share at boot so it is accessible to the system without a user logged in?

I would like to run scripts via SSH or as a daemon on boot that check files on my AFP share. Unfortunately, the shares don't mount until a user logs in.

share|improve this question

5 Answers 5

Not sure that you can. I would think for security reasons a user has to be logged in, so that a set of credentials can be used. There's probably some scripts that are run pre-login though, so I suppose if you specify your credentials in there it would be fine.

share|improve this answer
    
Actually, having a user logged in when the mount happens makes tons of sense. Someone will see an error and connect it to something that is happening now. Next, the user can provide credentials and thirdly, if the credentials are stored in a user keychain, then it's more secure on multi user systems. –  bmike Jul 8 '11 at 16:29
    
@bmike - I agree. Why 'actually'? Did you think I was arguing that a user shouldn't be logged in, or...? –  Harv Jul 9 '11 at 23:50
    
Im scratching my head too about actually - I think I wanted to say additionally. –  bmike Jul 10 '11 at 0:34

Indeed you can script it all from terminal.

You will want to learn a little about launchd - that will specify when the mount will happen. At $5 the Lingon app from the App Store is great if you don't want to learn launchd configuration files.

Next, you'll need a command to make the AFP mount.

Last, you might learn security command to store or retrieve a password from the keychain if you don't want to store your afp password in the script.

Each of these should be easy to learn more with a few internet searches.

share|improve this answer
    
Ooh. Retrieve passwords from keychain. I like it. –  Harv Jul 9 '11 at 23:51

I would look into AutoFS. You can have AFP mounted on demand (see page 14 of the linked PDF).

share|improve this answer

Here you go. A bit outdated, but you can see how to do what you want from here.

http://www.real-world-systems.com/docs/launchctl.1.html

share|improve this answer

Yes, this can be done, and it's actually necessary when you want the share point available to something like servers which are started and run without a user logged in.

I did this years ago for something, and just again needed to do it, but my notes were inadequate. After a lot of fiddling, I've written enough details out so that I'll never have to do that again (I hope).

You combine launchd and a script, but there's some details that many other posts fail to mention. I captured them (at least for my setup).

All the nitty gritty details are here:

http://www.gregwillits.ws/articles/using_launchd_to_mount_afp_share_point_upon_startup

share|improve this answer
1  
Welcome to Ask Different and thanks for posting an answer greg! Can you please summarize the contents of the link you posted? Link have a tendency to disappear over time, leaving an answer that is not relevant to those who may find your answer down the road. Thank you! –  daviesgeek May 23 '12 at 3:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.