I need to mount shares when I am connected to the main wireless connection here at home. So I wrote a quick ruby script that will do this based on your network name, and mount the shares you have listed.
- Make a file called auto_mount_shares, open in a text editor.
- The script is:
#!/usr/bin/ruby # network name to automount on mnt_network = "network-name" # share names to mount # mnt_shares["SHARE-NAME"] = "afp://USER:PASSWORD@IP/SHARE_NAME" mnt_shares = Hash.new mnt_shares["backups"] = "afp://eric:password@10.1.1.2/backups" #mnt_shares["music"] = "afp://music:music@10.1.1.2/music" network = `system_profiler SPAirPortDataType | grep -e "Current Wireless Network:"` network = network.sub(/Current Wireless Network: /, "").strip mnt_shares.each { |share_name,location| `cd /Volumes; mkdir #{share_name}; mount -t afp #{location} #{share_name} >> /dev/null 2>&1` } - Move the file to /usr/local/bin (or somewhere of your liking, but I'll assume you've put it in /usr/local/bin).
- In Terminal, run:
chmod u+x /usr/local/bin/auto_mount_shares
sudo defaults write com.apple.loginwindow \
LoginHook /usr/local/bin/auto_mount_shares
[robg adds: I haven't tested this one...]
•
[12,883 views]

