Linux – rc scripts dependencies

bootlinuxUbuntu

On a Ubuntu 10.04.1 LTS server install certain services fail to start properly after a reboot.

I have a couple of virtual interfaces defined on eth0:

/etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
    address 172.16.5.240
    netmask 255.255.255.0
    gateway 172.16.5.1

auto eth0:1
iface eth0:1 inet static
    address 172.16.5.241
    netmask 255.255.255.0
    gateway 172.16.5.1

auto eth0:2
iface eth0:2 inet static
    address 172.16.5.242
    netmask 255.255.255.0
    gateway 172.16.5.1

auto eth0:3
iface eth0:3 inet static
    address 172.16.5.243
    netmask 255.255.255.0
    gateway 172.16.5.1

and so on…

Some SysV init scripts that try to bind to for example 172.16.5.243 fail during boot, complaining that there is no such IP address.

My questions:

1) Are the services started parallel by default? Can I disable that so they run sequentially?

2) Is there a way to define dependencies between rc scripts? I'm only familiar with the defining the order of seqentially started scripts using the numbers in /etc/rc[0-6].d/)

Any other fix or workaround appreciated.

Best Answer

There is no clear answer to your question. It depends whether the service which needs 172.16.5.243 is a SysV init script or a upstart job.

When it is a SysV init script, you can add dependencies with this header in the init script:

### BEGIN INIT INFO
# Provides:          scriptname
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

When it is an Upstart script, take a look at this post. The interesting part is in the accepted answer:

start on (local-filesystems and net-device-up IFACE=eth0)