3

Some of the services on my Raspberry Pi (~ Debian) depend on the availability of Internet (especially ntpd, for cryptic reasons). Specifically, the availability of a network device or a link being up is not enough.

When looking at /etc/init.d/ntp I see

### BEGIN INIT INFO
# Provides:        ntp
# Required-Start:  $network $remote_fs $syslog
# Required-Stop:   $network $remote_fs $syslog
# Default-Start:   2 3 4 5
# Default-Stop:
# Short-Description: Start NTP daemon
### END INIT INFO

which I believe means that ntp depends on $network to be able to start. I found a reference in /etc/insserv.conf but it does not say much about what is actually required to set it up:

#
# Low level networking (ethernet card)
#
$network        +networking +ifupdown

Q1: How exactly is $network defined via the +networking +ifupdown elements? (so that I can modify it and try to reach an actual host before declaring the network as 'up')

Q2: If the network prerequisite is not met will the ntp start be delayed or will it fail?

WoJ
  • 1,545

1 Answers1

3

Where is $network defined?

This is a good question, and I've generalized it here.

How exactly is $network defined via the +networking +ifupdown elements?

AFAICT it isn't defined by that, it defines what services must (optionally) also declare any dependencies the facility has (?? -- see the question I posted and linked above). From man insserv:

insserv scans for System Facilities in the configuration file /etc/insserv.conf [...] All names followed by such a system facility will declare the required dependencies of the facility. [...] Names starting with a `+' sign are marked as optional.

And in fact on raspbian /etc/init.d/networking (which is started through /etc/rcS.d, which runs at boot regardless of runlevel) does not include $network as a prereq, although some other services (such as ntp) do.

Q2: If the network prerequisite is not met will the ntp start be delayed or will it fail?

Those prereqs (and other stuff in the INIT INFO block) are only used to set up and configure the script links in the /etc/rcN.d directories, e.g., when you run update-rc.d (which is a front end for insserv). In other words, they aren't used during the actual execution. So, if S02ntp is in your default runlevel, it will be run no matter what during boot (excepting some previous fatal error).

goldilocks
  • 87,661
  • 30
  • 204
  • 262
  • Thank you - the last part is particularly useful. I was not aware that this information is used only when planting the script and not during actual execution. I will write a brand new question then (about how to delay a startup script). – WoJ Apr 09 '14 at 11:08