Re: sysvinit: rc vs. r2d2 bahavior
In article <cistron.19981230123040.O19769@spinnaker.rhein.de>,
Roland Rosenfeld <roland@spinnaker.rhein.de> wrote:
>The policy tells us:
>
> When `init' changes runlevel first the targets of the links whose
> names starting with a `K' are executed, each with the single
> argument `stop', followed by the scripts prefixed with an `S',
> each with the single argument `start'.
Yes, that is correct. That is the short description.
>But this is what rc from sysvinit (and hopefully the rc from your
>newly patched file-rc, too) does:
>
> 1. Run all K??-scripts in the new runlevel with the parameter "stop"
> except when starting up (prevlevel==N).
Ofcourse when prevlevel == N the K scripts do not get run - but that
is not obvious from the policy document. I does make a lot of sense.
> 2. Run all S??-scripts in the new runlevel which are not in
> prevlevel as S??-scripts or which are also K??-scripts in the new
> runlevel.
This is merely an optimization. When you go from runlevel 2 to runlevel 3,
and the squid proxy runs in both levels, you don't want to have it
stopped and started again ..
> When going to runlevel 0 or 6, use parameter "stop"
> otherwise "start".
This doesn't make much sense, and I have been critisized for implementing it
this way.
The thing was, I needed a way to run "stop" scripts for the halt/reboot
procedures AFTER /etc/rc6.d/K99xxxxx. Since most of those scripts
didn't look at $1 after all, I just used /etc/rc6.d/SXXxxxx. Then some
scripts appeared that did look at $1. Now the easiest and most compatible
way to fix this was to just say "OK, Sxx scripts in runlevel 0 and 6
are called with the "stop" argument".
>I cannot find anything about the "prevelvel" exception in the policy
That should really be in there.
>and I didn't find a word about running all scripts with parameter
>"stop" when going to runlevel 0 or 6 there.
If we decide we do not want to do that, we should allow runlevel 0 and
6 to have K scripts with numbers > 99. Say K100 .. K199 or so. Then
migrate the Sxx scripts to K1xx.
Not in "slink" though, since all packages that install links in
/etc/rc{0.6}.d/Sxx should be updated at the same time and their postinst
should move the Sxx link to K1xx etc etc.
>b) the one implemented in sysvinit rc: this gets rid of the multiple
> running with "start" by checking the previous level. But this is
> only implemented for "start" not for "stop" (why?)
If there is a K link present, the script will be stopped. If there also
is a S link present, it will be started _again_. This is intentional -
if the maintainer of the package doesn't want the package to be stopped
and started, he/she can just not install the K link. In fact the K
link is not installed in runlevels 2, 3, 4 and 5 by default by update-rc.d
So it is the other way around - see it as a facility a package can
use to have the daemon or whatever stop and restart on a runlevel change.
> and then there's
> the additional rule for changing the parameter to "stop" when going
> to runlevel 0 or 6 (which seems to be a bug for me, because when I
> want "stop" as the parameter I will name the link K?? instead of
> S??).
As I said, the problem was that I needed to add a bunch of scripts
after K99, and levels > K99 weren't defined nor supported by update-rc.d.
I didn't feel like fixing update-rc.d and doing an NMU for dpkg at the
time, because dpkg is a package I rather not fool around with.
>c) the one implemented in r2d2: this is completely logical, but quite
> different from the above ones. It's only fault seems to be, that it
> came too late...
Also, running the K scripts in reverse order is logical but incompatible
with any package out there that depends on the order it's stop script(s)
is/are run in. And it's incompatible with most other Unices.
>As you can see b) doesn't implement a). So where's the argument that
>doesn't allow me to replace b) by c), which also doesn't implement a)?
b) is the defacto standard. a) is an attempt to describe it.
You need to follow b) and/or fix a) (and perhaps even fix b) if needed).
Mike.
--
Indifference will certainly be the downfall of mankind, but who cares?
Reply to: