add base packages..
[vuplus_openvuplus_3.0] / meta-openvuplus / recipes-base / autofs / autofs-4.1.4 / autofs.init
1 #!/bin/sh
2 #
3 # $Id: rc.autofs.in,v 1.58 2005/04/11 11:30:54 raven Exp $
4 #
5 # rc file for automount using a Sun-style "master map".
6 # We first look for a local /etc/auto.master, then a YP
7 # map with that name
8 #
9 # On most distributions, this file should be called:
10 # /etc/rc.d/init.d/autofs or /etc/init.d/autofs
11 #
12 ### BEGIN INIT INFO
13 # Provides:            autofs
14 # Required-Start:      $local_fs
15 # Required-Stop:       $local_fs
16 # Default-Start:       2 3 4 5
17 # Default-Stop:                0 1 6
18 # Short-Description:   automount daemon
19 # Description:         daemon to mount (possibly remote) filesystems
20 #                      automatically upon entering the mountpoint
21 ### END INIT INFO
22
23 # For Redhat-ish systems
24 #
25 # chkconfig: 345 28 72
26 # processname: /usr/sbin/automount
27 # config: /etc/auto.master
28 # description: Automounts filesystems on demand
29
30 # This is used in the Debian distribution to determine the proper
31 # location for the S- and K-links to this init file.
32 # The following value is extracted by debstd to figure out how to
33 # generate the postinst script. Edit the field to change the way the
34 # script is registered through update-rc.d (see the manpage for
35 # update-rc.d!)
36 #
37 FLAGS="defaults 21"
38
39 #
40 # Location of the automount daemon and the init directory
41 #
42 DAEMON=/usr/sbin/automount
43 prog=`basename $DAEMON`
44 initdir=/etc/init.d
45
46 test -e $DAEMON || exit 0
47
48 #
49 # Determine which kind of configuration we're using
50 #
51 system=debian
52 if [ -f /etc/redhat-release ]; then
53         system=redhat
54 fi
55
56 if [ $system = redhat ]; then
57         . $initdir/functions
58 fi
59
60 if [ $system = debian ]; then
61         thisscript="$0"
62         if [ ! -f "$thisscript" ]; then
63                 echo "$0: Cannot find myself" 1>&2
64                 exit 1
65         fi
66 fi
67
68 PATH=/sbin:/usr/sbin:/bin:/usr/bin
69 export PATH
70
71 #
72 # We can add local options here
73 # e.g. localoptions='rsize=8192,wsize=8192'
74 #
75 localoptions=''
76
77 #
78 # Daemon options
79 # e.g. --timeout=60
80 #
81 daemonoptions=''
82
83 #
84 # load custom settings
85 #
86 if [ "$system" = "redhat" ]; then
87         LOCALOPTIONS=""
88         DAEMONOPTIONS=""
89         UNDERSCORETODOT=1
90         DISABLE_DIRECT=1
91         DAEMON_EXIT_WAIT=20
92
93         [ -f /etc/sysconfig/autofs ] && . /etc/sysconfig/autofs
94
95         # Over-ride localoptions if set
96         if [ -n "$LOCALOPTIONS" ]; then
97                 localoptions=$LOCALOPTIONS
98         fi
99
100         # Over-ride daemonoptions if set
101         if [ -n "$DAEMONOPTIONS" ]; then
102                 daemonoptions=$DAEMONOPTIONS
103         fi
104 elif [ "$system" = "debian" ]; then
105         TIMEOUT=300
106         DISABLE_DIRECT=1
107         DAEMON_EXIT_WAIT=20
108
109         [ -f /etc/default/autofs ] && . /etc/default/autofs
110
111         daemonoptions="$daemonoptions --timeout=$TIMEOUT"
112 fi
113
114 #
115 # Check for all maps that are to be loaded
116 #
117 getschemes()
118 {
119         SOURCES=`grep ^automount: /etc/nsswitch.conf | \
120                  sed -e 's/^.*://' -e 's/\[.*\]/ /g'`
121
122         if [ `echo $SOURCES | awk '{print NF}'` -gt 0 ]
123         then
124                 echo ${SOURCES}
125         else
126                 echo files
127         fi
128 }
129
130 catnismap()
131 {
132     if [ -z "$1" ] ; then
133         map="auto_master"
134     else
135         map="$1"
136     fi
137
138     # Append the map's options at the _start_ if there are any options already
139     # (ie. myopt -> $2,myopt), otherwise just append them at the end.
140     if [ -z "$2" ]; then
141         /usr/bin/ypcat -k "$map" 2> /dev/null | sed -e '/^#/d' -e '/^$/d'
142     else
143         /usr/bin/ypcat -k "$map" 2> /dev/null |
144         sed -e '/^#/d' -e '/^$/d' \
145             -e "s/^[ \t]*\([^ \t]\+\)[ \t]\+\([^ \t]\+\)[ \t]\+-\([^ \t]\+\)/\1 \2 $2,\3/" \
146             -e "s/^[ \t]*\([^ \t]\+\)[ \t]\+\([^ \t]\+\)[ \t]*$/\1 \2 $2/"
147     fi    
148 }
149
150 getfilemounts()
151 {
152     if [ -f /etc/auto.master ] ; then
153         cat /etc/auto.master | awk '{print $0}' | sed -e '/^#/d' -e '/^$/d' | (
154         while read auto_master_in
155         do
156             if [ "`echo $auto_master_in | grep '^\+'`" = "" ]; then
157                 echo $auto_master_in
158             else
159                 cat /etc/auto.master | grep '^\+' | sed -e '/^#/d' -e '/^$/d' | (
160                     while read map options; do
161                         catnismap `echo "$map" | sed -e 's/^\+//'` $options
162                     done
163                 )
164             fi
165         done
166         )
167     fi
168 }
169
170 getnismounts()
171 {
172     YPMAP=`catnismap auto.master`
173     if [ -z "$YPMAP" ]; then
174        catnismap
175     else
176        catnismap auto.master
177     fi
178 }
179
180 getldapmounts()
181 {
182     if [ -x /usr/lib/autofs/autofs-ldap-auto-master ]; then
183         [ ! -z $LDAPURI ] && export LDAPURI="$LDAPURI"
184         [ ! -z $LDAPBASE ] && export LDAPBASE="$LDAPBASE"
185         /usr/lib/autofs/autofs-ldap-auto-master 2> /dev/null
186         /usr/lib/autofs/autofs-ldap-auto-master -m automountMap \
187             -e automount -n ou -k cn -v automountInformation 2> /dev/null
188     fi
189 }
190
191 getrawmounts()
192 {
193     for scheme in `getschemes` ; do
194         case "$scheme" in
195             files)
196                 if [ -z "$filescheme" ] ; then
197                     getfilemounts
198                     filescheme=1
199                     export filescheme
200                 fi
201                 ;;
202             nis)
203                 if [ -z "$nisscheme" ] ; then
204                     getnismounts
205                     nisscheme=1
206                     export nisscheme
207                 fi
208                 ;;
209             ldap*)
210                 if [ -z "$ldapscheme" ] ; then
211                     getldapmounts
212                     ldapscheme=1
213                     export ldapscheme
214                 fi
215                 ;;
216         esac
217     done
218 }
219
220
221 #
222 # This function will build a list of automount commands to execute in
223 # order to activate all the mount points. It is used to figure out
224 # the difference of automount points in case of a reload
225 #
226 getmounts()
227 {
228         local LC_ALL=C
229         export LC_ALL
230         knownmaps=" "
231         getrawmounts | (
232         while read dir map options
233         do
234             # These checks screen out duplicates and skip over directories
235             # where the map is '-'.
236             # We can't do empty or direct host maps, so don't bother trying.
237
238             # Strip trailing slashes from the dir line if it exists to aid
239             # in checking for duplicate maps
240             dir=`echo "$dir" | sed -e "s/\/*$//"`
241
242             if [ ! -z "$map" -a "$map" = "-hosts" ] ; then
243                 continue
244             fi
245
246             if [ $DISABLE_DIRECT -eq 1 \
247                         -a x`echo $dir | grep -E "^/-"` != 'x' ]
248             then
249                 continue
250             fi
251
252             # If possible, canonicalise the path so it will always unmount
253             # cleanly.
254             link=`readlink -f "$dir"`
255             if [ ! -z "$link" ]; then
256                     dir="$link"
257             fi
258
259             # Do not include a map if it is a duplicate, maps on top of
260             # another map or another map, maps on top of it.
261             for knownmap in $knownmaps
262             do  
263                 if [ "`echo $dir/ | grep ^$knownmap`" != "" \
264                         -o "`echo $knownmap | grep ^$dir/`" != "" \]
265                 then 
266                     continue 2
267                 fi      
268             done
269
270             if [ ! -z "$dir" -a ! -z "$map" \
271                         -a x`echo "$map" | cut -c1` != 'x-' ]
272             then
273                 # If the options include a -t or --timeout, a -g or --ghost,
274                 # a -v or --verbose or a -d or --debug paramter, then pull
275                 # those particular options out.
276                 : echo DAEMONOPTIONS OPTIONS $daemonoptions $options
277                 startupoptions=
278                 if echo "$options" | grep -qE -- '\B-(t\b|-timeout\b=)' ;
279                 then
280                     startupoptions="--timeout=$(echo $options |\
281                         sed 's/.*-\(t[^0-9]*\|-timeout\)[ \t=]*\([0-9][0-9]*\).*$/\2/g')"
282                 elif echo "$daemonoptions" | grep -q -- '-t' ;
283                 then
284                     # It's okay to be sloppy with DAEMONOPTIONS as there is no
285                     # possibility of conflicting with mount or map options.
286                     startupoptions="--timeout=$(echo $daemonoptions | \
287                       sed 's/.*--*t\(imeout\)*[ \t=]*\([0-9][0-9]*\).*$/\2/g')"
288                 fi
289
290                 # Check for the ghost option
291                 if echo "$daemonoptions $options" | grep -qE -- '\B-(g\b|-ghost\b)' ;
292                 then
293                     startupoptions="$startupoptions --ghost"
294                 fi
295                 # Dont even deal with conflicts between --ghost and [no]browse
296                 # Its just insane to configure things like that.
297                 if echo "$options" | grep -qE -- '\B-browse\b' ;
298                 then
299                     startupoptions="$startupoptions --ghost"
300                 fi
301                 # Check for verbose
302                 if echo "$daemonoptions $options" | \
303                                         grep -qE -- '\B-(v\b|-verbose\b)' ;
304                 then
305                     startupoptions="$startupoptions --verbose"
306                 fi
307
308                 # Check for debug
309                 if echo "$daemonoptions $options" | \
310                                         grep -qE -- '\B-(d\b|-debug\b)' ;
311                 then
312                     startupoptions="$startupoptions --debug"
313                 fi
314
315                 # Other option flags are intended for maps.
316                 mapoptions="$(echo "$daemonoptions $options" |\
317                       sed   's/-\(t[^0-9]*\|-timeout\)[ \t=]*\([0-9][0-9]*\)//g' |
318                       sed   's/-\(g\b\|-ghost\b\)//g' |
319                       sed   's/-\(v\b\|-verbose\b\)//g' |
320                       sed   's/-\(d\b\|-debug\b\)//g' |
321                       sed   's/-\b\(no\)\?browse\b//g')"
322
323                 # Break up the maptype and map, if the map type is specified
324                 maptype=`echo $map | cut -f1 -d:`
325                 # Handle degenerate map specifiers
326                 if [ "$maptype" = "$map" ] ; then
327                     if [ "$map" = "hesiod" -o "$map" = "userhome" -o "$map" = "ldap" ] ; then
328                         maptype=$map
329                         map=
330                     elif [ "$map" = "multi" ] ; then
331                         maptype=$map
332                         map=
333 #                   elif echo "$map" | grep -q '^!'; then
334 #                       map=`echo "$map"| sed -e 's/^!//g'`
335                     elif `echo $map | grep -q "^/"` && [ -x "$map" ]; then
336                         maptype=program
337                     elif [ -x "/etc/$map" ]; then
338                         maptype=program
339                         map=`echo /etc/$map | sed 's^//^/^g'`
340                     elif `echo $map | grep -q "^/"` && [ -f "$map" ]; then
341                         maptype=file
342                     elif [ -f "/etc/$map" ]; then
343                         maptype=file
344                         map=`echo /etc/$map | sed 's^//^/^g'`
345                     else
346                         maptype=yp
347                         if [ "$UNDERSCORETODOT" = "1" ] ; then
348                             map=`basename $map | sed -e s/^auto_home/auto.home/ -e s/^auto_mnt/auto.mnt/`
349                         else
350                             map=`basename $map | sed 's^//^/^g'`
351                         fi
352                     fi
353                 fi
354                 map=`echo $map | cut -f2- -d:`
355
356                 : echo STARTUPOPTIONS $startupoptions
357                 : echo DIR $dir
358                 : echo MAPTYPE $maptype
359                 : echo MAP $map
360                 : echo MAPOPTIONS $mapoptions
361                 : echo LOCALOPTIONS $localoptions
362
363                 NEWOPTIONS=""
364                 for m in $mapoptions
365                 do
366                         if [ x"$m" = x"--" ]; then
367                                 NEWOPTIONS="$NEWOPTIONS $localoptions --"
368                         else
369                                 NEWOPTIONS="$NEWOPTIONS $m"
370                         fi
371                 done
372                 mapoptions=$NEWOPTIONS
373
374                 echo "$DAEMON $startupoptions $dir $maptype $map $mapoptions $localoptions" | sed -e 's/        / /g' -e 's/  */ /g'
375
376                 : echo ------------------------
377                 knownmaps=" $dir/ $knownmaps"
378             fi
379         done
380     )
381 }
382
383 #
384 # Status lister.
385 #
386 status()
387 {
388         echo -e $"Configured Mount Points:\n------------------------"
389         getmounts
390         echo ""
391         echo -e $"Active Mount Points:\n--------------------"
392         ps axwww|grep "[0-9]:[0-9][0-9] $DAEMON " | (
393                 while read pid tt stat time command; do echo $command; done
394         )
395 }
396
397 get_command_from_pid()
398 {
399         ps ax | grep "[0-9]:[0-9][0-9] $DAEMON " | (
400                 while read pid tt stat time command; do
401                         if [ "$pid" = "$1" ] ; then
402                                 echo `echo "$command" | \
403                                         sed 's/--pid-file.*\.pid/ /'`
404                                 return 0
405                         fi
406                 done
407         )
408         return 0
409 }
410
411 # return true if at least one pid is alive
412 alive()
413 {
414     if [ -z "$*" ]; then
415         return 1
416     fi
417     for i in $*; do
418         if kill -0 $i 2> /dev/null; then
419             return 0
420         fi
421     done
422
423     return 1
424 }
425
426 #
427 # Find pids of process group leaders
428 #
429 get_pgrp_pids()
430 {
431         ps -eo pid,pgrp,cmd|grep $DAEMON|\
432         awk '{print $1,$2}'|\
433         while read pid pgrp
434         do
435                 if [ $pid -eq $pgrp ]
436                 then
437                         echo $pid
438                 fi
439         done
440 }
441
442 #
443 # Signal each automount process group leader
444 #
445 signal_automounts()
446 {
447         RETVAL=0
448         pgrp_pids=`get_pgrp_pids`
449         for pid in $pgrp_pids
450         do
451                 kill -USR2 $pid 2 > /dev/null
452                 count=0
453                 while ps ax|grep -v grep|grep $pid >/dev/null
454                 do
455                         sleep 1 
456                         count=$(expr $count + 1)
457                         if [ $count -gt $DAEMON_EXIT_WAIT ]; then
458                                 break;
459                         fi
460                 done
461         done
462
463         if [ -n "`pidof $DAEMON`" ] ; then
464                 RETVAL=1
465         fi
466
467         return $RETVAL
468 }
469
470 umount_loopback()
471 {
472     loops=`LC_ALL=C awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts`
473     automounts=`LC_ALL=C awk '!/^#/ && $1 ~ /^automount/ {print $2}' /proc/mounts`
474
475     for l in $loops
476     do
477         # If a loop device is mounted into a subdir of the automount point,
478         # umount it here.
479         for a in $automounts
480         do
481             match=`echo $l | grep -E "^$a[\$|/]" || true`
482             if [ -n "$match" ]; then
483                 echo ""
484                 echo -n $"Unmounting loopback filesystem $match:  "
485                 loopdev=`LC_ALL=C grep $l /proc/mounts | awk '{print $1}'`
486                 umount -d $match
487                 if [ $? -eq 0 ]; then
488                     echo "done"
489                 else
490                     echo "failed ($?)"
491                 fi
492             fi
493         done
494     done
495
496     # If the loop device file exists under the automount point, umount
497     # it here.
498     loopmnts=`LC_ALL=C awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $1}' /proc/mounts`
499     for l in $loopmnts
500     do
501         loopmnt=`losetup $l | awk -F\( '{print $2}' | awk -F\) '{print $1}'`
502         for a in $automounts
503         do
504             match=`echo $loopmnt | grep -E "^$a[\$|/]" || true`
505             if [ -n "$match" ]; then
506                 echo ""
507                 echo -n $"Unmounting loopback filesystem $match:  "
508                 umount -d $match
509                 if [ $? -eq 0 ]; then
510                     echo "done"
511                 else
512                     echo "failed ($?)"
513                 fi
514             fi
515         done
516     done
517 }
518
519 #
520 # Redhat start/stop function.
521 #
522 redhat()
523 {
524
525 #
526 # See how we were called.
527 #
528 case "$1" in
529   start)
530         # Make sure the autofs filesystem type is available.
531         (grep -q autofs /proc/filesystems || /sbin/modprobe -k autofs4 || /sbin/modprobe -k autofs) 2> /dev/null
532         echo -n $"Starting $prog: "
533         TMP=`mktemp /tmp/autofs.XXXXXX` || { echo $"could not make temp file" >& 2; exit 1; }
534         getmounts | tee $TMP | sh
535         RETVAL=$?
536         if [ -s $TMP ] ; then
537             if [ $RETVAL -eq 0 ] ; then
538                 success "$prog startup"
539             else
540                 failure "$prog startup"
541             fi
542             [ $RETVAL = 0 ] && touch /var/lock/subsys/autofs
543         else
544             echo -n $"No Mountpoints Defined"
545             success "$prog startup"
546         fi
547         rm -f $TMP
548         echo
549         ;;
550   stop)
551         echo -n $"Stopping $prog:"
552         if [ -z "`pidofproc $prog`" -a -z "`getmounts`" ]; then
553                 RETVAL=0
554         else
555                 umount_loopback
556                 signal_automounts
557                 RETVAL=$?
558         fi
559         count=0
560         while [ -n "`/sbin/pidof $DAEMON`" -a $count -lt 10 ] ; do
561            killproc $DAEMON -USR2 >& /dev/null
562            RETVAL=$?
563            [ $RETVAL = 0 -a -z "`/sbin/pidof $DAEMON`" ] || sleep 3
564            count=`expr $count + 1`
565         done
566         umount -a -f -t autofs
567         rm -f /var/lock/subsys/autofs
568         if [ -n "`/sbin/pidof $DAEMON`" ] ; then
569             failure "$prog shutdown"
570         else
571             success "$prog shutdown"
572         fi
573         echo
574         ;;
575   restart)
576         redhat stop
577         redhat start
578         ;;
579   reload)
580         if [ ! -f /var/lock/subsys/autofs ]; then
581                 echo $"$prog not running"
582                 RETVAL=1
583                 return
584         fi
585         echo $"Checking for changes to /etc/auto.master ...."
586         TMP1=`mktemp /tmp/autofs.XXXXXX` || { echo $"could not make temp file" >& 2; exit 1; }
587         TMP2=`mktemp /tmp/autofs.XXXXXX` || { echo $"could not make temp file" >& 2; exit 1; }
588         getmounts >$TMP1
589         ps axwww|grep "[0-9]:[0-9][0-9] $DAEMON " | (
590             while read pid tt stat time command; do
591                 echo "$command" >>$TMP2
592                 if ! grep -q "^$command" $TMP1; then
593                     if ! echo "$command" | grep -q -e --submount; then
594                         kill -USR2 $pid 2> /dev/null
595                         echo $"Stop $command"
596                     fi
597                 else
598                         kill -HUP $pid 2> /dev/null
599                         echo $"Reload map $command"
600                 fi
601             done
602         )
603         cat $TMP1 | ( while read x; do
604                 if ! grep -q "^$x" $TMP2; then
605                         $x
606                         echo $"Start $x"
607                 fi
608         done )
609         rm -f $TMP1 $TMP2
610         ;;
611   status)
612         status
613         ;;
614   condrestart)
615         [ -f /var/lock/subsys/autofs ] && redhat restart
616         RETVAL=0
617         ;;
618   *)
619         echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
620         RETVAL=0
621 esac
622 }
623
624 #
625 # Debian start/stop functions.
626 #
627 debian()
628 {
629
630 case "$1" in
631 start)
632         echo -n 'Starting automounter:'
633
634         # make sure autofs4 is loaded
635         if ! grep -q autofs /proc/filesystems
636         then
637                 # autofs filesystem support not loaded
638                 echo -n ' loading autofs4 kernel module,'
639                 modprobe autofs4 || true
640         elif ([ -f /proc/modules ] && lsmod) | grep -q autofs[^4]; then
641                 # wrong autofs filesystem module loaded
642                 echo
643                 echo "WARNING: autofs kernel module is loaded, autofs4 needed"
644                 echo " for correct behaviour. You might experience mount failures."
645         fi
646
647         # Check that maps exist
648         if [ -z "$(getrawmounts)" ]
649         then
650                 echo " no automount maps defined."
651                 exit 0
652         fi
653
654         # ensure pid file directory exists
655         if [ ! -e /var/run/autofs ]
656         then
657                 mkdir /var/run/autofs
658         fi
659
660         getmounts | while read cmd rest
661         do
662                 mnt=`echo $rest | sed 's/^.* \(\/[^ ]*\) [A-Za-z].*$/\1/'`
663                 pidfile=/var/run/autofs/`echo $mnt | sed 's,/,_,g'`.pid
664
665                 start-stop-daemon --start --pidfile $pidfile --quiet \
666                         --exec $DAEMON -- --pid-file=$pidfile $rest
667
668                 ret=$?
669
670                 if [ $ret -ne 0 ]
671                 then
672                         echo
673                         echo " failed to start automount point $mnt"
674                 fi
675         done
676
677         echo " done."
678         ;;
679 stop)
680         echo -n 'Stopping automounter:'
681
682         umount_loopback
683         
684         any=0
685         for file in `ls /var/run/autofs/*.pid 2>/dev/null`
686         do
687                 if [ -e "$file" ]
688                 then
689                         any=1
690                         pid=`head -n 1 $file`
691                         mnt=`ps -wwo 'cmd=' $pid | sed -e \
692                           's,.* --pid-file=/var/run/autofs/\([^ ]*\)\.pid.*,\1,; s,_,/,g'`
693                         dname=`basename $DAEMON`
694
695                         start-stop-daemon --stop --quiet \
696                                         --retry USR2/$DAEMON_EXIT_WAIT \
697                                         --pidfile $file --name $dname
698
699                         ret=$?
700
701                         case $ret in
702                         0)
703 #                               echo -n " $mnt"
704                                 rm -f $file
705                                 ;;
706                         1)
707                                 echo -n -e "\n No process for automount $mnt"
708                                 rm -f $file
709                                 ;;
710                         2)
711                                 echo -n -e "\n  Couldn't stop automount for $mnt"
712                                 ;;
713                         *)
714                                 echo -n -e \
715                                 "\n Strange start-stop-daemon exit status: $ret"
716                                 ;;
717                         esac
718                 fi
719         done
720
721         echo " done."
722         ;;
723 reload)
724         echo "Reloading automounter: checking for changes ... "
725
726         TMP1=`mktemp -t autofs.XXXXXX`
727         TMP2=`mktemp -t autofs.XXXXXX`
728
729         getmounts >$TMP1
730
731         for i in `ls /var/run/autofs/*.pid 2>/dev/null`
732         do
733                 pid=`head -n 1 $i 2>/dev/null`
734                 [ "$pid" = "" ] && continue
735                 
736                 cmd=`get_command_from_pid $pid`
737                 echo $cmd >>$TMP2
738
739                 mnt=`ps -wwo 'cmd=' $pid | sed -e \
740                  's,.* --pid-file=/var/run/autofs/\([^ ]*\)\.pid.*,\1,; s,_,/,g'`
741
742                 if ! grep -q "$cmd" $TMP1; then
743                         echo "Stopping automounter for: $mnt"
744                         kill -USR2 $pid 2> /dev/null
745                 else
746                         echo "Reloading automounter map for: $mnt"
747                         kill -HUP $pid 2> /dev/null
748                 fi
749         done
750
751         cat $TMP1 | (while read x; do
752                 if ! grep -q "^$x" $TMP2; then
753                         echo $x | while read cmd rest; do
754
755                         mnt=`echo $rest | sed 's/^.* \(\/[^ ]*\) [A-Za-z].*$/\1/'`
756                         pidfile=/var/run/autofs/`echo $mnt | sed 's,/,_,g'`.pid
757
758                         start-stop-daemon --start --pidfile $pidfile --quiet \
759                                 --exec $DAEMON -- --pid-file=$pidfile $rest
760
761                         ret=$?
762
763                         if [ $ret -ne 0 ]
764                         then
765                                 echo
766                                 echo " failed to start automount point $mnt"
767                         else
768                                 echo "Started automounter: $mnt"
769                         fi
770                         done
771                 fi
772         done)
773
774         rm -f $TMP1 $TMP2
775         ;;
776 force-reload|restart)
777         debian stop
778         debian start
779         ;;
780 status)
781         status
782         ;;
783 getmounts)
784         getmounts
785         ;;
786 active)
787         alive
788         ;;
789 *)
790         echo "Usage: $initdir/autofs {start|stop|restart|reload|status|getmounts|active}" >&2
791         exit 1
792         ;;
793 esac
794 }
795
796 RETVAL=0
797 if [ $system = debian ]; then
798         debian "$@"
799 elif [ $system = redhat ]; then
800         redhat "$@"
801 fi
802
803 exit $RETVAL