]> git.pld-linux.org Git - packages/autofs.git/blame - autofs.init
- moved auto.misc to auto.media; set CC and some flags (maybe more needed).
[packages/autofs.git] / autofs.init
CommitLineData
32959511 1#!/bin/sh
797fe9d4 2#
a38f2977 3# autofs automatically mounts filesystems when you use them,
4# and unmounts them later when you are not using them.
797fe9d4 5#
a38f2977 6# chkconfig: 2345 72 08
797fe9d4 7#
7590d9df 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 \
a38f2977 10# map with that name
797fe9d4 11#
964cdbbb 12# processname: autofs
a38f2977 13# config: /etc/autofs/auto.master
797fe9d4 14
a38f2977 15
16# Source function library
797fe9d4 17. /etc/rc.d/init.d/functions
18
a38f2977 19# Get network config
20. /etc/sysconfig/network
21
d2ed1b07 22# Demon specified configuration.
733b034a 23[ -f /etc/sysconfig/autofs ] && . /etc/sysconfig/autofs
d2ed1b07 24
a38f2977 25# Check that networking is up.
5fd65513 26if is_yes "${NETWORKING}"; then
48741d3e 27 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
5fd65513 28 msg_network_down automounter
29 exit 1
30 fi
31else
32 exit 0
e0d6e433 33fi
58b54885 34
d2ed1b07 35DAEMON=/usr/sbin/automount
797fe9d4 36
37#
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
41#
aacfd6e1 42getmounts()
797fe9d4 43{
44#
2dfbde63 45# Check for local maps to be loaded
797fe9d4 46#
86f60339 47if [ -f /etc/autofs/auto.master ]; then
5fd65513 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" \
51 -a x`echo "$map" | cut -c1` != 'x-' ]; then
d537f7f8
ER
52 maptype=`echo $map | cut -f1 -d:`
53 if [ "$maptype" = "$map" ]; then
5fd65513 54 map=`echo "/etc/autofs/$map" | sed -e 's:^/etc\/autofs//:/:'`
55 options=`echo "$options" | sed -e 's/\(^\|[ \t]\)-/\1/g'`
56 if [ -x $map ]; then
57 echo "$DAEMON --timeout $TIMEOUT $dir program $map $options"
58 elif [ -f $map ]; then
59 echo "$DAEMON --timeout $TIMEOUT $dir file $map $options"
60 else
61 echo "$DAEMON --timeout $TIMEOUT $dir `basename $map` $options"
62 fi
d537f7f8
ER
63 else
64 map=`echo $map | cut -f2- -d:`
65 if [ ! -z "$map" ]; then
66 if [ "$maptype" = "file" ]; then
67 map=`echo "/etc/autofs/$map" | sed -e 's:^/etc\/autofs//:/:'`
68 fi
69 echo "$DAEMON --timeout $TIMEOUT $dir $maptype $map $options"
70 fi
71 fi
797fe9d4 72 fi
797fe9d4 73 done
5fd65513 74 )
797fe9d4 75fi
76
77#
2dfbde63 78# Check for YellowPage maps to be loaded
797fe9d4 79#
58b54885 80if is_yes $USE_YP; then
5fd65513 81 if [ -e /usr/bin/ypcat ] && \
82 [ `ypcat -k auto.master 2>/dev/null | wc -l` -gt 0 ]; then
83 ypcat -k auto.master | (
84 while read dir map options; do
85 if [ ! -z "$dir" -a ! -z "$map" \
86 -a x`echo "$map" | cut -c1` != 'x-' ]; then
87 map=`echo "$map" | sed -e 's/^auto_/auto./'`
88 if echo $options | \
89 grep -- '-t' >/dev/null 2>&1; then
90 mountoptions="--timeout $(echo $options | \
91 sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')"
92 fi
93 options=`echo "$options" | sed -e '
94 s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g
95 s/\(^\|[ \t]\)-/\1/g'`
96 echo "$DAEMON --timeout $TIMEOUT $mountoptions \
97 $dir yp $map $options"
98 fi
99 done
100 )
101 fi
ab90884a 102fi
797fe9d4 103}
104
f897d0ea 105RETVAL=0
c6b81892 106# See how we were called.
797fe9d4 107case "$1" in
108 start)
a38f2977 109 # Check if the service is already running?
964cdbbb 110 if [ ! -f /var/lock/subsys/autofs ]; then
86f60339 111 msg_starting automounter
a38f2977 112 busy
58b54885 113 getmounts | sh
86f60339 114 RETVAL=$?
c6b81892 115 [ $RETVAL -eq 0 ] && ok || fail
964cdbbb 116 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/autofs
e8a0884c 117 else
86f60339 118 msg_already_running automounter
797fe9d4 119 fi
120 ;;
121 stop)
86f60339 122 if [ -f /var/lock/subsys/autofs ]; then
5fd65513 123 msg_stopping automounter
86f60339 124 killproc automount
125 rm -f /var/lock/subsys/autofs >/dev/null 2>&1
126 else
127 msg_not_running automounter
86f60339 128 fi
797fe9d4 129 ;;
c6b81892 130 restart|force-reload)
aacfd6e1 131 $0 stop
132 $0 start
c6b81892 133 exit $?
797fe9d4 134 ;;
135 status)
86f60339 136 nls "Configured Mount Points:"
797fe9d4 137 getmounts
138 echo ""
86f60339 139 nls "Active Mount Points:"
aba83489 140 ps axw|grep "[0-9]:[0-9][0-9] /usr/sbin/automount " | (
797fe9d4 141 while read pid tt stat time command; do echo $command; done
142 )
143 ;;
144 *)
c6b81892 145 msg_usage "$0 {start|stop|restart|force-reload|status}"
146 exit 3
797fe9d4 147esac
148
733b034a 149exit $RETVAL
This page took 0.055895 seconds and 4 git commands to generate.