6

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?

  • 1
    When there is no start, chkconfig knows that it haven't to be stopped. Create them if you want! ln -s /etc/init.d/resolvconf /etc/rc6.d/K02resolvconf && ln -s /etc/init.d/resolvconf /etc/rc0.d/K02resolvconf – Ipor Sircer Sep 13 '16 at 14:33
  • 1
    @Rui F Ribeiro - I have updated my original question. – Martin Vegter Sep 13 '16 at 14:35
  • 2
    The messages come from insserv; in Debian, chkconfig is just a front-end to that. In LSB, "Default-Start" is required, so the messages are correct; what isn't is the behaviour with an empty "Default-Start" (your first test). Could you run insserv -v resolvconf (with the empty "Default-Start" line in the script)? That should give you more information about what's going on... – Stephen Kitt Sep 13 '16 at 14:57
  • @Stephen Kitt - insserv -v resolvconf works without any problems. – Martin Vegter Sep 13 '16 at 15:42
4

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.