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 if [ "${NETWORKING}" = "no" ]; then
27 echo "WARNING: Networking is down. Autofs service can't be runed."
32 # We can add local options here
33 # e.g. localoptions='rsize=8192,wsize=8192'
38 # This function will build a list of automount commands to execute in
39 # order # to activate all the mount points. It is used to figure out
40 # the difference of automount points in case of a reload
45 # Check for local maps to be loaded
47 if [ -f /etc/autofs/auto.master ]
49 cat /etc/autofs/auto.master | sed -e '/^#/d' -e '/^$/d'| (
50 while read dir map options
52 if [ ! -z "$dir" -a ! -z "$map" \
53 -a x`echo "$map" | cut -c1` != 'x-' ]
55 map=`echo "/etc/autofs/$map" | sed -e 's:^/etc/autofs/:/:'`
56 # special: treat -t or --timeout (or any reasonable derivative)
57 # specially, since it can't be made a normal mount option.
58 if echo $options | grep -- '-t' >/dev/null 2>&1 ; then
59 mountoptions="--timeout $(echo $options | \
60 sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')"
62 options=`echo "$options" | sed -e '
63 s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g
64 s/\(^\|[ \t]\)-/\1/g'`
66 echo "/usr/sbin/automount $mountoptions $dir program $map $options $localoptions"
67 elif [ -f $map ]; then
68 echo "/usr/sbin/automount $mountoptions $dir file $map $options $localoptions"
70 echo "/usr/sbin/automount $mountoptions $dir `basename $map` $options $localoptions"
78 # Check for YellowPage maps to be loaded
80 if [ -e /usr/bin/ypcat ] && [ `ypcat -k auto.master 2>/dev/null | wc -l` -gt 0 ]
82 ypcat -k auto.master | (
83 while read dir map options
85 if [ ! -z "$dir" -a ! -z "$map" \
86 -a x`echo "$map" | cut -c1` != 'x-' ]
88 map=`echo "$map" | sed -e 's/^auto_/auto./'`
89 if echo $options | grep -- '-t' >/dev/null 2>&1 ; then
90 mountoptions="--timeout $(echo $options | \
91 sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')"
93 options=`echo "$options" | sed -e '
94 s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g
95 s/\(^\|[ \t]\)-/\1/g'`
96 echo "/usr/sbin/automount $mountoptions $dir yp $map $options $localoptions"
104 # See how we were called.
108 # Check if the service is already running?
109 if [ ! -f /var/lock/subsys/automount ]; then
110 show Starting automounter
116 echo "automount already is running"
118 touch /var/lock/subsys/automount
121 show Stopping automounter
122 killproc automount -TERM
123 rm -f /var/lock/subsys/automount
126 if [ ! -f /var/lock/subsys/automount ]; then
127 echo "Automounter not running"
134 echo "Configured Mount Points:"
137 echo "Active Mount Points:"
138 ps ax|grep "[0-9]:[0-9][0-9] /usr/sbin/automount " | (
139 while read pid tt stat time command; do echo $command; done
143 echo "Usage: $0 {start|stop|restart|reload|status}"