Skip to content

Fix init-d-script systemd redirection (#826214)

Mert Dirik requested to merge mertdirik-guest/systemd:init-d-script into master

Hi

This branch consists of 2 commits for properly redirecting scripts using /lib/init/init-d-script.

First commit makes use of __init_d_script_name variable set by new init-d-script versions (sysvinit-utils > 2.88dsf-59.11) to properly redirect in both situations where init-d-script is sourced or used as the shebang.

Second commit uses more advanced heuristics and properly redirects in every condition (even when __init_d_script_name is not set in sysvinit-utils < 2.88dsf-59.11).

In the tests I manually conducted I've observed no breakage under both old and new sysvinit-utils versions, with old standalone init scripts or scripts utilizing init-d-script as shebang or simply sources it.

The advantage of the second commit is that redirection works even if __init_d_script_name is not set (in old sysvinit-utils versions). If that commit is applied __init_d_script_name can be dropped from init-d-script (and after that the check for __init_d_script_name can be removed from 40-systemd)

In summary:
Current situation for redirection:
init-d-script \ __init_d_script_name is Set (new version) Not set (old version)
Sourced Works Doesn't work
Shebang Doesn't work Doesn't work
Redirection after first commit:
init-d-script \ __init_d_script_name is Set (new version) Not set (old version)
Sourced Works Doesn't work
Shebang Works Doesn't work
Redirection after second commit:
init-d-script \ __init_d_script_name is Set (new version) Not set (old version)
Sourced Works Works
Shebang Works Works
Edited by Mert Dirik

Merge request reports

Loading