mark-

no, it is not an error on your part that you run slackware. :> i've
attached an autofs script that i've written to work with slackware. the
script assumes that automount is installed in /usr/local/sbin. if it
isn't, edit the 3rd line[DAEMON=/usr/local/sbin/automount] of the script
setting the correct location.

-kelley


 >> kelley j eicher
<<  UNIX architect
 >> Univ. of MN Astronomy Dept.
<<  ph: (612) 626-2067 or (612) 624-3589
 >> fx: (612) 626-2029
<<  office: 385 physics
 >> [EMAIL PROTECTED]

On Thu, 17 May 2001, Mark wrote:

> 
> 
> Hi, fairly new user here, and I could really use some help.
> 
> I found the Autofs at Freshmeat and thought "wow! gotta have this."
> 
> I unpacked the file, and made sure I read all the docs.
> 
> Recompiled my kernel to make sure the necessary code was there.
> 
> Compiled and installed autofs, et al.
> 
> Read all the man pages.
> 
> Read the mini howto at LDP and two other pages linked from the howto.
> 
> Edited auto.master and auto.miss as described.
> 
> Made autofs executable.
> 
> Ran it  : only to get a message that tells me I'm using an
> unknown system. I then checked the rc.autofs script, which seems to
> imply that it will only work with Redhat or Debian.
> 
> Now I r(ALL)tfm(s) and to the best of my knowledge nowhere is it stated
> that it only works with these two distributions only, other than inside
> the autofs script.
> 
> And guess what? I run Slackware.
> 
> I'm hoping that I misunderstood the error message/script somehow, and
> that there's some obvious and/or arcane switch somewhere that I need
> to enter that will alow me to use this piece of software. If not, and all
> the effort I made was in vain, I would make a VERY strong suggestion
> that mention be made of this limitation somewhere BEFORE people start installing
> the app, such as the readme, the install file, the Howto, or any of the
> places that I read as a matter of course before installation.
> 
> Again, if this is an error on my part, I would love to know the way to
> fix it, and if not, please rectify this so others won't have to end up
> wasting as much time as I did.
> 
> Thanks
> Mark Hughes
> 
#!/bin/bash

DAEMON=/usr/local/sbin/automount
initdir=/etc/init.d

test -e $DAEMON || exit 0

PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH

#
# We can add local options here
# e.g. localoptions='rsize=8192,wsize=8192'
#
localoptions='rsize=8192,wsize=8192'

#
# Daemon options
# e.g. --timeout 60
#
daemonoptions='--timeout 60'

#
# 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
#
function 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//:/:'`
                options=`echo "$options" | sed -e 's/\(^\|[ \t]\)-/\1/g'`
                if [ -x $map ]; then
                    echo "$DAEMON $daemonoptions $dir program $map $options 
$localoptions"
                elif [ -f $map ]; then
                    echo "$DAEMON $daemonoptions $dir file $map $options 
$localoptions"
                else
                    echo "$DAEMON $daemonoptions $dir `basename $map` $options 
$localoptions"
                fi
            fi
        done
    )
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./'`
                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\)*[ \t]*[0-9][0-9]*//g
                  s/\(^\|[ \t]\)-/\1/g'`
                echo "$DAEMON $daemonoptions $mountoptions $dir yp $map $options 
$localoptions"
            fi
        done
    )
fi
}

#
# Status lister.
#
function status()
{
        echo "Configured Mount Points:"
        echo "------------------------"
        getmounts
        echo ""
        echo "Active Mount Points:"
        echo "--------------------"
        ps ax|grep "[0-9]:[0-9][0-9] automount " | (
                while read pid tt stat time command; do echo $command; done
        )
}

# return true if at least one pid is alive
function alive()
{
    if [ -z "$*" ]; then
        return 1
    fi
    for i in $*; do
        if kill -0 $i 2> /dev/null; then
            return 0
        fi
    done

    return 1
}

# Slackware start/stop/restart/status function
# See how we were called.
#
case "$1" in
  start)
        # Check if the automounter is already running?
        if [ ! -f /var/lock/subsys/autofs ]; then
            echo 'Starting automounter: '
            getmounts | sh
            touch /var/lock/subsys/autofs
        fi
        ;;
  stop)
        pids=$(/sbin/pidof $DAEMON)
        kill -TERM $pids 2> /dev/null && sleep 1
        count=1
        while alive $pids; do
            sleep 5
            count=$(expr $count + 1)
            if [ $count -gt 5 ]; then
                echo "Giving up on automounter"
                break;
            fi
            echo "Automounter not stopped yet: retrying... (attempt $count)"
        done
        if [ $count -gt 1 -a $count -le 10 ]; then
            echo "Automounter stopped"
        fi
        rm -f /var/lock/subsys/autofs
        ;;
  reload|restart)
        if [ ! -f /var/lock/subsys/autofs ]; then
                echo "Automounter not running"
                exit 1
        fi
        echo "Checking for changes to /etc/auto.master ...."
        TMP1=`mktemp /tmp/autofs.XXXXXX` || { echo "could not make temp file" >& 2; 
exit 1; }
        TMP2=`mktemp /tmp/autofs.XXXXXX` || { echo "could not make temp file" >& 2; 
exit 1; }
        getmounts >$TMP1
        ps ax|grep "[0-9]:[0-9][0-9] $DAEMON " | (
            while read pid tt stat time command; do
                echo "$command" >>$TMP2
                if ! grep -q "^$command" $TMP2; then
                        while kill -USR2 $pid; do
                            sleep 3
                        done
                        echo "Stop $command"
                fi
            done
        )
        ( while read x; do
                if ! grep -q "^$x" $TMP2; then
                        $x
                        echo "Start $x"
                fi
        done ) < $TMP1
        rm -f $TMP1 $TMP2
        ;;
  status)
        status
        ;;
  *)
        echo "Usage: $initdir/autofs {start|stop|restart|reload|status}"
        exit 1
esac

exit 0

Reply via email to