3 # autofs automatically mounts filesystems when you use them,
4 # and unmounts them later when you are not using them.
6 # chkconfig: 2345 72 08
8 # description: Script for automount using a Sun-style "master map".
9 # We first look for a local /etc/autofs/auto.master, then a YP
12 # processname: automount
13 # config: /etc/autofs/auto.master
16 # Source function library
17 . /etc/rc.d/init.d/functions
20 . /etc/sysconfig/network
23 [ -f /etc/sysconfig/inetd ] && . /etc/sysconfig/inetd
25 # Check that networking is up.
26 [ "${NETWORKING}" = "no" ] && echo "Error: Networking is down"; exit 0
29 # We can add local options here
30 # e.g. localoptions='rsize=8192,wsize=8192'
35 # This function will build a list of automount commands to execute in
36 # order # to activate all the mount points. It is used to figure out
37 # the difference of automount points in case of a reload
42 # Check for local maps to be loaded
44 if [ -f /etc/autofs/auto.master ]
46 cat /etc/autofs/auto.master | sed -e '/^#/d' -e '/^$/d'| (
47 while read dir map options
49 if [ ! -z "$dir" -a ! -z "$map" \
50 -a x`echo "$map" | cut -c1` != 'x-' ]
52 map=`echo "/etc/autofs/$map" | sed -e 's:^/etc/autofs/:/:'`
53 # special: treat -t or --timeout (or any reasonable derivative)
54 # specially, since it can't be made a normal mount option.
55 if echo $options | grep -- '-t' >/dev/null 2>&1 ; then
56 mountoptions="--timeout $(echo $options | \
57 sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')"
59 options=`echo "$options" | sed -e '
60 s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g
61 s/\(^\|[ \t]\)-/\1/g'`
63 echo "/usr/sbin/automount $mountoptions $dir program $map $options $localoptions"
64 elif [ -f $map ]; then
65 echo "/usr/sbin/automount $mountoptions $dir file $map $options $localoptions"
67 echo "/usr/sbin/automount $mountoptions $dir `basename $map` $options $localoptions"
75 # Check for YellowPage maps to be loaded
77 if [ -e /usr/bin/ypcat ] && [ `ypcat -k auto.master 2>/dev/null | wc -l` -gt 0 ]
79 ypcat -k auto.master | (
80 while read dir map options
82 if [ ! -z "$dir" -a ! -z "$map" \
83 -a x`echo "$map" | cut -c1` != 'x-' ]
85 map=`echo "$map" | sed -e 's/^auto_/auto./'`
86 if echo $options | grep -- '-t' >/dev/null 2>&1 ; then
87 mountoptions="--timeout $(echo $options | \
88 sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')"
90 options=`echo "$options" | sed -e '
91 s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g
92 s/\(^\|[ \t]\)-/\1/g'`
93 echo "/usr/sbin/automount $mountoptions $dir yp $map $options $localoptions"
101 # See how we were called.
105 # Check if the service is already running?
106 if [ ! -f /var/lock/subsys/automount ]; then
107 show Starting automounter
113 echo "automount already is running"
115 touch /var/lock/subsys/automount
118 show Stopping automounter
119 killproc automount -TERM
120 rm -f /var/lock/subsys/automount
123 if [ ! -f /var/lock/subsys/automount ]; then
124 echo "Automounter not running"
131 echo "Configured Mount Points:"
134 echo "Active Mount Points:"
135 ps ax|grep "[0-9]:[0-9][0-9] /usr/sbin/automount " | (
136 while read pid tt stat time command; do echo $command; done
140 echo "Usage: $0 {start|stop|restart|reload|status}"