How to start a SysV init script after network starts in Red Hat Enterprise Linux 7
Environment
- Red Hat Enterprise Linux 7
- SysVinit service script
- systemd
Issue
-
systemd includes compatibility for SysVinit service scripts in
/etc/rc.d
but how can you configure dependencies so that a 3rd-party initscript doesn't start until after some other native systemd unit (like networking)? -
We are working on porting our legacy platform from RHEL5 to RHEL7 and we are running into issues where the chkconfig'd sysvinit services are starting before network and NFS which are dependencies. Is there a way to delay sysvinit scripts until systemd init has finished, or even better yet untill a couple of wants are satisfied?
-
I have a legacy SysV init script that needs to start after the network starts in RHEL 7 and I cannot convert the initscript to a systemd service file.
Resolution
-
Put the
Required-Start: $network
directive in the LSB header of the SysVinit script
Use therhnsd
service script as an example:$ awk '/### BEGIN INIT INFO/,/### END INIT INFO/' /etc/init.d/rhnsd ### BEGIN INIT INFO # Provides: rhnsd # Required-Start: $local_fs $network $remote_fs $named $time # Required-Stop: $local_fs $network $remote_fs $named # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Starts the Spacewalk Daemon # Description: This is a daemon which handles the task of connecting # periodically to the Spacewalk servers to # check for updates, notifications and perform system # monitoring tasks according to the service level that # this server is subscribed for. ### END INIT INFO
-
See also:
Root Cause
-
systemd honors the LSB headers in init scripts. It will convert
$network
to the systemd optionAfter=network-online.target
For more information, please see:
Diagnostic Steps
-
Find out what is starting first using provided tools such as:
systemd-analyze plot > analyzestartup.svg
Then analyzestartup.svg with firefox or an image viewer
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments