[Pkg-sysvinit-devel] Bug#826214: SysV init scripts using init-d-script are not properly redirected to systemctl
Mert Dirik
mertdirik at gmail.com
Wed Jan 10 22:38:00 UTC 2018
On Wed, 10 Jan 2018 22:49:17 +0300 Mert Dirik <mertdirik at gmail.com> wrote:
> On 01/10/18 21:20, Petter Reinholdtsen wrote:
> > [Mert Dirik]
> >> Please forgive my naivety, but simply moving the argument shift
part before
> >> sourcing /lib/lsb/init-functions seems to successfully redirect to
> >> systemctl.
> > Interesting. This seem like a very good idea. :)
> I'm happy to hear that.
> >
> >> The only variable leaking to /lib/lsb/init-functions is "script",
which can be
> >> easily renamed and namespaced in case of a possible problem.
> > Perhaps good to give it some init-d-script related prefix, to
reduce the
> > chance of a future collision?
> Maybe "__init_d_script_path"?
> >
> >> Is there anything wrong with this approach?
> > Nothing I could think of from the top of my head. :)
> >
> Great :) I'll test it again in stretch or sid and I'll post the result
> here. (previous test was done in jessie)
>
I've tested the attached patch in a sid lxc container and the issue
seems to be fixed there.
Here is a relevant output:
> root at sid:~# cat /etc/init.d/sleep-daemon
> #!/bin/sh
> # kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and
> sourcing.
> if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
> set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
> fi
> ### BEGIN INIT INFO
> # Provides: sleep-daemon
> # Required-Start: $remote_fs $syslog
> # Required-Stop: $remote_fs $syslog
> # Default-Start: 2 3 4 5
> # Default-Stop: 0 1 6
> # Short-Description: Sleep daemon
> # Description: Sleep daemon
> ### END INIT INFO
>
> # Author: Foo Bar <foobar at baz.org>
>
> DESC="Sleep daemon"
> DAEMON=/bin/sleep
> DAEMON_ARGS=120
> START_ARGS="--background --make-pidfile"
>
> root at sid:~# /etc/init.d/sleep-daemon start
> [ ok ] Starting sleep-daemon (via systemctl): sleep-daemon.service.
> root at sid:~# systemctl status sleep-daemon | cat
> ● sleep-daemon.service - LSB: Sleep daemon
> Loaded: loaded (/etc/init.d/sleep-daemon; generated; vendor preset:
> enabled)
> Active: active (running) since Wed 2018-01-10 22:35:58 UTC; 2s ago
> Docs: man:systemd-sysv-generator(8)
> Process: 1467 ExecStop=/etc/init.d/sleep-daemon stop (code=exited,
> status=0/SUCCESS)
> Process: 1513 ExecStart=/etc/init.d/sleep-daemon start (code=exited,
> status=0/SUCCESS)
> Tasks: 1 (limit: 4915)
> CGroup: /lxc/sid/system.slice/sleep-daemon.service
> └─1529 /bin/sleep 120
>
> Jan 10 22:35:58 sid systemd[1]: Starting LSB: Sleep daemon...
> Jan 10 22:35:58 sid systemd[1]: Started LSB: Sleep daemon.
> root at sid:~#
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 826214.patch
Type: text/x-patch
Size: 829 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-sysvinit-devel/attachments/20180111/e8b77479/attachment.bin>
More information about the Pkg-sysvinit-devel
mailing list