blob: a78e8b24c8c5128ec3c7353f9a3c5469edf3a3d9 (
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
#!/sbin/runscript
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /var/cvsroot/gentoo-x86/net-fs/autofs/files/autofs.rc8,v 1.3 2003/01/13 04:28:23 bcowan 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
DAEMON=/usr/sbin/automount
depend() {
need localmount
use ypbind nfs
}
opts="start stop status stats reload restart"
#
# Check for all maps that are to be loaded
#
function getschemes()
{
grep ^automount: /etc/nsswitch.conf | sed -e 's/^.*://' -e 's/\[.*\]/ /g'
}
function getfilemounts()
{
if [ -f /etc/autofs/auto.master ] ; then
cat /etc/autofs/auto.master | sed -e '/^#/d' -e '/^$/d'
fi
}
function getnismounts()
{
/usr/bin/ypcat -k auto.master 2> /dev/null | sed -e '/^#/d' -e '/^$/d'
}
function getldapmounts()
{
if [ -x /usr/lib/autofs/autofs-ldap-auto-master ]; then
/usr/lib/autofs/autofs-ldap-auto-master 2> /dev/null
fi
}
function getrawmounts()
{
for scheme in `getschemes` ; do
case "$scheme" in
files)
getfilemounts
;;
nis*)
getnismounts
;;
ldap*)
getldapmounts
;;
esac
done
}
#
# 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
#
function getmounts()
{
knownmaps=" "
getrawmounts | (
while read dir map options
do
# These checks screen out duplicates and skip over directories
# where the map is '-'.
if [ ! -z "$dir" -a ! -z "$map" \
-a x`echo "$map" | cut -c1` != 'x-' \
-a "`echo "$knownmaps" | grep $dir/`" = "" ]
then
# If the options include a -t or --timeout parameter, then
# pull those particular options out.
# echo DAEMONOPTIONS OPTIONS $daemonoptions $options
startupoptions=
if echo $options | grep -q -- '-t' ; then
startupoptions="--timeout $(echo $daemonoptions $options | \
sed 's/.*--*t\(imeout\)*[ \t=]*\([0-9][0-9]*\).*$/\2/g')"
fi
# Other option flags are intended for maps.
mapoptions="$(echo "$daemonoptions $options" |\
sed 's/--*t\(imeout\)*[ \t=]*\([0-9][0-9]*\)//g')"
# Break up the maptype and map, if the map type is specified
maptype=`echo $map | cut -f1 -d:`
# Handle degenerate map specifiers
if [ "$maptype" = "$map" ] ; then
if [ -x "$map" ]; then
maptype=program
elif [ -x "/etc/$map" ]; then
maptype=program
map=`echo /etc/$map | sed 's^//^/^g'`
elif [ -f "$map" ]; then
maptype=file
elif [ -f "/etc/$map" ]; then
maptype=file
map=`echo /etc/$map | sed 's^//^/^g'`
elif [ "$map" = "hesiod" -o "$map" = "userhome" ] ; then
maptype=$map
map=
elif [ "$map" = "multi" ] ; then
maptype=$map
map=
else
maptype=yp
map=`basename $map | sed -e s/^auto_home/auto.home/ -e s/^auto_mnt/auto.mnt/`
fi
fi
map=`echo $map | cut -f2- -d:`
#echo STARTUPOPTIONS $startupoptions > /tmp/debug
#echo DIR $dir >> /tmp/debug
#echo MAPTYPE $maptype >> /tmp/debug
#echo MAP $map >> /tmp/debug
#echo MAPOPTIONS $mapoptions >> /tmp/debug
#echo LOCALOPTIONS $localoptions >> /tmp/debug
echo "$DAEMON $startupoptions $dir $maptype $map $mapoptions $localoptions" | sed -e 's/ / /g' -e 's/ / /g'
# echo ------------------------
fi
knownmaps=" $dir/ $knownmaps"
done
)
}
start() {
ebegin "Starting automounter"
getmounts | while read cmd timeout mnt rest
do
#FIXME: this works but it really sucks
if echo $timeout|grep -v -- '--timeout' >/dev/null ; then
rest="$mnt $rest"
mnt="$timeout"
timeout=""
fi
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 ax|grep "[0-9]:[0-9][0-9] 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 +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
}
|