The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - Newcomers (http://hintsforums.macworld.com/forumdisplay.php?f=15)
-   -   Automount network home folder using AD path (http://hintsforums.macworld.com/showthread.php?t=106139)

tlarkin 10-12-2009 11:49 AM

Quote:

Originally Posted by lennysweet (Post 556912)
No luck, it's just spitting back errors no matter what I try to do. I just wish there was option to do this is Workgroup Manager. I'm thinking that even I get this script to work it was have to be customized for each of my file servers. What I'm ultimately trying to do is mount the user's home folder the same way the dock shortcut is created so that no matter what server their home lives as long as the the computer is bound to AD and OD it will mount the volume on the desktop. I would even settle for an alias to the home folder be automatically created on the user's desktop at login. Both of these options always sounded so simple to me but may be out of reach.

Thank you very much for your help with this. Hopefully someone else having the same problem will see this post and offer their solution.


You most likely can do it with WGM, I had no idea you were also running OD along with AD. You can set automounts via computer policy in WGM.

Go into WGM, click on the computer list, use your guest computer or your computer group and select preferences, then select Login. On the last tab of the Login pref pane there is an option called "Items" and there is an automount home folder using user name and password option.

I didn't think you were using OD with AD, otherwise I would have suggested this via MCX in the beginning.

lennysweet 10-12-2009 12:40 PM

By George I think I've got it!

I ran the following script though ARD to a computer already logged in and kerberized

#!/bin/bash

#pause for kerberos ticket

#/bin/sleep 15

#get current logged in user

cur_user=`/bin/ls -l /dev/console | awk '/ / { print $3 }'`

#input full path of home folder

home_folder="/Volumes/path/to/folder"

#now make sure it is mounted

if [[ -e $home_folder ]]

then /bin/echo "home folder is mounted"

else /sbin/mount_smbfs //172.20.0.6/students/classof2011/$cur_user /Users/$cur_user/Desktop

fi

/bin/echo "done"

exit 0

It seems like using the IP instead of the DNS name is what worked. I know DNS is configured correctly but for some reason the mount_smbfs command didn't like it.

When I ran this, it mounted the user's home folder on that user's desktop and it appeared automatically under places in finder. Now all I have to do is figure out how to implement this as a login scripts through Workgroup Manager. Thanks again for all your help, I hope this helps someone else out there trying to do the same thing.

lennysweet 10-12-2009 01:30 PM

I am having one small problem I can't seem to figure out. This script only works if the root sharepoint is not already mounted. In other words, in my example above the script worked because the volume smb://172.20.0.6/students does not automount when the user logs in, only smb://172.20.0.6/classof2016. So, the script allowed a new volume to be mounted using the full path smb://172.20.0.6/students/classof2016/$cur_user

The problem is, most of my other file servers are setup with everyone's home folder at the root. So if a user's home folder is in smb://172.20.0.6/students the script gives the message "file exists" because the "students" sharepoint is already mounted on that user's desktop at login in order to give them the shortcut on the dock.

I hope this makes sense, obviously moving home folders into subfolders is not going to be an option. Is there any way to force the script to execute even if it thinks the file already exists?

tlarkin 10-12-2009 02:12 PM

Try editing my line that has the home_folder variable to the actual full path, so in your case...

home_folder="/Volumes/students/classof2011/$cur_user /Users/$cur_user/Desktop"

..I think that is how OS X will mount the home directory. Since the script I gave you checks to see if that full path exists first, and if it does then it exits because it is already mounted. If it doesn't exist it mounts it.

lennysweet 10-12-2009 02:13 PM

sorry I wasn't more clear about our environment earlier. I am very familiar with the login items option in Workgroup Manager but it does not actually mount the user's home folder, only the sharepoint or root share appears on the desktop. The dock shortcut is correct and is set to the user's home folder but the desktop only mounts the share, not the folder. In order for a user's home folder to automount on the desktop, smb shares would have to be created for each user rather than just on the root which is not very secure. This would also put a much heavier load on the file server having to deal with several thousand smb shares instead of just one.

I know it's possible to mount the individual folder as a network volume on the desktop simply by typing in the fully smb://server/share/homefolder path using "connect to server" but for some reason OSX only mounts the root smb share and stops. That has been my problem from day 1 which is why I've been trying to find a workaround using scripting.

Your idea is working but only for home folders nested within a subfolder like I said in my last post.

lennysweet 10-12-2009 02:17 PM

I didn't think about modifying that line, I'm going to test that now. I'll post back in a few minutes

lennysweet 10-12-2009 02:20 PM

no luck, I still get a "File Exists" message since the root share is already automounted at login. If I disconnect the root share and run the script again it works fine. Argh!

tlarkin 10-12-2009 02:23 PM

Quote:

Originally Posted by lennysweet (Post 556951)
no luck, I still get a "File Exists" message since the root share is already automounted at login. If I disconnect the root share and run the script again it works fine. Argh!

We can modify the [[ -e $home_folder part ]]

I just scripted it as if there was nothing mounting it but the script itself. So that volume auto-mounts at log in?

You can have WGM run the script as a log in hook on a computer group and totally ditch the auto mount, or we can modify the script so it just does it regardless. I used an if/then statement to lessen the load on the server from users hitting it if the mount already exists.

If it already exists we may be able to use an apple script to tell the finder to mount the folder path on the desktop.

lennysweet 10-12-2009 02:28 PM

I would prefer not to ditch the automount because of the shared folders users access through the root share and I believe it's required if I still want to keep the dock shortcut.

If there is any way to modify the script to run regardless, I would like to try that first.

An applescript would be great too, I could do a bunch of things with that using Automator.

tlarkin 10-12-2009 02:40 PM

Well try this apple script

Code:


tell application "Finder"
       
        mount volume "smb://user@domain.mycompany.com/sharepoint"
       

end tell

I don't know the vocabulary off the top of my head for it to grab the current user.

lennysweet 10-12-2009 02:55 PM

The applescript is having the same issue, if the sharepoint is already mounted on the desktop the script runs but does nothing since it thinks the volume is already there. If I disconnect the root sharepoint and run it again, it works.

tlarkin 10-12-2009 03:08 PM

Quote:

Originally Posted by lennysweet (Post 556963)
The applescript is having the same issue, if the sharepoint is already mounted on the desktop the script runs but does nothing since it thinks the volume is already there. If I disconnect the root sharepoint and run it again, it works.

So, if it is already mounted and the have a kerberos ticket all you need to do is to have it show up on the desktop? I guess we could just script out an alias or make an alias that way.

It really won't map the whole path of the home folder? I have not tried but the check box for home folders seems to imply that it will on different servers.

Instead of having it auto mount you could have it just run the script.

I guess you can also try the script like this:

Code:

#!/bin/bash

#get current logged in user

cur_user=`/bin/ls -l /dev/console | awk '/ / { print $3 }'`

/sbin/mount_smbfs //172.20.0.6/students/classof2011/$cur_user /Users/$cur_user/Desktop

exit 0


lennysweet 10-12-2009 03:19 PM

this script acts the same as the first one only it doesn't bother checking to see if the voluem exists. The end result is the same unfortunately, with the root sharepoint "classof2011" already on the desktop, the script reports that the file exists. If I disconnect the root share and retry it works.

I understand that I am not dealing with drives and mapping but instead a volume but I know it's possible to bypass this rule since typing in the full path using "connect to server" mounts the folder as a separate volume right next to the root folder. I just can't seem to get it to work using a script.

lennysweet 10-12-2009 03:21 PM

I found this in another forum, this is exactly what my problem is and the way it was explained makes sense but of course, no one chimed in with a workaround

http://forums.macrumors.com/archive/.../t-472070.html

tlarkin 10-12-2009 03:51 PM

Well, how comfortable are you with the command line? You can try creating a directory and then creating a symbolic link to the automount that is already mounted.

It is not hard, but it may be a bit more work and may have a higher failure rate, but I think it may be worth a shot.

So uh, something along these lines.

Code:

#!/bin/bash

#create a sym link to an already mounted nested folder

#grabbing current user

cur_user=`/bin/ls -l /dev/console | awk '/ / { print $3 }'`

#now make sure volume is mounted

home_folder="/Volumes/students/classof2011/$cur_user"

if [[ -e $home_folder ]]

then

#change winmount to whatever you want

/bin/mkdir /Users/$cur_user/Desktop/win_mount

/usr/bin/chown -R $cur_user:staff /Users/$cur_user/Desktop/win_mount

else

/bin/echo "folder not mounted exiting"

exit 1

fi

#create the symbolic link

/bin/ln -s /Users/$cur_user/Desktop/win_mount /Volumes/students/classof2011/$cur_user


exit 0

That is kind of quick and dirty but you may want to play with it. It will link whatever folder you create on their desktop to the actual share. however, symbolic links will break if anything on any system changes a lot of times so as long as you test test test test test test test before you deploy they are OK to use.

I edited this to what I think it should be with out knowing anything about your environment so you may need to tweak my variables.

lennysweet 10-12-2009 03:54 PM

creating a sym link sounds promising, I'll dive into testing this tomorrow, it's time to go home now. Thanks again for all your help today. I'll post back soon and let you know how it goes.

tlarkin 10-12-2009 04:09 PM

This would be a one time run script, as you wouldn't run it more than once. Once that folder and link are created your automount would take care of the rest.

lennysweet 10-13-2009 07:49 AM

No luck, even the symlink won't work because a "file exists" error. I'm not sure this would be a long-term solution anyway since it's a once and done sort of thing.

If there is anyway to force a mount using the same method as "connect to server" I think it would work but the command line is a little too picky

tlarkin 10-13-2009 09:27 AM

Try it from the command line.

manually make the folder, and then use this

/bin/ln -s /Users/$cur_user/Desktop/win_mount /Volumes/students/classof2011/$cur_user

but modify it to reflect the actual paths and folders with out the variables.

lennysweet 10-13-2009 03:10 PM

no luck doing this manually either. I created a folder called "test" on the desktop then opened terminal and typed in

/bin/ln -s /Users/balboar/Desktop/test /Volumes/students/classof2011/balboar

The command didn't produce any errors but nothing happened. The folder remained an empty folder. I disconnected the classof2011 volume from the desktop and the command gave me a "file does not exist" message.


All times are GMT -5. The time now is 10:17 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.