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 # Demon specified configuration.
23 . /etc/sysconfig/autofs
25 # Check that networking is up.
26 if [ "${NETWORKING}" = "no" ]; then
27 echo "WARNING: Networking is down. Autofs service can't be runed."
31 DAEMON=/usr/sbin/automount
34 # This function will build a list of automount commands to execute in
35 # order # to activate all the mount points. It is used to figure out
36 # the difference of automount points in case of a reload
41 # Check for local maps to be loaded
43 if [ -f /etc/autofs/auto.master ]
45 cat /etc/autofs/auto.master | sed -e '/^#/d' -e '/^$/d'| (
46 while read dir map options
48 if [ ! -z "$dir" -a ! -z "$map" \
49 -a x`echo "$map" | cut -c1` != 'x-' ]
51 map=`echo "/etc/autofs/$map" | sed -e 's:^/etc\/autofs//:/:'`
52 options=`echo "$options" | sed -e 's/\(^\|[ \t]\)-/\1/g'`
54 echo "$DAEMON --timeout $TIMEOUT $dir program $map $options"
55 elif [ -f $map ]; then
56 echo "$DAEMON --timeout $TIMEOUT $dir file $map $options"
58 echo "$DAEMON --timeout $TIMEOUT $dir `basename $map` $options"
66 # Check for YellowPage maps to be loaded
68 if [ -e /usr/bin/ypcat ] && [ `ypcat -k auto.master 2>/dev/null | wc -l` -gt 0 ]
70 ypcat -k auto.master | (
71 while read dir map options
73 if [ ! -z "$dir" -a ! -z "$map" \
74 -a x`echo "$map" | cut -c1` != 'x-' ]
76 map=`echo "$map" | sed -e 's/^auto_/auto./'`
77 if echo $options | grep -- '-t' >/dev/null 2>&1 ; then
78 mountoptions="--timeout $(echo $options | \
79 sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')"
81 options=`echo "$options" | sed -e '
82 s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g
83 s/\(^\|[ \t]\)-/\1/g'`
84 echo "$DAEMON --timeout $TIMEOUT $mountoptions $dir yp $map $options"
92 # See how we were called.
96 # Check if the service is already running?
97 if [ ! -f /var/lock/subsys/automount ]; then
98 show Starting automounter
100 if getmounts | sh; then
106 echo "automount already is running"
108 touch /var/lock/subsys/automount
111 show Stopping automounter
112 killproc automount -TERM
113 rm -f /var/lock/subsys/automount
116 if [ ! -f /var/lock/subsys/automount ]; then
117 echo "Automounter not running"
124 echo "Configured Mount Points:"
127 echo "Active Mount Points:"
128 ps ax|grep "[0-9]:[0-9][0-9] /usr/sbin/automount " | (
129 while read pid tt stat time command; do echo $command; done
133 echo "Usage: $0 {start|stop|restart|reload|status}"