Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CentOS init scripts dependencies

Tags:

centos

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?

like image 816
Andrey Minogin Avatar asked Jun 30 '26 10:06

Andrey Minogin


2 Answers

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).

like image 175
viGeek Avatar answered Jul 02 '26 00:07

viGeek


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
like image 25
leon_pro Avatar answered Jul 01 '26 23:07

leon_pro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!