LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-27-2012, 04:00 PM   #1
ted_chou12
Member
 
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 430
Blog Entries: 30

Rep: Reputation: 2
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

Last edited by ted_chou12; 08-27-2012 at 04:02 PM.
 
Old 08-28-2012, 05:15 PM   #2
kakaka
Member
 
Registered: Sep 2003
Posts: 382

Rep: Reputation: 87
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.
 
1 members found this post helpful.
Old 08-29-2012, 01:07 PM   #3
ted_chou12
Member
 
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 430

Original Poster
Blog Entries: 30

Rep: Reputation: 2
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
autofs doesnt turn ghost option off ted_chou12 Linux - Software 0 08-27-2012 12:39 PM
[SOLVED] executable file apparently doesnt exist when trying to execute with bash archnemesis Linux - Newbie 2 05-09-2011 07:06 AM
Autofs Questions- options: map versus mount and time limit local dman777 Linux - Software 0 01-01-2011 03:22 PM
how to read shell variable in /etc/auto.direct map for autofs service UltraSoul Linux - General 8 06-05-2009 07:21 AM
autofs works, but doesnt show automounted directory nef Linux - Software 1 03-02-2005 07:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration