3

I just moved to debian squeeze and need to change the startup sequence of some scripts. I used to do this with update-rc.d service defaulta xx xx but now with the LSB way of doing things the update-rc.d method does not change the order.

I need to start the packages in this order:

  • openvpn
  • ndo2db
  • nagios
  • apache2

Any ideas?

Ricardo Marimon
  • 529
  • 4
  • 11
  • 26

2 Answers2

4

Just use Required-Start keyword. For e.g, init script for ndo2db should have the following:

### BEGIN INIT INFO
# Provides:          ndo2db
# Required-Start:    $openvpn
# Required-Stop:     $openvpn
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Daemonized ndo2db
# Description:       Starts the ndo2db daemon
### END INIT INFO

Take a look at this for more details.

quanta
  • 50,327
  • 19
  • 152
  • 213
  • What does one invoke to update the rcN.d-symlinks with the new values, though? – Kvisle Oct 21 '11 at 05:05
  • How about `dpkg-reconfigure insserv sysv-rc`: http://wiki.debian.org/LSBInitScripts/DependencyBasedBoot – quanta Oct 21 '11 at 05:12
  • What about having apache2 load after openvpn. I'm not sure that changing lsb scrpits for apache2 is a solution. – Ricardo Marimon Oct 21 '11 at 05:29
  • 1
    There's nothing wrong with patching the init-scripts. It's like any other configuration file - you need to pay attention when you upgrade to a newer version, and apt will present you with a diff (because it detects that you've edited the file). The same would apply if you were using upstart, and patching the upstart-configfiles. – Kvisle Oct 21 '11 at 06:16
  • I always thought that patching the init-scripts was a no-no. Particularly in trying to keep maintainability going forward. This is perhaps one of the reasons for having `/etc/default/*`. Perhaps there is something similar for lsb scripts? – Ricardo Marimon Oct 22 '11 at 00:15
  • it should just be `openvpn`, without the `$`, btw – Karalga May 12 '15 at 17:36
1

Once you edit the Required-Start lines (and Required-Stop lines) in the appropriate files in your init.d directory, perform the following commands for each of the services you'd like reordered:

chkconfig --del servicename

chkconfig --add servicename

Once you do this, the init scripts will be reordered in your rc#.d directories.