How do I specify dependencies between init scripts on CentOS?
E.g. I need that when service "tomcat" is started it first start service "soffice".
On Gentoo we can do:
depend() {
need soffice
}
But what about CentOS?
CentOS out of the box uses an integer to specify the start/stop.
If you look inside an init script you'll most likely see: chkconfig: - 85 15
First number: start priority (higher = lower priority)
Second: Stop priority (lower = lower priority)
If you hop into /etc/rc3.d (or depending on run level).
Files start with either an S (start) or a K (kill, stop) followed by an integer. Same concept applies in regards to numerics.
In some cases you'll see: chkconfig: - 2345 85 15
To change order, simply adjust those numbers.
This simply represents the run levels (2,3,4,5).
There's a section in init script:
### BEGIN INIT INFO
....
### END INIT INFO
Probably you'll need something like this:
### BEGIN INIT INFO
# Provides: tomcat
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 3 4 5
# Default-Stop: 0 1 6
# X-Start-Before: soffice
# Short-Description: xxxx
# Description: xxxx
### END INIT INFO
More info: https://wiki.debian.org/LSBInitScripts
After modifying this section you should disable and then enable tomcat service again:
chkconfig --del tomcat
chkconfig --add tomcat
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With