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
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
114 show Stopping automounter
116 kill -TERM $(/sbin/pidof /usr/sbin/automount)
117 rm -f /var/lock/subsys/automount
122 if [ ! -f /var/lock/subsys/automount ]; then
123 echo "Automounter not running"
126 echo "Checking for changes to /etc/autofs/auto.master ...."
127 TMP1=`mktemp /tmp/autofs.XXXXXX` || { echo "could not make temp file" >&2; exit 1; }
128 TMP2=`mktemp /tmp/autofs.XXXXXX` || { echo "could not make temp file" >&2; exit 1; }
130 ps ax|grep "[0-9]:[0-9][0-9] /usr/sbin/automount " | (
131 while read pid tt stat time command; do
132 echo "$command" >>$TMP2
133 if ! grep -q "^$command" $TMP2; then
139 cat $TMP1 | ( while read x; do
140 if ! grep -q "^$x" $TMP2; then
148 echo "Configured Mount Points:"
151 echo "Active Mount Points:"
152 ps ax|grep "[0-9]:[0-9][0-9] /usr/sbin/automount " | (
153 while read pid tt stat time command; do echo $command; done
157 echo "Usage: $0 {start|stop|restart|reload|status}"