aboutsummaryrefslogtreecommitdiffstats
path: root/samples/rc.autofs
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>1999-03-07 22:37:23 +0000
committerH. Peter Anvin <hpa@zytor.com>1999-03-07 22:37:23 +0000
commit4f18e463590cc3940c82af59ae1e792b3d90f79f (patch)
treee1ff83e429232ec6430320ce7a613ea004cab3e0 /samples/rc.autofs
parent32817e0ee60f6aaaafc1e4e08da377cfde8ff182 (diff)
downloadautofs3-4f18e463590cc3940c82af59ae1e792b3d90f79f.tar.gz
autofs3-4f18e463590cc3940c82af59ae1e792b3d90f79f.tar.xz
autofs3-4f18e463590cc3940c82af59ae1e792b3d90f79f.zip
Make autofs hopefully work on both debian and redhat.
Diffstat (limited to 'samples/rc.autofs')
-rw-r--r--samples/rc.autofs118
1 files changed, 75 insertions, 43 deletions
diff --git a/samples/rc.autofs b/samples/rc.autofs
index 4a6f638..2fc9391 100644
--- a/samples/rc.autofs
+++ b/samples/rc.autofs
@@ -1,43 +1,73 @@
#! /bin/bash
#
-# $Id$
+# $Id$
#
-# 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
+# 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
#
-# On most distributions, this file should be called:
-# /etc/rc.d/init.d/autofs or /etc/init.d/autofs
+# On most distributions, this file should be called:
+# /etc/rc.d/init.d/autofs or /etc/init.d/autofs
#
-# This is used in the Debian distribution to determine the proper
-# location for the S- and K-links to this init file.
-# The following value is extracted by debstd to figure out how to
-# generate the postinst script. Edit the field to change the way the
-# script is registered through update-rc.d (see the manpage for
-# update-rc.d!)
+# This is used in the Debian distribution to determine the proper
+# location for the S- and K-links to this init file.
+# The following value is extracted by debstd to figure out how to
+# generate the postinst script. Edit the field to change the way the
+# script is registered through update-rc.d (see the manpage for
+# update-rc.d!)
#
FLAGS="defaults 21"
-test -f /usr/sbin/automount || exit 0
+#
+# Location of the automount daemon
+#
+DAEMON=/usr/sbin/automount
+
+#
+# Determine which kind of configuration we're using
+#
+system=unknown
+if [ -f /etc/debian_version ]; then
+ system=debian
+ initdir=/etc/init.d
+elif [ -f /etc/redhat-release ]; then
+ system=redhat
+ initdir=/etc/rc.d/init.d
+else
+ echo "$0: Unknown system, please port and contact autofs@linux.kernel.org" 1>&2
+ exit 1
+fi
+
+if [ $system = redhat ]; then
+ . $initdir/functions
+fi
+
+test -e $DAEMON || exit 0
+thisscript="$0"
+if [ ! test -f $thisscript ]; then
+ echo "$0: Cannot find myself" 1>&2
+ exit 1
+fi
+
PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH
#
-# We can add local options here
-# e.g. localoptions='rsize=8192,wsize=8192'
+# We can add local options here
+# e.g. localoptions='rsize=8192,wsize=8192'
#
localoptions=''
#
-# 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
+# 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()
{
#
-# Check for local maps to be loaded
+# Check for local maps to be loaded
#
if [ -f /etc/auto.master ]
then
@@ -50,11 +80,11 @@ then
map=`echo "/etc/$map" | sed -e 's:^/etc//:/:'`
options=`echo "$options" | sed -e 's/\(^\|[ \t]\)-/\1/g'`
if [ -x $map ]; then
- echo "automount $dir program $map $options $localoptions"
+ echo "$DAEMON $dir program $map $options $localoptions"
elif [ -f $map ]; then
- echo "automount $dir file $map $options $localoptions"
+ echo "$DAEMON $dir file $map $options $localoptions"
else
- echo "automount $dir `basename $map` $options $localoptions"
+ echo "$DAEMON $dir `basename $map` $options $localoptions"
fi
fi
done
@@ -62,7 +92,7 @@ then
fi
#
-# Check for YellowPage maps to be loaded
+# Check for YellowPage maps to be loaded
#
if [ -e /usr/bin/ypcat ] && [ `ypcat -k auto.master 2>/dev/null | wc -l` -gt 0 ]
then
@@ -73,8 +103,14 @@ then
-a x`echo "$map" | cut -c1` != 'x-' ]
then
map=`echo "$map" | sed -e 's/^auto_/auto./'`
- options=`echo "$options" | sed -e 's/\(^\|[ \t]\)-/\1/g'`
- echo "automount $dir yp $map $options $localoptions"
+ 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 "$DAEMON $dir yp $map $options $localoptions"
fi
done
)
@@ -82,7 +118,7 @@ fi
}
#
-# Status lister.
+# Status lister.
#
function status()
{
@@ -99,13 +135,13 @@ function status()
#
-# Redhat start/stop function.
+# Redhat start/stop function.
#
function redhat()
{
#
-# See how we were called.
+# See how we were called.
#
case "$1" in
start)
@@ -117,7 +153,7 @@ case "$1" in
fi
;;
stop)
- killall -TERM automount
+ kill -TERM $(/sbin/pidof /usr/sbin/automount)
rm -f /var/lock/subsys/automount
;;
reload|restart)
@@ -126,8 +162,8 @@ case "$1" in
exit 1
fi
echo "Checking for changes to /etc/auto.master ...."
- TMP1=`tempfile`;
- TMP2=`tempfile`;
+ TMP1=`mktemp /tmp/autofs.XXXXXX` || { echo "could not make temp file" >& 2; exit 1; }
+ TMP2=`mktemp /tmp/autofs.XXXXXX` || { echo "could not make temp file" >& 2; exit 1; }
getmounts >$TMP1
ps ax|grep "[0-9]:[0-9][0-9] automount " | (
while read pid tt stat time command; do
@@ -144,27 +180,24 @@ case "$1" in
echo "Start $x"
fi
done )
- rm $TMP1 $TMP2
+ rm -f $TMP1 $TMP2
;;
status)
status
;;
*)
- echo "Usage: /etc/init.d/autofs {start|stop|restart|reload|status}"
+ echo "Usage: $initdir/autofs {start|stop|restart|reload|status}"
exit 1
esac
}
#
-# Debian start/stop functions.
+# Debian start/stop functions.
#
function debian()
{
-
-DAEMON=/usr/sbin/automount
-
#
-# See how we were called.
+# See how we were called.
#
case "$1" in
start)
@@ -207,22 +240,21 @@ case "$1" in
fi
done
rm -f $TMP
- /etc/init.d/autofs start
+ $thisscript start
;;
status)
status
;;
*)
- echo "Usage: /etc/init.d/autofs {start|stop|restart|reload|status}" >&2
+ echo "Usage: $initdir/autofs {start|stop|restart|reload|status}" >&2
exit 1
;;
esac
}
-if [ -f /etc/debian_version ]
-then
+if [ $system = debian ]; then
debian "$@"
-else
+elif [ $system = redhat ]; then
redhat "$@"
fi