On 11/22/18, Ian Jackson <ijack...@chiark.greenend.org.uk> wrote: > Mert Dirik writes ("Bug#913247: Please provide a C implementation of > /lib/init/init-d-script"): >> I noticed the new snippet in the man page of experimental version uses >> the >> #! /usr/bin/env /lib/init/init-d-script >> shebang, which doesn't work with systemd redirection. > > I don't know what `systemd redirection' is. Why does it not work ? > Can it be fixed ? >
To sum it up, when /lib/lsb/init-functions is sourced from a script in /etc/init.d, /lib/lsb/init-functions.d/40-systemd is also sourced and the script is executed using a corresponding "systemctl ...." command so that systemd can track the daemon. Relevant bug report is #826214. The problem here is, 40-systemd uses the value of "$0" to figure out whether the caller was a script inside /etc/init.d/ and using /lib/init/init-d-script breaks that. We partially fixed this in init-d-script so that using the old "set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script" snippet (as it was in the /etc/init.d/skeleton) works correctly, but if /lib/init/init-d-script (or /usr/bin/env) is used as shebang there is no way to fix it inside init-d-script since dash scripts can't change the value of $0. I'm in the process of writing a longer opinion mail on /lib/init/init-d-script but it's not finished yet.