job-mode=ignore-dependencies, as currently used in the LSB hook during
bootup and shutdown, can have undesired side-effects, like changing the
ordering of services and ultimately causing them to fail, due to unmet
dependencies.
So simplify that, and only apply --no-block on reload requests during
bootup and shutdown.
Closes: #960594
Improve heuristics for scripts run via init-d-script so that
the redirection works even for older init-d-script versions
without the __init_d_script_name variable.
systemctl daemon-reload is a quite a heavy operation, it will re-parse
all configuration and re-run all generators. This should only be done
when strictly needed.
The init-function helpers try to cope with an lsb init script being
called *before* the sysv generator has run. Unfortunately that always got
triggered when other script sourced the helpers as there won't be a
service matching them.
Resolve this by only potentially reloading the daemon when preparing to
redirect.
Closes: #861158
Rename _SYSTEMCTL_SKIP_REDIRECT to SYSTEMCTL_SKIP_REDIRECT to be more
consistent with other environment variables which are used internally by
systemd, like SYSTEMCTL_SKIP_SYSV.
It seems we don't actually need it to detect recursive loops (PPID is
sufficient) and by exporting it we leak _SYSTEMCTL_SKIP_REDIRECT into
the runtime environment of the service.
Closes: #802018
Since upstream commit e33a06a1 "systemctl show" fails for nonexisting units
instead of succeeding with "not-found". Make the code compatible to both for
now.
This will run systemd-sysv-generator, so SysV init scripts that aren't
installed by the package manager should be picked up automatically.
Closes: #825913
When a service is masked the native service does not support
reload, so the lsb hooks would then allow fallback on init script
reload function.
Move the check for masked services earlier and bail out with exit 0
so that does not happen.
(Still a bit confusing that there's no output at all to inform
the user calling the init script for a masked service about this,
but I've been told it's on purpose eg. to avoid spamming the logs.)
Closes: #804882
DHCP/ifupdown and similar hooks which call "/etc/init.d/foo reload" can easily
cause deadlocks, since the synchronous wait plus systemd's normal behaviour of
transactionally processing all dependencies first easily causes dependency
loops. Thus during boot/shutdown operate only on the unit and not on its
dependencies, just like SysV behaves.
Closes: #777115
LP: #1417010