Mac iTOps Tube

Wednesday, May 16, 2012

Using $USER variable in autofs mapping not working

Hello all.

I am trying to automount a CIFS share in my /home/$USER directories. The problem I am coming up with is that the $USER variable works everywhere fine except in the key mapping. I can't figure out how to use it for the key itself.

For example, I am using /mnt as a test location until I get it working (Since I dont want to map over /home till its working).

I want to be able for a user to automount a CIFS share called documents in their /home/username/documents location (but in the test it would actually be in /mnt/username/documents)

Heres my auto.master line:


/mnt/$USER/ /etc/auto.documents --timeout=600 --ghost

And here is the code I have in auto.documents:


documents -fstype=cifs,rw,noperm,credentials=/home/$USER/.adpass SERVER.DOMAIN.GRP:/homedir\$/$USER

Now, this works beautifully except for one problem:


[boodaddy@dgs9wddmq1 /]$ cd /mnt

[boodaddy@dgs9wddmq1 mnt]$ ll

total 0

drwxr-xr-x. 3 root root 0 May 15 17:27 $USER

[boodaddy@dgs9wddmq1 mnt]$ cd \$USER/

[boodaddy@dgs9wddmq1 $USER]$ ll

total 0

dr-xr-xr-x. 2 root root 0 May 15 17:27 documents

[boodaddy@dgs9wddmq1 $USER]$ cd documents/

[boodaddy@dgs9wddmq1 documents]$ ll

total 456

dr-xr-xr-x. 0 root root      0 May 15 10:54 My Music

dr-xr-xr-x. 0 root root      0 Mar  3  2011 My Pictures

drwxr-xr-x. 0 root root      0 Oct  9  2009 My Received Files

drwxr-xr-x. 0 root root      0 Nov  8  2011 My Shapes

It doesnt parse the $USER variable for the mapping key :( Ideally that line of code would have mounted up the CIFS share as /mnt/boodaddy/documents but instead is just assumed $USER was the literal name of the mapping key. I read through the man pages and I assumed you could use that and a few other variables as mapping key.

The autofs mount is working good (as you can see by listing the documents folder) but is using $USER instead of pulling the actual username from the variable.

Anyone have any suggestions on how to do this?

No comments:

Post a Comment