SUMMARY: automounter stuff

From: Dan (Dan.Farmer@Corp.Sun.COM)
Date: Mon Mar 30 1992 - 20:35:26 CST


  Thanks for all the responses! It would take too long to reply to everyone
that replied to me, so I'll just post the summary here. My overall
question was basically that I wanted to get all the users that were not being
automounted on a particular host, but there were other questions too:

  How can you tell if the automounter is running?

The best answer I got to was to look in /etc/mtab for clues. A typical
automounter line looks something like:

foo:(pid124) /home ignore ro,intr,port=722,map=autouser,indirect,dev=8206 0 0

  How can I tell if automounter uses a text file or NIS for maps? Any
  format differences?

You can usually tell if automounter uses a text file or NIS for maps by
looking at the startup args. The map formats (NIS and text file) are indeed
the same, no suprise there. Fortunately, I'm ignoring all that stuff in my
final solution, so no problem for me anyway :-)

Here's some simple/crude code that tries to extract any non-automounting
users from a system. I'm just looking at all the 2nd fields in /etc/mtab to
get the directories that are potential automounted home dirs, and then using
using that as a awk input to suck out all the pertainent guts of the output of:

(cat /etc/passwd; ypcat passwd)

(or whatever you want to stick there instead.) I'm not sure whether or
not I really want to just look for any automounted home dirs, or any
NFS dirs, or what. This will all get tossed into COPS as an option
somewhere, if anyone cares.

  See comments and code for more info; and thanks again --

  -- dan

==============================================================================
p.s. paths to programs are hard coded, ala cops.
either run reconfig (from cops) on the file, or
put in your own paths.
==============================================================================

:
#
# Try to find out which home-dirs are not being automounted...
# First, look at /etc/mtab, which, unfortunately, rumours say might
# go away in BSD 4.4. Anyway, grab the automounter info there, then use
# that for an awk script for all home-dirs that *aren't* being automounted.
#
AWK=/bin/awk
ECHO=/bin/echo
TEST=/bin/test
YPCAT=/usr/bin/ypcat
CAT=/bin/cat
RM=/bin/rm
SED=/bin/sed

passwd="./tmp_passwd.$$"
etc_passwd=/etc/passwd

# mtab has a clue if automounter is running; typical line:
# sun:(pid129) /home ignore ro,intr,port=723,map=/etc/auto.direct,direct 0 0
#
# I'll be looking for the "(pid129)" type of thing.
mtab=./mtab
mtab=/etc/mtab

if $TEST ! -s "$mtab" ; then
        $ECHO "Can't open $mtab"
        exit 1;
        fi

# quick password hack
($CAT $etc_passwd ; $YPCAT passwd ) > $passwd
# ($CAT $etc_passwd ) > $passwd

# automounter dirs?
#
# all the magic happens here; forming an egrep expression:
# =`$AWK '/(pid[0-9]+)/ {print $2} ' $mtab |
all_automounts=`$AWK '/(pid[0-9]+)/ {print $2} ' $mtab |
                        $SED 's#/#\\\/#g' |
                        $AWK '{ x[i++]=$0;} \
                        END {
                        for (j=0;j<i-1;j++) {
                            printf("!/^.*:.*:.*:.*:.*:%s\\\/.*:.*$/&&",x[j]); \
                            printf("!/^.*:.*:.*:.*:.*:%s:.*$/&& ",x[j])} \
                        if (j) {
                            printf("!/^.*:.*:.*:.*:.*:%s\\\/.*:.*$/&&",x[j]); \
                            printf("!/^.*:.*:.*:.*:.*:%s:.*$/",x[j])}}'`

if $TEST -z "$all_automounts" ; then
        $ECHO not running automounter...
        $RM -f $passwd
        exit 1
        fi

$AWK "$all_automounts" $passwd

$RM -f $passwd
# finis



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:06:40 CDT