Debian – confusing behavior of LSB Init Scripts in Debian

debianinit-scriptlsb

I am experiencing strange behavior with LSB Init Scripts in Debian Wheezy. I can demonstrate the problem on following example:

The script /etc/init.d/resolvconf starts in S and stops in runlevels 0 and 6.

# Default-Start:     S
# Default-Stop:      0 6

And indeed, when I use chkconfig resolvconf on to turn the script on, I see that symlinks have been created in respective runlevel directories:

$ ls /etc/rc?.d/*resolvconf
/etc/rc0.d/K02resolvconf
/etc/rc6.d/K02resolvconf
/etc/rcS.d/S13resolvconf

When I turn the script off with chkconfig resolvconf off, the symlinks disappear. So far so good.

Now, I have decided I don't want the script to start in S (I am going to start it manually), but I still want it to stop in runlevels 0 and 6. I change default start accordingly:

# Default-Start:     
# Default-Stop:      0 6

and turn the script on chkconfig resolvconf on. And nothing happens.

$ ls /etc/rc?.d/*resolvconf
ls: cannot access /etc/rc?.d/*resolvconf: No such file or directory

no symlinks have been created, and the script does not stop in runlevels 0 and 6.

What is happening here?

How can I have a script only run (stop) in runlevels 0 and 6, without starting in S ?

UPDATE

as suggested by @Rui F Ribeiro, I have completely removed the # Default-Start: line. Now when I run chkconfig resolvconf on, I get following errors:

insserv: Script resolvconf is broken: incomplete LSB comment.
insserv: missing `Default-Start:'  entry: please add even if empty.
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `resolvconf'

the symlinks are created, though.

$ ls /etc/rc?.d/*resolvconf
/etc/rc0.d/K02resolvconf
/etc/rc6.d/K02resolvconf

But why do I get the errors?

Best Answer

chkconfig only reads the "Default-Start" lines when calculating the runlevels for scripts. It counts the number of runlevels and only calls insserv if at least one runlevel is requested in "Default-Start"...

Workarounds which avoid this behaviour include:

  • enabling services with chkconfig -a;
  • disabling services with chkconfig -d;
  • using insserv directly, insserv service to enable service, insserv -r service to remove it.