Jump to content

Recommended Posts

Posted

What shares are you mapping - are they generic shared folders, or are they individual shares per user?

 

The basic command for mapping a share in a bash script is as follows (and assumes you're using AFP filesharing):

#!/bin/bash

# Create a mount point within the filesystem
mkdir /Volumes/shareName
# Mount the share to the mount point
/sbin/mount -t afp afp://your.server/share /Volumes/shareName

This will mount afp://your.server/share as a volume called shareName

 

You'll also need a LogoutHook to unmount the share you added at login:

#!/bin/bash

# Unmount share
/sbin/umount /Volumes/shareName
# Delete mount point used from file system
rmdir /Volumes/shareName

 

 

If you need to map a specific share for a user, LoginHook scripts are passed the current username as $1, so you can use this variable in the path if you require:

#!/bin/bash

mkdir /Volumes/shareName
/sbin/mount -t afp afp://your.server/$1 /Volumes/shareName

This will mount afp://your.server/ as a volume called shareName

 

 

If you need to use authentication you need to change your share address to something like this

#!/bin/bash

mkdir /Volumes/shareName
/sbin/mount -t afp afp://username:[email protected]/share /Volumes/shareName

However, the above will only work if you want to use just one account to mount the share with. You can't have the user enter their password into a loginhook script as it runs. For example, I use the above method to mount a share during the login process to copy some files from the server, before disconnecting at the end of the login script, i.e.:

#!/bin/bash

mkdir /Volumes/loginfiles
/sbin/mount -t afp afp://serviceuseraccount:[email protected]/loginfiles /Volumes/loginfiles

# File copying and other stuff happens here

/sbin/umount /Volumes/loginfiles
rmdir /Volumes/loginfiles

 

 

Also, once you've written your *.sh script, you'll need to make it executable in the Terminal:

chmod +x yourscript.sh

 

Hope this gets you started!

Posted

Why using login hooks? Can you not just add the shares to the login items using WGM? This is how I mount staff data shares, pupil data shares and an applications share found on the windows server.

 

Also you can mount afp shares using Kerberos authentication. Do man mount_afp for the command. I think that's what it is. It's been a while since I looked at this as it was easier using WGM.

Posted

I'm new to this. Didn't really matter how i did it, just needed to figure out how to achieve the end result.

How would i go about adding my shares to the login items then?

  • 3 years later...
Posted

I know this is an old thread but I'm pretty much in the same boat!

 

I ideally would like to use Work Group Manager for adding network shares to my users. Where should I start within WGM?

 

I have groups and their docks all setup.

Posted

Go to WGM and then select the group you want to makes changes to.

Click on preferences along the top

Click on login

Click items tab along top to the right

In finder click go > connect to server.

Enter the UNC path to the share you want to add

When it mounts on your desktop drag the icon into the white space in WGM

Select the share that is now displayed and tick the mount using username and password of user logging in.

 

 

You can't mount a share that is located on the server that is hosting the share. Instead use WGM on a client and then do the same process as above. You may find running WGM on a client makes the process of creating the managed preferences a lot easier.

Posted

Hi Everyone,

 

Just wondering if you could help me out, I have a AFP share that I need to mount to all desktops but cant seem to get it to work. It works at the root level of the share but I was wondering if I could make it go into a sub-folder with the username of the current logged on user?

 

I'm using WGM with the following URL afp://macserver/Network%20Users/ <

Each user has a folder on the Network Users share with the correct permissions (see screenshot)

 

Some websites are suggesting adding $1 to translate the path to afp://macserver/Network%20Users/RMUser01

 

I'm by no means a mac man and I appreciate if anyone could advise or a better way of achieving this?

 

screenshot.pngscreen.jpg

Posted

That's how OS X mounts shares - it'll mount directly to the shared folder. You cannot mount a sub-folder of a share.

 

I think the $1 trick will only work in a login script, because - as mentioned above - the username is passed to the script as variable '$1'. I don't know if this will work with a WGM-managed share as I never tried it, but if it is going to work, you'll need each individual user folder to be shared individually.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...