Bug#734848: [Pkg-systemd-maintainers] Bug#734848: systemd: LSB initscript wrappers should also handle sockets on start/stop

Michael Stapelberg stapelberg at debian.org
Sat May 31 14:43:30 BST 2014


Hi Apollon,

Thanks for providing a patch.

Apollon Oikonomopoulos <apoikos at gmail.com> writes:
> diff --git a/debian/init-functions.d/40-systemd b/debian/init-functions.d/40-systemd
> index a213afc..e494ac2 100644
> --- a/debian/init-functions.d/40-systemd
> +++ b/debian/init-functions.d/40-systemd
> @@ -40,6 +40,7 @@ systemctl_redirect () {
>      local rc
>      local prog=${1##*/}
>      local command=$2
> +    local sockets=""
I think this should not only be limited to sockets, but to any
triggering unit. As an example, cups.service is triggered by cups.path
and cups.socket.

> +    # We also start/stop the associated sockets (if any), so that
> +    # "/etc/init.d/foo stop" permanently stops the service.
> +    if [ "$command" = start -o "$command" = stop ]; then
> +        for socket in $(systemctl list-unit-files --full --type=socket \
> +                                  --no-legend 2>/dev/null \
> +                        | sed -ne 's/\.socket\s*[a-z]*\s*$/.socket/p'); do
> +
> +            # Only handle successfully loaded sockets triggering this service
> +            triggers=$(systemctl -p Triggers show "$socket" 2>/dev/null)
> +            state=$(systemctl -p LoadState show "$service" 2>/dev/null)
> +
> +            if [ "$state" = "LoadState=loaded" -a \
> +                 "$triggers" = "Triggers=$service" ]; then
> +                sockets="$socket $sockets"
> +                /bin/systemctl $command "$socket"
This feels really clumsy. Why not ask systemd for all triggers of the
service directly? E.g.:

for unit in $(systemctl -p TriggeredBy show "$service" | sed
's/^TriggeredBy=//g')
do
    /bin/systemctl $command $unit
done

-- 
Best regards,
Michael




More information about the Pkg-systemd-maintainers mailing list