|
|
#1 |
|
Prospect
Join Date: Apr 2009
Posts: 2
|
Mount AppleShare volume on bootup (not login)?
I am trying to mount an appleshare volume at boot time (not login time) by storing the commands in /etc/rc.local, but I am having some problems. If I have the following commands in rc.local, the device mounts okay, but it's mounted as root so my other software can't access it:
Code:
# /etc/rc.local mkdir /Volumes/my_mount_point mount_afp afp://user:pass@192.168.0.2/folder /Volumes/my_mount_point Code:
# /etc/rc.local sudo -u sysadmin mkdir /Volumes/my_mount_point sudo -u sysadmin mount_afp afp://user:pass@192.168.0.2/folder /Volumes/my_mount_point Code:
# /var/log/system.log myhostname sudo[141]: root : TTY=unknown ; PWD=/ ; USER=sysadmin ; COMMAND=/sbin/mount_afp afp://user:pass@192.168.0.2/directory /Volumes/my_mount_point com.apple.SystemStarter[51]: mount_afp: AFPMountURL returned error -1069 errno is -1069 Does anyone have any ideas? Can I just mount it as root and then chown to sysadmin? I tried adding chown sysadmin -R /Volumes/my_mount_point to the first script, but it failed. I am running out of ideas given my limited experience with unix, and apple's extensions to it. Any help, even a poke in the right direction, would be much appreciated. P.S: I have previously posted this question at macrumors but I don't think anyone's going to respond (link). |
|
|
|
|
|
#2 |
|
Prospect
Join Date: Jul 2007
Posts: 32
|
I'ld forget everyting about rc.local - Apple has deprecated the rc.* files.
Apple are advising to go the launchd route, so the solution I'm presenting to you here will go that route. In your case you'll need two files: a plist and a script The plist should look something like this: Code:
bash-4.0# cat /Library/LaunchDaemons/info.mathiesen.mountafp.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>EnableGlobbing</key> <true/> <key>Label</key> <string>info.mathiesen.mountafp</string> <key>ProgramArguments</key> <array> <string>~bjarne/System/sbin/mountafp</string> </array> <key>RunAtLoad</key> <true/> <key>UserName</key> <string>bjarne</string> </dict> </plist> Code:
bash-4.0# cat mountafp #!/bin/bash mkdir /Volumes/mountpnt mount_afp afp://[user[;AUTH=uamname][:password]@]host[:port]/volume /Volumes/mountpnt ![]() You start things by executing this command as root: Code:
launchctl load -w /Library/LaunchDaemons/info.mathiesen.mountafp.plist ![]() Incidentially, the plist must be owned by root:wheel, and remember to chmod +x the script ![]() I've tested it on my own iMac and it works as advertised
|
|
|
|
|
|
#3 |
|
Prospect
Join Date: Apr 2009
Posts: 2
|
Thank you BjarneDM. I have followed your recommendation, but unfortunately even with the new approach I am still getting error -1069 from mount_afp (and yet, if I enter the mount_afp commands over a terminal, they work fine).
I am beginning to think that the network interface might not be up when my script is running (as the volumes to be mounted are on the network). |
|
|
|
|
|
#4 |
|
Prospect
Join Date: Jul 2007
Posts: 32
|
OK - then lets try this:
Code:
bash-4.0# cat mountafp
#!/bin/bash
until ping -c2 -t5 [host] >/dev/null 2>&1
do
sleep 5
done
mkdir /Volumes/mountpnt
mount_afp afp://[user[;AUTH=uamname][:password]@]host[:port]/volume /Volumes/mountpnt
|
|
|
|
|
|
#5 |
|
League Commissioner
Join Date: Mar 2003
Location: Kansas City
Posts: 11,347
|
I had a similar problem but it was due to the fact that my AFP shares were on old Novell servers that only supported plain text passwords. I also ended up using an Apple Script that invoked shell scripting in the script. For some reason, mount_afp gave me a lot of trouble, here is an example of my script:
Code:
tell application "Finder" mount volume "afp://user:passwd@sevrer.domain.com/sharepoint" delay 10 repeat 25 times if (exists "sharepoint") then do shell script "open -a desired.app" exit repeat end if delay 2 end repeat end tell I ended up using apple script for the mounting and then shell commands for the app launching and it works. I have no idea why, maybe a lack in the API or something?
__________________
sudo make me a sammich http://www.tlarkin.com "It just told me what I already knew, that I'm a great and amazing guy, didn't I tell you baby, I'm Zaphod Beeblebrox." |
|
|
|
|
|
#6 |
|
Prospect
Join Date: Oct 2003
Posts: 4
|
I did this years ago for something, and just again needed to do it, but my notes were inadequate. After a lot of fiddling and trying everything in posts like this one I finally got it to work. I've written enough details out so that I'll never have to do that again (I hope).
So, yes, you can combine launchd and a script to have an automated mounting without a login, but there's some details that many other posts fail to mention -- like difference between mounting an AFP volume vs a share point. Also, what happens if the share point unmounts? The launchd/script should handle that. All the nitty gritty details are here (way too much detail for a direct post): http://www.gregwillits.ws/articles/u...t_upon_startup |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|