LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   autofs IS LYING! executable map doesnt work (https://www.linuxquestions.org/questions/linux-software-2/autofs-is-lying-executable-map-doesnt-work-4175424288/)

ted_chou12 08-27-2012 04:00 PM

autofs IS LYING! executable map doesnt work
 
Hi, I tried a few times, but it still doesn't work. I REALIZED autofs man is lying, and according to this webpage:
http://docstore.mik.ua/orelly/networ...fs/ch09_05.htm
http://forums.fedoraforum.org/showthread.php?t=240811
executable maps should work perfectly:
Code:

#!/bin/bash
# This file must be executable to work! chmod 755!
key="$1"
# Note: this script works only in authentication free servers,
# if you want to add authentication please do.
# Ted wrote in 2012 Aug 28
# Note: Use cifs:
opts="-fstype=cifs,noperm,file_mode=0660,dir_mode=0755"

output="$(/usr/bin/smbclient -N -L //$key -g 2>&1)"
IFS="
"
dirs=($output)
for each in ${dirs[@]} ; do
        if [ "${each:0:4}" == "Disk" ] ; then
                IFS="|"
                dir=($each)
                printf "${dir[1]}\t$opts\t://$key/${dir[1]}\n"
        fi
done

This is my customized executable map chmod at 755
Where as:
Code:

#!/bin/bash

# This file must be executable to work! chmod 755!

key="$1"
opts="-fstype=cifs"

for P in /bin /sbin /usr/bin /usr/sbin
do
        if [ -x $P/smbclient ]
        then
                SMBCLIENT=$P/smbclient
                break
        fi
done

[ -x $SMBCLIENT ] || exit 1

$SMBCLIENT -gNL $key 2>/dev/null| awk -v key="$key" -v opts="$opts" -F'|' -- '
        BEGIN        { ORS=""; first=1 }
        /Disk/        {
                  if (first)
                        print opts; first=0
                  dir = $2
                  loc = $2
                  # Enclose mount dir and location in quotes
                  # Double quote "$" in location as it is special
                  gsub(/\$$/, "\\$", loc);
                  print " \\\n\t \"/" dir "\"", "\"://" key "/" loc "\""
                }
        END        { if (!first) print "\n"; else exit 1 }
        '

was /etc/auto.smb a file that came with the system,the two outputs give the follow:
Code:

root:# /etc/auto.cifs NAS
root        -fstype=cifs,noperm,file_mode=0660,dir_mode=0755        ://NAS/root
main        -fstype=cifs,noperm,file_mode=0660,dir_mode=0755        ://NAS/main
downloads        -fstype=cifs,noperm,file_mode=0660,dir_mode=0755        ://NAS/downloads
media        -fstype=cifs,noperm,file_mode=0660,dir_mode=0755        ://NAS/media
stream        -fstype=cifs,noperm,file_mode=0660,dir_mode=0755        ://NAS/stream
vector://home/ted
root:# /etc/auto.smb NAS
-fstype=cifs \
        "/root" "://NAS/root" \
        "/main" "://NAS/main" \
        "/downloads" "://NAS/downloads" \
        "/media" "://NAS/media" \
        "/stream" "://NAS/stream"

I tried the output of my own customized script as unexecutable form, and works perfectly.
Here is the auto.master file:
Code:

#
# Sample auto.master file
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# For details of the format look at autofs(5).
#
/misc                        /etc/auto.misc                --timeout=60
#
# NOTE: mounts done from a hosts map will be mounted with the
#        "nosuid" and "nodev" options unless the "suid" and "dev"
#        options are explicitly given.
#
/misc/net/NAS                /etc/auto.test                --timeout=60 //unexecutable customized script
/misc/net/NAS                /etc/auto.smb NAS                --timeout=60
/misc/net/NAS                /etc/auto.cifs NAS                --timeout=60
/misc/net/NAS                /etc/auto.smb                --timeout=60
#
# Include central master map if it can be found using
# nsswitch sources.
#
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#
#+auto.master

I have tried all combinations above separately, but none works. autofs is a big LIER.
Thanks,
Ted

rigor 08-28-2012 05:15 PM

Hi ted_chou12!

In a different thread concerning autofs on linuxquestions.org I illustrated an executable map that's actually working on my system. Naturally, the implementation of autofs that you are using might work differently. The thread focused on other issues which don't seem to be things with which you are having problems. But you can look at how I set up the master map, and the executable map that actually worked on my system. Maybe that can help you. Here's a link to the particular message where I included the master map and an associated executable map that worked for me. The link should take you to message # 9 in that thread.

http://www.linuxquestions.org/questi...8/#post4720287

HTH.

ted_chou12 08-29-2012 01:07 PM

Thanks kakaka.
I got it to work today! The executable maps worked finally.
The auto.master file looks like this:
Code:

/net          /etc/auto.smb        timeout=......etc
auto.smb is right up there.
After restarting autofs.
You must manually access your directories. such as "ls /net/NAS". Notice the word manually, cause the machine will not search and list the avialable shares for you. But I can't get my other share for the host name TED-PC to work, my guess is that the "-" (dash) is causing the troubles. But I am not sure how to solve it.
I hope there is someone that could resolve this problem. But the issue regarding this thread is technically solved.
Thanks
Ted


All times are GMT -5. The time now is 09:32 PM.