3

I'm working on some lsb init scripts. Here's the init info from one of them:

### BEGIN INIT INFO
# Provides:     myscript
# Required-Start:   networking myotherscript
# Required-Stop:    networking myotherscript
# Default-Start:    2 3 4 5
# Default-Stop:     0 1 6
# Short-Description:    Starts my daemon
### END INIT INFO

And the init info from myotherscript

### BEGIN INIT INFO
# Provides:     myotherscript
# Required-Start:   networking
# Required-Stop:    networking
# Default-Start:    2 3 4 5
# Default-Stop:     0 1 6
# Short-Description:    Starts my other daemon
### END INIT INFO

If I understand correctly, running service myscript start should not work unless myotherscript is running. However, executing service myscript start does indeed work.

Why don't I at least get an error about the unmet dependency?

1
  • I'm probably incorrect but have you checked to see if the dependency relationship only affects what number chkconfig gives the script's symlink when you enable it? As in does that just tell chkconfig to make sure myotherscript has a lower number than myscript ? – Bratchley Aug 15 '14 at 21:12
1

The service command doesn't do much more than run the init script with the provided argument. In particular, it doesn't take care of dependencies.

On Fedora/RHEL/CentOS and on Debian/Ubuntu/Mint (and probably others), the dependencies recorded in comments are only taken into account by the service script management utility chkconfig. They are not taken into account if you invoke a script directly, the idea being that if you're doing that, you're intervening directly and want fine control over what services you're manipulating (for example, you may be running a locally-installed version of a dependency, or you may be running it in a different guest in a virtualized environment). This is compliant with the LSB which only specifies the interface between applications and distributions, not between distributions and administrators.

A lack of built-in support for dependencies is one of the defects of SysVinit, which is slowly being phased out in favor of Systemd.

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.