Mounting network drives with variables

HollyShort
New Contributor

I've got a question concerning the mounting of network drives but I think it's rather a Mac OS issue than a Casper Suite issue.

I tried to make a configuration profile which configures the network mounts in the login items payload. I want to mount the home drive of the currently logged on user and therefore I want to use the $USER environment variable. The name of the home directory is similar to smb://domain/share/$USER so I thought the configuration profile would be the best idea but it just doesn't work.

The same problem occurs when I try to mount it manually with "Finder -> Got to server" but when I use "mount -t smbfs //domain/share/$USER share" it is mounted.

Anyone knows how I can get this to work? I would prefer to have this mount in the login items similar to other mounts without variables but if this is impossible I'll have to script it.
The home folders are not assigned to the users in our AD (which would make it so much easier...).

5 REPLIES 5

apizz
Valued Contributor

@HollyShort BIG bummer on the home folders not being in AD. If I'm thinking about this correctly, the config profile method you're trying wouldn't work because it doesn't use logic when mounting the specified network folder. It just mounts whatever path you tell it.

Just to clarify, you say that when you manually enter the user's folder path that it doesn't mount at all or just doesn't show up on the Desktop? If the latter that may just be a function of the Finder prefs if the "Show Network Folders" option is not checked.

@bentoms has a nice AppleScript app which queries Active Directory for group membership and based on the membership mounts a particular home folder. If the path for user shares follows the same pattern that may be your best bet. We used it on our Mac image this year with success, however we were only mounting the parent share that contains the home folder, so we're actually going to be using a different method in order to more easily mount the logged in user's folder via a dscl command on the local machines rather than querying AD.

If neither of those linked methods are ideal, you might try using them as a base to build something designed for your environment.

Hope that's helpful.

HollyShort
New Contributor

Thank you for your answer @aporlebeke!

I know, the home folders being in AD would be so much better but unfortunately this decision was made in another team...

When I try to mount the path with the $USER variable there's an error message that the path can not be found. When I replace $USER with the actual username it mounts perfectly fine so I think you're right with the mounting not using logic.

I'll have a look at the links you posted, I think I can use them to build my own script.

davidacland
Honored Contributor II

Hi @HollyShort

Login items payload in config profiles has a few downsides that aren't well documented. We've seen cases where we can't change them once they're pushed out as they get added to every users login items. Changing the paths adds a second login item, causing errors for the user at login.

We have our drive mapping scripts up on github: https://github.com/amsysuk

Here's the SMBHome mounting script: https://github.com/amsysuk/public_scripts/blob/master/mount_SMBHome/mounthome.sh

And the general drive mapping script: https://github.com/amsysuk/public_scripts/tree/master/shareConnect

There's a plain version and a Casper specific version that you can add to a policy and use the policy script variables.

Hope they help :)

apizz
Valued Contributor

@davidacland 's / amsysuk's mounthome script is what I was referring to with my second link.

HollyShort
New Contributor

@davidacland : Thank you for the warning concerning the login items payload and the links.
Considering all the downsides I will use the script to mount the drives :)

Thanks to both of you for your help!