Automounting SAMBA shares
I have a few of Linux boxes lying around the house doing duty as webservers and so on. Because we used to be a Windows household, each of those servers exports directories as SAMBA shares. I'm not really interested in setting up NFS (although maybe I should -- but then I'd probably want AFS or CODA), so I just want a way for those shares to get mounted when I log in or when the powerbook wakes up. It turns out that this is harder than it ought to be.
You can mount shares in the Finder via Applescript code that looks like this:
Code:
tell application "Finder"
try mount volume "smb://WORKGROUP;username:password@machine_name/directory"
end try
end tell
Automounting of shares in /Network is controlled by NetInfo -- you have to use the NetInfo Manager as described in this article. You need to supply a SAMBA url instead of an AFP url.
You can also mount using a shell script.
Code:
#!/bin/bash
mount_smbfs //username:password@server1/home ./s1home
You also want to unmount them when you go away / lid close
You can unmount non local volumes in Applescript like this:
Code:
tell application "Finder"
eject (every disk whose local volume is false)
end tell