Bug#826012: /lib/lsb/init-functions.d/40-systemd: Support for compound target units as first-order services
Am 10.12.18 um 14:12 schrieb Michael Biebl: > Say you have test.service and test.target. > I'm not sure if there is a reliable way to detect whether the user > wanted test.service or test.target when running "/etc/init.d/test ..." Just tested systemctl. If you have a test.service and test.target and you run systemctl start test then test.service is started but not test.target. So, I guess what would be more in line with the systemctl behaviour is a patch which does the following: If you run /etc/init.d/test start: - We start test.service if it exists - If test.service does not exist and a test.target exist, start the target. - If no service and target exists, fall through and let the sysv init script handle the request directly Michael -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? signature.asc Description: OpenPGP digital signature
Bug#826012: /lib/lsb/init-functions.d/40-systemd: Support for compound target units as first-order services
Hi Am 01.06.16 um 14:07 schrieb Terry Burton: > This message [1] identifies that compound target units are the > appropriate mechanism for controlling multiple service units. > > The LSB override hook currently only consider .service units, ignoring > compound .target units. > > Support for this would be useful for providing systemd scripts for > multi-daemon services such as ISC DHCP server (with IPv4 and IPv6; > discussions ongoing here [2]) and PostgreSQL. > > A patch for /lib/lsb/init-functions.d/40-systemd is attached. We probe > for a compound .target unit (having component services in the derived > ConsistsOf property) of matching service name invoking this as we > would a plain .service unit. I don't think using ConsistsOf= is the right property to determine whether to use a target or not. There can be targets without ConsistsOf and there can also be services with ConsistsOf Say you have test.service and test.target. I'm not sure if there is a reliable way to detect whether the user wanted test.service or test.target when running "/etc/init.d/test ..." -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? signature.asc Description: OpenPGP digital signature
Bug#826012: /lib/lsb/init-functions.d/40-systemd: Support for compound target units as first-order services
Package: systemd Version: 230-2 Severity: normal This message [1] identifies that compound target units are the appropriate mechanism for controlling multiple service units. The LSB override hook currently only consider .service units, ignoring compound .target units. Support for this would be useful for providing systemd scripts for multi-daemon services such as ISC DHCP server (with IPv4 and IPv6; discussions ongoing here [2]) and PostgreSQL. A patch for /lib/lsb/init-functions.d/40-systemd is attached. We probe for a compound .target unit (having component services in the derived ConsistsOf property) of matching service name invoking this as we would a plain .service unit. Would a maintainer kindly review? It may be desirable to coordinate this with corresponding patches to the init-system-helpers scripts [3]. [1] https://lists.freedesktop.org/archives/systemd-devel/2015-July/033628.html [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=792894 [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=826011 Many thanks, Terry --- a/40-systemd 2016-06-01 11:55:20.885757279 +0100 +++ b/40-systemd 2016-06-01 12:00:21.42184 +0100 @@ -19,7 +19,11 @@ # Some services can't reload through the .service file, # but can through the init script. prog=${0##*/} -service="${prog%.sh}.service" +if [ "$(systemctl -p ConsistsOf show ${prog%.sh}.target)" != "ConsistsOf=" ]; then +service="${prog%.sh}.target" +else +service="${prog%.sh}.service" +fi if [ "$(systemctl -p CanReload show $service 2>/dev/null)" = "CanReload=no" ] && [ "${1:-}" = "reload" ]; then _use_systemctl=0 fi @@ -51,7 +55,12 @@ ;; esac -service="${prog%.sh}.service" +# If there is an umbrella target for prog then use it +if [ "$(systemctl -p ConsistsOf show ${prog%.sh}.target)" != "ConsistsOf=" ]; then +service="${prog%.sh}.target" +else +service="${prog%.sh}.service" +fi # Don't try to run masked services. Don't check for errors, if # this errors, we'll just call systemctl and possibly explode