5 # /etc/rc.d/init.d/autofs
7 # rc file for automount using a Sun-style "master map".
8 # We first look for a local /etc/autofs/auto.master, then a YP
11 # chkconfig: 2345 72 08
12 # description: automatically mounts filesystems when you use \
13 # them, and unmounts them later when you are not using them.
14 # processname: automount
15 # Note that there may be multiple processes names automount
16 # config: /etc/autofs/auto.master
17 # Note that all other config files are automatically reloaded
18 # and may be different on different systems; we can ignore them
21 # Source function library.
22 . /etc/rc.d/init.d/functions
24 [ -f /usr/sbin/automount ] || exit 0
27 # We can add local options here
28 # e.g. localoptions='rsize=8192,wsize=8192'
33 # This function will build a list of automount commands to execute in
34 # order # to activate all the mount points. It is used to figure out
35 # the difference of automount points in case of a reload
40 # Check for local maps to be loaded
42 if [ -f /etc/autofs/auto.master ]
44 cat /etc/autofs/auto.master | sed -e '/^#/d' -e '/^$/d'| (
45 while read dir map options
47 if [ ! -z "$dir" -a ! -z "$map" \
48 -a x`echo "$map" | cut -c1` != 'x-' ]
50 map=`echo "/etc/autofs/$map" | sed -e 's:^/etc/autofs/:/:'`
51 # special: treat -t or --timeout (or any reasonable derivative)
52 # specially, since it can't be made a normal mount option.
53 if echo $options | grep -- '-t' >/dev/null 2>&1 ; then
54 mountoptions="--timeout $(echo $options | \
55 sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')"
57 options=`echo "$options" | sed -e '
58 s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g
59 s/\(^\|[ \t]\)-/\1/g'`
61 echo "/usr/sbin/automount $mountoptions $dir program $map $options $localoptions"
62 elif [ -f $map ]; then
63 echo "/usr/sbin/automount $mountoptions $dir file $map $options $localoptions"
65 echo "/usr/sbin/automount $mountoptions $dir `basename $map` $options $localoptions"
73 # Check for YellowPage maps to be loaded
75 if [ -e /usr/bin/ypcat ] && [ `ypcat -k auto.master 2>/dev/null | wc -l` -gt 0 ]
77 ypcat -k auto.master | (
78 while read dir map options
80 if [ ! -z "$dir" -a ! -z "$map" \
81 -a x`echo "$map" | cut -c1` != 'x-' ]
83 map=`echo "$map" | sed -e 's/^auto_/auto./'`
84 if echo $options | grep -- '-t' >/dev/null 2>&1 ; then
85 mountoptions="--timeout $(echo $options | \
86 sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')"
88 options=`echo "$options" | sed -e '
89 s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g
90 s/\(^\|[ \t]\)-/\1/g'`
91 echo "/usr/sbin/automount $mountoptions $dir yp $map $options $localoptions"
99 # See how we were called.
103 # Check if the automounter is already running?
104 if [ ! -f /var/lock/subsys/automount ]; then
105 show Starting automounter
108 touch /var/lock/subsys/automount
112 echo "Automounter already is running"
116 show Stopping automounter
117 killproc automount -TERM
118 rm -f /var/lock/subsys/automount
121 if [ ! -f /var/lock/subsys/automount ]; then
122 echo "Automounter not running"
129 echo "Configured Mount Points:"
132 echo "Active Mount Points:"
133 ps ax|grep "[0-9]:[0-9][0-9] /usr/sbin/automount " | (
134 while read pid tt stat time command; do echo $command; done
138 echo "Usage: $0 {start|stop|restart|reload|status}"