[kwlug-disc] somwehat confused about K* and S* /etc/init.d scripts in SuSE

Robert P. J. Day rpjday at crashcourse.ca
Sat Sep 26 06:23:26 EDT 2009


  i'm reading someone else's courseware manual for SuSE 11, and the
discussion of how the start and kill scripts are invoked to change
runlevels just seems ... weird.

  i've always believed that, for any single runlevel:

  * the "K" scripts for that runlevel represent things to be killed
upon entering that runlevel

  * the "S" scripts for that runlevel represent things to be started,
*also* upon entering that runlevel

  in other words, a single runlevel directory (say /etc/init/rc5.d)
completely defines what should and should not be running in that
runlevel, based solely on its contents.

  but the manual i'm reading claims:

"When the runlevel is changed, init calls the rc script with the new
runlevel as parameter (such as /etc/init.d/rc 3). The /etc/init.d/rc
script examines the /etc/init.d/ rccurrentrl.d/ and
/etc/init.d/rcnewrl.d/ directories and determines what to do.

For example, suppose you change from runlevel 5 to runlevel 3. There
are three possible scenarios that could occur as a result:

1)  There is a Kxx link for a certain service in /etc/init.d/rc5.d/
and there is an Sxx link in /etc/init.d/rc3.d/ for the same service.
In this case, the service is neither started nor stopped because the
service should run in both runlevels. Therefore, the service’s script
in /etc/init.d/ is not called at all.

2)  There is a Kxx link for a certain service in /etc/init.d/rc5.d/,
but there is no corresponding Sxx link in /etc/init.d/rc3.d/. In this
case, the script in /etc/init.d/service is called with the stop
parameter and the service is stopped.

3)  There is an Sxx link in /etc/init.d/rc3.d/ and there is no
corresponding Kxx link for the service in /etc/init.d/rc5.d/. In this
case, the script in /etc/init.d/service is called with the start
parameter and the service is started."


  again, that seems weird, in that you end up consulting the K
scripts of the runlevel you're *leaving*?  and i notice that, in both
/of /etc/init.d/rc[35].d directories, there exist both scripts K01sshd
and S08sshd.  start and kill scripts for the same service in the same
runlevel directory?

  does SuSE just do things that differently from, say, fedora?  or
have i misuderstood how this works all this time?

rday

p.s.  as another bit of weirdness, point 1) suggests that, if there's
a K script for the runlevel you're leaving, but an S script for the
runlevel you're entering, then you don't have to do anything with that
service.  but what if you've *manually* stopped that service, then
change runlevels?  since the above algorithm bases its decision
strictly on whether the symlink exists, that service won't be
restarted upon changing runlevels since no test is made as to whether
that service is still running.

  i've never seen this particular explanation before, and it flies in
the face of everything i thought i knew.

--

========================================================================
Robert P. J. Day                               Waterloo, Ontario, CANADA

        Linux Consulting, Training and Annoying Kernel Pedantry.

Web page:                                          http://crashcourse.ca
Twitter:                                       http://twitter.com/rpjday
========================================================================


More information about the kwlug-disc mailing list