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
22 # Check that networking is up.
23 if [ "${NETWORKING}" = "no" ]; then
24 echo "WARNING: Networking is down. Autofs service can't be runed."
28 DAEMON=usr/sbin/automount
30 # We can add local options here
31 # e.g. localoptions='rsize=8192,wsize=8192'
36 # This function will build a list of automount commands to execute in
37 # order # to activate all the mount points. It is used to figure out
38 # the difference of automount points in case of a reload
43 # Check for local maps to be loaded
45 if [ -f /etc/autofs/auto.master ]
47 cat /etc/autofs/auto.master | sed -e '/^#/d' -e '/^$/d'| (
48 while read dir map options
50 if [ ! -z "$dir" -a ! -z "$map" \
51 -a x`echo "$map" | cut -c1` != 'x-' ]
53 map=`echo "/etc/autofs/$map" | sed -e 's:^/etc\/autofs//:/:'`
54 options=`echo "$options" | sed -e 's/\(^\|[ \t]\)-/\1/g'`
56 echo "$DAEMON $daemonoptions $dir program $map $options $localoptions"
57 elif [ -f $map ]; then
58 echo "$DAEMON $daemonoptions $dir file $map $options $localoptions"
60 echo "$DAEMON $daemonoptions $dir `basename $map` $options $localoptions"
68 # Check for YellowPage maps to be loaded
70 if [ -e /usr/bin/ypcat ] && [ `ypcat -k auto.master 2>/dev/null | wc -l` -gt 0 ]
72 ypcat -k auto.master | (
73 while read dir map options
75 if [ ! -z "$dir" -a ! -z "$map" \
76 -a x`echo "$map" | cut -c1` != 'x-' ]
78 map=`echo "$map" | sed -e 's/^auto_/auto./'`
79 if echo $options | grep -- '-t' >/dev/null 2>&1 ; then
80 mountoptions="--timeout $(echo $options | \
81 sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')"
83 options=`echo "$options" | sed -e '
84 s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g
85 s/\(^\|[ \t]\)-/\1/g'`
86 echo "$DAEMON $daemonoptions $mountoptions $dir yp $map $options $localoptions"
94 # See how we were called.
98 # Check if the service is already running?
99 if [ ! -f /var/lock/subsys/automount ]; then
100 show Starting automounter
102 if getmounts | sh; then
108 echo "automount already is running"
110 touch /var/lock/subsys/automount
113 show Stopping automounter
114 killproc automount -TERM
115 rm -f /var/lock/subsys/automount
118 if [ ! -f /var/lock/subsys/automount ]; then
119 echo "Automounter not running"
126 echo "Configured Mount Points:"
129 echo "Active Mount Points:"
130 ps ax|grep "[0-9]:[0-9][0-9] /usr/sbin/automount " | (
131 while read pid tt stat time command; do echo $command; done
135 echo "Usage: $0 {start|stop|restart|reload|status}"