* Re: autofs v4 maintainer request
[not found] ` <1061138039.23980.8.camel@ixodes.goop.org>
@ 2003-08-17 21:26 ` Jochen Reinwand
0 siblings, 0 replies; 2+ messages in thread
From: Jochen Reinwand @ 2003-08-17 21:26 UTC (permalink / raw)
To: Jeremy Fitzhardinge, Ian Kent; +Cc: autofs mailing list
[-- Attachment #1: Type: text/plain, Size: 3158 bytes --]
> > This is on my list. I believe that it can be addressed by bringing the
> > parsing of the master map into the daemon. This will enable a much more
> > generic init script to be written.
>
> The approach I was thinking about was to factor all the init scripts
> into two parts: one set of functions for doing autofs specific things
> (parsing maps, starting and stopping daemons, etc), and a set of
> per-distro scripts which use the autofs functions to do their work. The
> per-distro scripts should have very little real code in them, just
> whatever the distro needs an init script to do.
>
> Why would moving the map parsing into the C code make things more
> generic?
Look at the way Solaris does it. It's somehow nice, because the command
"automount" handles nearly _everything_.
But it's not very flexible. You can only edit auto.master, start automount and
hope that it does exactly what you want.
Therefore I had a different idea some time ago:
Looking at the different init scripts revealed a great problem: The scripts
for the different distros do the same things in different ways!
We have LSB, so why not use it?
So I wrote a common init script I called rc.autofs that does everything, but
leaves out the distro specific stuff, like the output on the screen.
I took all useful things from the different init scripts and implemented a few
new things.
What was important for me: The script uses PID files and waits a few seconds
after "rc.autofs stop" and _very_ important during "rc.autofs restart" after
the stop part for the PID files to disappear to be sure the automount is
really gone. If one or more PID files remain, it prints an error message
telling what mount point is broken or still in use. In the case of "rc.autofs
start" or after the stop part of "rc.autofs restart" the script does _not_
start an already or still running automount!
I attached the rc.autofs script and an example "real" autofs script for SuSE.
It's for an old version (something around 7.x, where init scripts used
rc.config variables), but the basic concept should be clear.
The code is old and I haven't looked at it for a long time. While reading this
thread I decided to share it with you, although there are some problems about
it (see below). I have not cleaned up a lot. Only a few German comments ;-)
So if anyone wants to clean it up or use a few parts for a complete new
version of the script, feel free to use it!
Now to the problems: I made a big mistake! I changed the syntax of auto.master
to the following:
# mount-point map-type map options -- additional options
/mnt file,sun /etc/autofs_mnt nonstrict,nosuid,nodev,sync -- -t1
As you can see I disabled the autodetection of the map type and used the new
second column.
In the docs there was nothing about how to specify a different timeout and
other daemon options for a map. So I made it possible to pass daemon options
after the "--". But as I found out later it is already possible by normal
options...
So if someone wants to use my code, he/she has to take care about it. But it
should be very easy to clean this up!!
regards,
Jochen
[-- Attachment #2: rc.autofs --]
[-- Type: application/x-shellscript, Size: 12858 bytes --]
[-- Attachment #3: autofs.SuSE --]
[-- Type: application/x-shellscript, Size: 2975 bytes --]
[-- Attachment #4: Type: text/plain, Size: 140 bytes --]
_______________________________________________
autofs mailing list
autofs@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/autofs
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: autofs v4 maintainer request
[not found] <Pine.LNX.4.44.0308182102250.977-100000@raven.themaw.net>
@ 2003-08-18 20:26 ` Taylor, ForrestX
0 siblings, 0 replies; 2+ messages in thread
From: Taylor, ForrestX @ 2003-08-18 20:26 UTC (permalink / raw)
To: Ian Kent; +Cc: autofs mailing list
[-- Attachment #1: Type: text/plain, Size: 647 bytes --]
Ian Kent wrote:
> Ignorant of me to ignore existing 4.0.0 users. I appologise.
>
> It's been a long time since I have worked with the original 4.0.0
> distribution so I will need input from people that are using it.
>
> Could everyone post bug reports and send any patches to me. Please
> include some indication of priority such as show stopper, nice to have
> etc. I will attempt to solve the problems and merge any patches.
Here is a patch that I use that contains mostly Red Hat-specific
changes. This includes starting autofs after NIS, and stopping autofs
before NFS, as well as changing the directory to /etc/init.d.
Forrest
--
[-- Attachment #2: autofs.patch --]
[-- Type: text/plain, Size: 6392 bytes --]
diff -urN autofs-4.0.0pre10/autofs.spec autofs-4.0.0pre10.new/autofs.spec
--- autofs-4.0.0pre10/autofs.spec 2001-03-27 21:08:23.000000000 -0800
+++ autofs-4.0.0pre10.new/autofs.spec 2003-08-18 12:54:59.000000000 -0700
@@ -4,6 +4,7 @@
%define version 4.0.0pre10
Version: %{version}
Release: 1
+Epoch: 2
Copyright: GPL
Group: Networking/Daemons
Source: ftp://ftp.kernel.org/pub/linux/daemons/autofs/autofs-%{version}.tar.gz
@@ -49,7 +50,7 @@
%install
rm -rf $RPM_BUILD_ROOT
-mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
+mkdir -p $RPM_BUILD_ROOT/etc/init.d
mkdir -p $RPM_BUILD_ROOT/usr/sbin
mkdir -p $RPM_BUILD_ROOT/usr/lib/autofs
mkdir -p $RPM_BUILD_ROOT/usr/man/man5
@@ -65,16 +66,34 @@
%post
chkconfig --add autofs
+echo "alias autofs autofs4" >> /etc/modules.conf
+AUTOFSMOD=`/sbin/lsmod | grep 'autofs '`
+if [[ $AUTOFSMOD ]];then
+ # XXX We need to rmmod the old autofs, and stop autofs,
+ # but we can't do it here.
+ #rmmod
+ echo
+ echo "Autofs appears to be running. Please stop autofs and rmmod the module."
+ echo "(I.e., /sbin/service autofs stop"
+ echo " /sbin/rmmod autofs"
+ echo " /sbin/service autofs start )"
+ echo
+fi
-%postun
-if [ "$1" = 0 ] ; then
- chkconfig --del autofs
+%preun
+/sbin/service autofs stop
+if [ $1 = 0 ] ; then
+ /sbin/chkconfig --del autofs
+ /sbin/rmmod autofs4
fi
+cp /etc/modules.conf /etc/modules.conf.autofs
+cat /etc/modules.conf | grep -v "alias autofs autofs4" > /etc/modules.conf.new
+mv /etc/modules.conf.new /etc/modules.conf
%files
%defattr(-,root,root)
%doc COPYRIGHT NEWS README TODO
-%config /etc/rc.d/init.d/autofs
+%config /etc/init.d/autofs
%config(missingok) /etc/auto.master
%config(missingok) /etc/auto.misc
%config(missingok) /etc/auto.net
@@ -105,6 +124,14 @@
# RedHat logs:
+* Mon Aug 18 2003 Forrest Taylor <forrestx.taylor@intel.com>
+- Added nonstrict to auto.net
+- Changed start and stop sequence. Autofs needs to start after NIS and stop before NFS.
+- Changed %postun to %preun in the specfile so that /etc/init.d/autofs is still there when trying to chkconfig --del autofs.
+- Changed /etc/rc.d/init.d/ to /etc/init.d/
+- Added Epoch 2 to specfile so that one can upgrade from autofs-3 from Red Hat.
+- Add module alias to /etc/modules.conf
+
* Tue Oct 6 1998 Bill Nottingham <notting@redhat.com>
- fix bash2 breakage in init script
diff -urN autofs-4.0.0pre10/samples/auto.net autofs-4.0.0pre10.new/samples/auto.net
--- autofs-4.0.0pre10/samples/auto.net 2001-03-27 21:08:23.000000000 -0800
+++ autofs-4.0.0pre10.new/samples/auto.net 2003-08-18 10:01:17.000000000 -0700
@@ -9,7 +9,7 @@
# add "nosymlink" here if you want to suppress symlinking local filesystems
# add "nonstrict" to make it OK for some filesystems to not mount
-opts="-fstype=nfs,hard,intr,nodev,nosuid"
+opts="-fstype=nfs,hard,intr,nodev,nosuid,nonstrict"
# Showmount comes in a number of names and varieties. "showmount" is
# typically an older version which accepts the '--no-headers' flag
diff -urN autofs-4.0.0pre10/samples/rc.autofs.in autofs-4.0.0pre10.new/samples/rc.autofs.in
--- autofs-4.0.0pre10/samples/rc.autofs.in 2001-03-27 21:08:23.000000000 -0800
+++ autofs-4.0.0pre10.new/samples/rc.autofs.in 2003-08-18 12:36:46.000000000 -0700
@@ -12,7 +12,7 @@
# For Redhat-ish systems
#
-# chkconfig: 345 15 85
+# chkconfig: 345 61 19
# description: Automounts filesystems on demand
# This is used in the Debian distribution to determine the proper
@@ -28,7 +28,9 @@
# Location of the automount daemon and the init directory
#
DAEMON=@@sbindir@@/automount
+#DAEMON=/usr/sbin/automount
initdir=@@initdir@@
+#initdir=/etc/init.d
#
# Determine which kind of configuration we're using
@@ -61,7 +63,7 @@
# We can add local options here
# e.g. localoptions='rsize=8192,wsize=8192'
#
-localoptions=''
+localoptions='rsize=8192,wsize=8192'
#
# Daemon options
@@ -138,7 +140,7 @@
echo ""
echo "Active Mount Points:"
echo "--------------------"
- ps ax|grep "[0-9]:[0-9][0-9] automount " | (
+ ps ax|grep "[0-9]:[0-9][0-9] $DAEMON " | (
while read pid tt stat time command; do echo $command; done
)
}
@@ -167,66 +169,80 @@
#
# See how we were called.
#
-case "$1" in
- start)
+ start() {
# Check if the automounter is already running?
if [ ! -f /var/lock/subsys/autofs ]; then
echo 'Starting automounter: '
getmounts | sh
touch /var/lock/subsys/autofs
fi
- ;;
- stop)
+ }
+ stop() {
pids=$(/sbin/pidof $DAEMON)
kill -TERM $pids 2> /dev/null && sleep 1
count=1
while alive $pids; do
- sleep 5
+ sleep 2
count=$(expr $count + 1)
- if [ $count -gt 5 ]; then
+ if [ $count -gt 10 ]; then
echo "Giving up on automounter"
break;
fi
echo "Automounter not stopped yet: retrying... (attempt $count)"
done
- if [ $count -gt 1 -a $count -le 10 ]; then
+ if [ $count -ge 1 -a $count -le 10 ]; then
echo "Automounter stopped"
fi
rm -f /var/lock/subsys/autofs
- ;;
- reload|restart)
+ }
+ condrestart() {
if [ ! -f /var/lock/subsys/autofs ]; then
echo "Automounter not running"
exit 1
fi
echo "Checking for changes to /etc/auto.master ...."
+ echo
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] $DAEMON " | (
+ ps ax --sort=-pid|grep "[0-9]:[0-9][0-9] $DAEMON " | (
while read pid tt stat time command; do
echo "$command" >>$TMP2
- if ! grep -q "^$command" $TMP2; then
- while kill -USR2 $pid; do
- sleep 3
- done
- echo "Stop $command"
+ if grep -q "^$command" $TMP2; then
+ kill -USR2 $pid
+ sleep 1
+ echo "Stopping $command"
fi
done
+ echo
)
( while read x; do
if ! grep -q "^$x" $TMP2; then
$x
- echo "Start $x"
+ echo "Starting $x"
fi
- done ) < $TMP1
+ done ) < $TMP1
rm -f $TMP1 $TMP2
+ }
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ condrestart|reload)
+ condrestart
;;
status)
- status
+ status $DAEMON
;;
*)
- echo "Usage: $initdir/autofs {start|stop|restart|reload|status}"
+ echo "Usage: $initdir/autofs {start|stop|restart|reload|condrestart|status}"
exit 1
esac
}
@@ -289,4 +305,4 @@
redhat "$@"
fi
-exit 0
+exit $?
[-- Attachment #3: Type: text/plain, Size: 140 bytes --]
_______________________________________________
autofs mailing list
autofs@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/autofs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-08-18 20:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <Pine.LNX.4.44.0308182102250.977-100000@raven.themaw.net>
2003-08-18 20:26 ` autofs v4 maintainer request Taylor, ForrestX
[not found] <Pine.LNX.4.44.0308161741530.1538-100000@raven.themaw.net>
[not found] ` <1061138039.23980.8.camel@ixodes.goop.org>
2003-08-17 21:26 ` Jochen Reinwand
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.