blob: ef525bde400c011e0b610ea04bcdeec33cfe912d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-fs/autofs/files/autofs.rc7,v 1.5 2004/09/02 17:56:05 swegener Exp $
# rc file for automount using a Sun-style "master map".
# We first look for a local /etc/auto.master, then a YP
# map with that name
depend() {
need net
use portmap ypbind
}
opts="start stop status stats reload restart"
#
# This function will build a list of automount commands to execute in
# order to activate all the mount points. It is used to figure out
# the difference of automount points in case of a reload
#
getmounts() {
#
# Check for local maps to be loaded
#
if [ -f /etc/autofs/auto.master ]
then
cat /etc/autofs/auto.master | sed -e '/^ *[^# ]/!d'| (
while read dir map options
do
if [ ! -z "$dir" -a ! -z "$map" \
-a x`echo "$map" | cut -c1` != 'x-' ]
then
map=`echo "/etc/$map" | sed -e 's:^/etc//:/:'`
timeout=`echo $options | sed --silent -e 's/\(.*\)\(--timeout=[0-9]\+\)\(.*\)/\2/g ; /--timeout=[0-9]\+/ p'`
options=`echo $options | sed -e 's/\(.*\)\(--timeout=[0-9]\+\)\(.*\)/\1\3/g ; s/\(^\|[ \t]\)-/\1/g'`
if [ -x $map ]; then
echo "/usr/sbin/automount $timeout $dir program $map $options $localoptions"
elif [ -f $map ]; then
echo "/usr/sbin/automount $timeout $dir file $map $options $localoptions"
else
echo "/usr/sbin/automount $timeout $dir `basename $map` $options $localoptions"
fi
fi
done
)
fi
#
# Check for YellowPage maps to be loaded
#
if [ -e /usr/bin/ypcat ] && [ `ypcat -k auto.master 2>/dev/null | wc -l` -gt 0 ]
then
ypcat -k auto.master | (
while read dir map options
do
if [ ! -z "$dir" -a ! -z "$map" \
-a x`echo "$map" | cut -c1` != 'x-' ]
then
map=`echo "$map" | sed -e 's/^auto_/auto./'`
if echo $options | grep -- '-t' >/dev/null 2>&1 ; then
mountoptions="--timeout $(echo $options | \
sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')"
fi
options=`echo "$options" | sed -e '
s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g
s/\(^\|[ \t]\)-/\1/g'`
echo "/usr/sbin/automount $mountoptions $dir yp $map $options $localoptions"
fi
done
)
fi
}
start() {
ebegin "Starting automounter"
getmounts | while read cmd timeout mnt rest
do
echo -n " $mnt"
pidfile=/var/run/autofs`echo $mnt | sed 's/\//./g'`.pid
start-stop-daemon --start --pidfile $pidfile --quiet \
--exec /usr/sbin/automount -- $timeout $mnt $rest
#
# Automount needs a '--pidfile' or '-p' option.
# For now we look for the pid ourself.
#
ps ax | grep "[0-9]:[0-9][0-9] /usr/sbin/automount $timeout \?$mnt" | (
read pid rest
echo $pid > $pidfile
echo "$mnt $rest" >> $pidfile
)
done
eend $?
}
stop() {
ebegin "Stopping automounter"
start-stop-daemon --stop --quiet --signal 12 --exec /usr/sbin/automount
eend $?
}
stats() {
echo "Configured Mount Points:"
echo "------------------------"
getmounts
echo ""
echo "Active Mount Points:"
echo "--------------------"
ps awx | grep automount | (
while read pid tt stat time command; do echo $command; done
)
}
reload() {
echo "Reloading automounter: checking for changes ... "
TMP=/var/run/autofs.tmp
getmounts >$TMP
for i in /var/run/autofs.*.pid
do
pid=`head -n 1 $i 2>/dev/null`
[ "$pid" = "" ] && continue
command=`tail -n +2 $i`
if ! grep -q "^$command" $TMP
then
echo "Stopping automounter: $command"
kill -USR2 $pid
fi
done
rm -f $TMP
svc_start
}
restart() {
svc_stop
svc_start
}
|