1
diff -ruN -x Makefile.in -x configure autofs-4.0.0pre10.orig/samples/rc.autofs.in autofs-4.0.0pre10/samples/rc.autofs.in
2
--- autofs-4.0.0pre10.orig/samples/rc.autofs.in Tue Mar 27 23:08:23 2001
3
+++ autofs-4.0.0pre10/samples/rc.autofs.in Tue Oct 16 11:23:57 2001
9
-# Check for local maps to be loaded
11
-if [ -f /etc/auto.master ]
13
- cat /etc/auto.master | sed -e '/^#/d' -e '/^$/d'| (
14
- while read dir map options
16
- if [ ! -z "$dir" -a ! -z "$map" \
17
- -a x`echo "$map" | cut -c1` != 'x-' ]
19
- map=`echo "/etc/$map" | sed -e 's:^/etc//:/:'`
20
- options=`echo "$options" | sed -e 's/\(^\|[ \t]\)-/\1/g'`
21
- if [ -x $map ]; then
22
- echo "$DAEMON $daemonoptions $dir program $map $options $localoptions"
23
- elif [ -f $map ]; then
24
- echo "$DAEMON $daemonoptions $dir file $map $options $localoptions"
26
- echo "$DAEMON $daemonoptions $dir `basename $map` $options $localoptions"
28
+ if ! getmounts_file /etc/auto.master; then
29
+ if ! getnismounts auto.master; then
30
+ echo "no autofs mounts configured!" 1>&2
35
+function getmounts_file()
38
+ # Check for local maps to be loaded
44
+ cat "$map" | sed -e '/^#/d' -e '/^$/d' | process_master_file "$@"
50
+function process_master_file()
52
+ local line_options="$@" daemon_options
53
+ while read dir map options
55
+ options="$line_options $options"
57
+ +*) getnismounts "${dir/+/}" $map $options
60
+ if [ ! -z "$dir" -a ! -z "$map" \
61
+ -a x`echo "$map" | cut -c1` != 'x-' ]
64
+ if [ -x $map ]; then
66
+ elif [ -f $map ]; then
68
+ elif [ x`echo "$map" | cut -c1` == 'x/' ]; then
69
+ # Starts with '/', thus a file, but doesn't exist
70
+ # so leave it out, leaving 'type=""' (hro)
72
+ elif [ -f /etc/$map ]; then
75
+ elif [ $map == hesiod ]; then
78
+ elif [ $map == ldap ]; then
83
+ !*) type=program map="${map/!/}";;
90
+ daemon_options=`munge_options daemon $daemonoptions $options`
91
+ options=`munge_options mount $options`
93
+ if [ "$type" ]; then
94
+ echo "$DAEMON $daemon_options -- $dir $type $map $localoptions $options"
100
+function getnismounts()
103
+ # Check for YellowPage maps to be loaded
107
+ if [ -e /usr/bin/ypcat ] && [ `ypcat -k "$map" 2>/dev/null | wc -l` -gt 0 ]
109
+ ypcat -k "$map" | process_master_file "$@"
116
-# Check for YellowPage maps to be loaded
117
+# List active mounts
119
-if [ -e /usr/bin/ypcat ] && [ `ypcat -k auto.master 2>/dev/null | wc -l` -gt 0 ]
121
- ypcat -k auto.master | (
122
- while read dir map options
125
+ ps ax|grep "[0-9]:[0-9][0-9] $DAEMON " |
126
+ while read pid tt stat time command
128
- if [ ! -z "$dir" -a ! -z "$map" \
129
- -a x`echo "$map" | cut -c1` != 'x-' ]
131
- map=`echo "$map" | sed -e 's/^auto_/auto./'`
132
- if echo $options | grep -- '-t' >/dev/null 2>&1 ; then
133
- mountoptions="--timeout $(echo $options | \
134
- sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')"
136
- options=`echo "$options" | sed -e '
137
- s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g
138
- s/\(^\|[ \t]\)-/\1/g'`
139
- echo "$DAEMON $daemonoptions $mountoptions $dir yp $map $options $localoptions"
148
@@ -134,13 +179,49 @@
150
echo "Configured Mount Points:"
151
echo "------------------------"
153
+ getmounts | sed 's/ -- / /'
155
echo "Active Mount Points:"
156
echo "--------------------"
157
- ps ax|grep "[0-9]:[0-9][0-9] automount " | (
158
- while read pid tt stat time command; do echo $command; done
163
+function munge_options()
167
+ echo "$@" | awk -v which="$which" '
171
+ daemon_opts[ "timeout" ] = "timeout"
172
+ daemon_opts[ "t" ] = "timeout"
177
+ if ( $1 in daemon_opts ) {
178
+ daemon[ daemon_opts[ $1 ] ] = $2
184
+ if ( which ~ "^daemon$" ) {
185
+ if ( "timeout" in daemon ) {
186
+ printf "--timeout=%s\n", daemon["timeout"]
189
+ for ( a in mount ) {
190
+ if ( length( out ) )
201
# return true if at least one pid is alive
203
# Check if the automounter is already running?
204
if [ ! -f /var/lock/subsys/autofs ]; then
205
echo 'Starting automounter: '
207
+ getmounts | sed 's/ -- / /' | sh
208
touch /var/lock/subsys/autofs
213
echo "Automounter not stopped yet: retrying... (attempt $count)"
215
- if [ $count -gt 1 -a $count -le 10 ]; then
216
+ if [ $count -gt 1 -a $count -le 5 ]; then
217
echo "Automounter stopped"
219
rm -f /var/lock/subsys/autofs
220
@@ -202,13 +283,13 @@
221
echo "Checking for changes to /etc/auto.master ...."
222
TMP1=`mktemp /tmp/autofs.XXXXXX` || { echo "could not make temp file" >& 2; exit 1; }
223
TMP2=`mktemp /tmp/autofs.XXXXXX` || { echo "could not make temp file" >& 2; exit 1; }
225
+ getmounts | sed 's/ -- / /' >$TMP1
226
ps ax|grep "[0-9]:[0-9][0-9] $DAEMON " | (
227
while read pid tt stat time command; do
228
echo "$command" >>$TMP2
229
if ! grep -q "^$command" $TMP2; then
230
while kill -USR2 $pid; do
248
- echo "Usage: $initdir/autofs {start|stop|restart|reload|status}"
249
+ echo "Usage: $initdir/autofs {start|stop|restart|reload|status|getmounts|active}"
253
@@ -241,25 +329,48 @@
257
- echo -n 'Starting automounter:'
258
+ echo -n 'Starting automounter: '
259
- getmounts | while read cmd mnt rest
260
+ getmounts | while read cmd args
267
- pidfile=/var/run/autofs`echo $mnt | sed 's/\//./'`.pid
268
+ if [ ! -d /var/run/autofs ]; then
269
+ mkdir /var/run/autofs
271
+ pidfile=/var/run/autofs/`echo $mnt | sed 's,_,__,g;s,/,_:,g'`.pid
272
start-stop-daemon --start --pidfile $pidfile --quiet \
273
- --exec $DAEMON $daemonoptions -- $mnt $rest
274
+ --exec $DAEMON -- $opt $mnt $rest
280
- echo 'Stopping automounter.'
281
+ echo -n 'Stopping automounter: '
282
start-stop-daemon --stop --quiet --signal USR2 --exec $DAEMON
283
+ for file in /var/run/autofs/*.pid
287
+ pid=`head -n 1 $file`
288
+ command=`tail -n 1 $file`
289
+ if [ -z "`ps --no-heading $pid`" ]
291
+ echo -n "Stopped $pid($command) "
294
+ echo -n "Couldn't stop $pid($command) "
302
- echo "Reloading automounter: checking for changes ... "
303
+ echo -n "Reloading automounter: checking for changes ... "
304
TMP=/var/run/autofs.tmp
306
- for i in /var/run/autofs.*.pid
307
+ getmounts | sed 's/ -- / /' >$TMP
308
+ for i in /var/run/autofs/*.pid
310
pid=`head -n 1 $i 2>/dev/null`
311
[ "$pid" = "" ] && continue
312
@@ -268,16 +378,28 @@
314
- echo "Stopping automounter: $command"
315
+ echo -n "Stopping automounter: $command"
324
+ force-reload|restart)
332
+ getmounts | sed 's/ -- / /'
338
- echo "Usage: $initdir/autofs {start|stop|restart|reload|status}" >&2
339
+ echo "Usage: $initdir/autofs {start|stop|restart|reload|force-reload|status|getmounts|active}" >&2