> > 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: rc.autofs
Description: application/shellscript

Attachment: autofs.SuSE
Description: application/shellscript

_______________________________________________
autofs mailing list
[EMAIL PROTECTED]
http://linux.kernel.org/mailman/listinfo/autofs

Reply via email to