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 \
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 [ -f /etc/sysconfig/autofs ] && . /etc/sysconfig/autofs
25 # Check that networking is up.
26 if is_yes "${NETWORKING}"; then
27 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
28 msg_network_down automounter
35 DAEMON=/usr/sbin/automount
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 ]; then
48 cat /etc/autofs/auto.master | sed -e '/^#/d' -e '/^$/d'| (
49 while read dir map options; do
50 if [ ! -z "$dir" -a ! -z "$map" -a x`echo "$map" | cut -c1` != 'x-' ]; then
57 if [ "$maptype" = "$map" ]; then
58 map=`echo "/etc/autofs/$map" | sed -e 's:^/etc/autofs//:/:'`
59 options=`echo "$options" | sed -e 's/\(^\|[ \t]\)-/\1/g'`
61 echo "$DAEMON --timeout ${TIMEOUT} ${OPTIONS} $dir program $map $options"
62 elif [ -f $map ]; then
63 echo "$DAEMON --timeout ${TIMEOUT} ${OPTIONS} $dir file $map $options"
65 echo "$DAEMON --timeout ${TIMEOUT} ${OPTIONS} $dir `basename $map` $options"
70 if [ "$maptype" = "file" ]; then
71 map=`echo "/etc/autofs/$map" | sed -e 's:^/etc/autofs//:/:'`
73 echo "$DAEMON --timeout $TIMEOUT ${OPTIONS} $dir $maptype $map $options"
81 # Check for YellowPage maps to be loaded
83 if is_yes $USE_YP; then
84 if [ -e /usr/bin/ypcat ] && \
85 [ `ypcat -k auto.master 2>/dev/null | wc -l` -gt 0 ]; then
86 ypcat -k auto.master | (
87 while read dir map options; do
88 if [ ! -z "$dir" -a ! -z "$map" \
89 -a x`echo "$map" | cut -c1` != 'x-' ]; then
90 map=`echo "$map" | sed -e 's/^auto_/auto./'`
92 grep -- '-t' >/dev/null 2>&1; then
93 mountoptions="--timeout $(echo $options | \
94 sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')"
96 options=`echo "$options" | sed -e '
97 s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g
98 s/\(^\|[ \t]\)-/\1/g'`
99 echo "$DAEMON --timeout $TIMEOUT ${OPTIONS} $mountoptions \
100 $dir yp $map $options"
109 # Check if the service is already running?
110 if [ ! -f /var/lock/subsys/autofs ]; then
111 msg_starting automounter
114 $DAEMON --timeout $TIMEOUT /etc/autofs/auto.master
116 [ $RETVAL -eq 0 ] && ok || fail
117 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/autofs
119 msg_already_running automounter
124 if [ -f /var/lock/subsys/autofs ]; then
125 msg_stopping automounter
127 rm -f /var/lock/subsys/autofs >/dev/null 2>&1
129 msg_not_running automounter
134 # See how we were called.
142 restart|force-reload)
147 # nls "Configured Mount Points:"
150 # nls "Active Mount Points:"
151 # ps axw|grep "[0-9]:[0-9][0-9] /usr/sbin/automount " | (
152 # while read pid tt stat time command; do echo $command; done
156 msg_usage "$0 {start|stop|restart|force-reload|status}"