From walken@wrs.com Fri Oct 23 23:21:48 1998 Return-Path: Received: from mail.wrs.com (unknown-1-11.wrs.com [147.11.1.11]) by mail.Linux-Consulting.com (8.8.7/8.8.7) with ESMTP id XAA03504 for ; Fri, 23 Oct 1998 23:21:47 -0700 Received: from gesvres.vannes.wrsec.fr (gesvres.vannes.wrsec.fr [147.11.80.24]) by mail.wrs.com (8.9.1/8.9.1) with SMTP id GAA29682; Sat, 24 Oct 1998 06:28:25 -0700 (PDT) Received: from erdre.vannes.wrsec.fr by gesvres.vannes.wrsec.fr (SMI-8.6/SMI-SVR4) id PAA02526; Sat, 24 Oct 1998 15:25:25 +0200 Received: from localhost by erdre.vannes.wrsec.fr (SMI-8.6/SMI-SVR4) id PAA18502; Sat, 24 Oct 1998 15:25:22 +0200 Date: Sat, 24 Oct 1998 15:25:22 +0200 (MET DST) From: Michel LESPINASSE Sender: walken@vannes.wrsec.fr To: Alvin Oga cc: alvin@linux-consulting.com Subject: Re: autofs with NIS+ and development kernels In-Reply-To: <199810232146.OAA04083@leopard.imedia.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Status: RO On Fri, 23 Oct 1998, Alvin Oga wrote: > hi Michel > could you email it to me to ??? > I'll include the steps needed into the autoFS HOWTO Well, here comes.... I didnt know about the autofs howto, are you currently writing it or should it be on every good HOWTO directory ? #! /bin/sh -e # # rc file for automount using a Sun-style "master map". # We first look for a local /etc/auto.master, then a YP # map with that name # # On most distributions, this file should be called: # /etc/rc.d/init.d/autofs or /etc/init.d/autofs # # # List of options to ignore with NIS maps. You can use this to filter out # options that Linux does not (yet) understand if your mount does not # understand the -s (sloppy) flag. Seperate the options with spaces! # PRUNEOPTIONS="quota" # # We can add local options here # e.g. localoptions='rsize=8192,wsize=8192' # localoptions='' # Check if automount exists test -f /usr/sbin/automount || exit 0 # Check if autofs is available on the system if ! grep -q autofs /proc/filesystems; then if [ ! -e /lib/modules/`uname -r`/fs/autofs.o ]; then echo "Error: autofs support not available." exit 0 fi fi PATH=/sbin:/usr/sbin:/bin:/usr/bin export PATH # Make a regular expression from PRUNEOPTIONS test ! -z "$PRUNEOPTIONS" && PRUNEREGEX=`echo $PRUNEOPTIONS | \ sed -e 's#^#\\\(#' -e 's# \+#\\\|#' -e 's#$#\\\)#'` # # This function will build a list of automount commands to execute in # order # to activate all the mount points. It is used to figure out # the difference of automount points in case of a reload # getmounts() { # # Check for local maps to be loaded # if [ -f /etc/auto.master ] then cat /etc/auto.master | sed -e '/^#/d' -e '/^$/d'| ( while read dir map options do if [ ! -z "$dir" -a ! -z "$map" -a \ x`echo "$map" | cut -c1` != 'x-' ] then map=`echo "/etc/$map" | sed -e 's:^/etc//:/:'` # special: treat -t or --timeout (or any reasonable derivative) # specially, since it can't be made a normal mount option. if echo $options | grep -- '-t' >/dev/null 2>&1 ; then mountoptions="--timeout $(echo $options | \ sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')" fi options=`echo "$options" | sed -e ' s/--*t\(imeout\)*[ ]*[0-9][0-9]*//g s/\(^\|[ \t]\)-/\1/g'` if [ -x $map ]; then echo "$automount $mountoptions $dir program $map $options $localoptions" elif [ -f $map ]; then echo "$automount $mountoptions $dir file $map $options $localoptions" else echo "$automount $mountoptions $dir `basename $map` $options $localoptions" fi fi done ) | sed 's/ / /g' fi # # Check for YellowPage maps to be loaded # if [ -e /usr/bin/ypcat ] && [ `ypcat -k auto.master 2>/dev/null | wc -l` -gt 0 ] then ypcat -k auto.master | ( while read dir map options do if [ ! -z "$dir" -a ! -z "$map" \ -a x`echo "$map" | cut -c1` != 'x-' ] then map=`echo "$map" | sed -e 's/^auto_/auto./'` # special: treat -t or --timeout (or any reasonable derivative) # specially, since it can't be made a normal mount option. if echo $options | grep -- '-t' >/dev/null 2>&1 ; then mountoptions="--timeout $(echo $options | \ sed 's/^.*-t\(imeout\)*[ ]*\([0-9][0-9]*\).*$/\2/g')" fi options=`echo "$options" | sed -e ' s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g s/\(^\|[ \t]\)-/\1/g'` options=`echo "$options" | sed -e 's/\(^\|[ \t]\)-/\1/g'` test ! -z "$PRUNEREGEX" && \ options=`echo $options | \ sed -e "s#$PRUNEREGEX##g" -e 's#,\+#,#g' -e 's#,$##'` echo "$automount $mountoptions $dir yp $map $options $localoptions" fi done ) fi } # # Status lister. # status() { echo "Configured Mount Points:" echo "------------------------" getmounts echo "" echo "Active Mount Points:" echo "--------------------" ps ax|grep "[0-9]:[0-9][0-9] /usr/sbin/[a]utomount " | ( while read pid tt stat time command; do echo $command; done ) } automount=/usr/sbin/automount # # See how we were called. # case "$1" in start) echo -n 'Starting automounter:' getmounts | while read cmd mnt rest do echo -n " $mnt" pidfile=/var/run/automount`echo $mnt | sed 's/\//./g'`.pid start-stop-daemon --start --pidfile $pidfile --quiet \ --exec $automount -- $mnt $rest # # Automount needs a '--pidfile' or '-p' option. # For now we look for the pid ourself. # ps ax | grep "[0-9]:[0-9][0-9] $automount $mnt" | ( read pid rest echo $pid > $pidfile echo "$mnt $rest" >> $pidfile ) done echo "." ;; stop) echo 'Stopping automounter.' start-stop-daemon --stop --quiet --signal USR2 --exec $automount ;; force-reload|reload|restart) echo "Reloading automounter: checking for changes ... " TMP=/var/run/automount.tmp getmounts >$TMP for i in /var/run/automount.*.pid do pid=`head -n 1 $i 2>/dev/null` [ "$pid" = "" ] && continue command=`tail +2 $i | sed -e 's/.*[0-9]:[0-9]\{2\} \(.*\)/\1/'` if ! grep -q "^$command" $TMP then echo "Stopping automounter: $command" kill -USR2 $pid fi done rm -f $TMP /etc/init.d/autofs start ;; status) status ;; *) echo "Usage: /etc/init.d/autofs {start|stop|restart|reload|status|force-reload}" >&2 exit 1 ;; esac exit 0 Michel "Walken" LESPINASSE - Development Engineer at Wind River Systems walken@wrs.com - http://www.via.ecp.fr/~walken/