2

I have a SysV init script on Fedora 18. Fedora 18 uses systemd (and apparently, there is no way to switch back to SysV).

My script requires the network to be ready. Currently, at the time the script runs, the network is not ready. How can I make sure that my SysV init script runs after the network is up?

The beginning of my script looks like this:

   #!/bin/bash
   #
   # chkconfig: 345 99 01
   # description: starts the xyz boot service

2 Answers 2

1

OK, after trying several things, I tried adding an LSB header:

### BEGIN INIT INFO
# Required-Start: $network $local_fs $named
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: Starts/stops the foo service
# Description: Starts/stops the foo service
### END INIT INFO

This worked! The script now runs after the network is initialized. I guess the systemd implementation reads the LSB header.

1
  • 1
    According Running Services After the Network is up from the systemd documentation, $network from LSB header is translated into the network-online target both for the After and Wants directive of your unit.
    – Dereckson
    Nov 5, 2014 at 23:02
0

To run a script when the network is ready, in the [Unit] section of your systemd service file, add the following:

After=network-online.target
Wants=network-online.target

The network is defined as ready when the network management software considers the network is up (that generally means a IP address is configured and routable). For NetWorkManager, it queries dbus to get the information..

References

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.