Control: tag -1 patch

Hello Michael,

Michael Biebl [2016-07-13 18:28 +0200]:
> > We need to replace is-enabled with something which also works for
> > sysv-only services (with v215).
> [...]
> v215 for a sysv only service
> $ systemctl is-enabled rpcbind
> Failed to get unit file state for rpcbind.service: No such file or directory

This works in >= 220-1 via the systemd-sysv-install wrapper, but not
before. WDYT about the attached patch? I tested that in a Jessie
container. This is more relaxed than the SLINK/SSLINK= further down as
it does not rely on `runlevel`.

Thanks,

Martin
-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
>From 08d6d3ce4d3bf2c3428d40e6a33665aba7270f59 Mon Sep 17 00:00:00 2001
From: Martin Pitt <martin.p...@ubuntu.com>
Date: Thu, 14 Jul 2016 15:39:53 +0200
Subject: [PATCH] invoke-rc.d: Add SysV fallback for "systemctl is-enabled" for
 systemd < 220

Commit 6dd9d53f4 switched to "systemctl is-enabled" to determine if a service
is enabled. This also has worked for SysV init scripts since systemd 220-1 (via
the systemd-sysv-install wrapper), but does not yet work under Jessie's systemd
215.

Add a fallback to checking runlevel symlinks (for any runlevel) to fix upgrades
where init-system-helpers gets upgraded before systemd, and to make i-s-h
backportable to Jessie.

Closes: #830982
---
 script/invoke-rc.d | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/script/invoke-rc.d b/script/invoke-rc.d
index ec87bbc..214f498 100755
--- a/script/invoke-rc.d
+++ b/script/invoke-rc.d
@@ -380,8 +380,11 @@ RC=
 ### LOCAL POLICY: Enforce that the script/unit is enabled. For SysV init
 ### scripts, this needs a start entry in either runlevel S or current runlevel
 ### to allow start or restart.
+### Note that systemd 215 does not yet support is-enabled for SysV scripts,
+### this works only with systemd >= 220-1 (systemd-sysv-install).
 if [ -n "$is_systemd" ]; then
-    if systemctl --quiet is-enabled "${UNIT}" 2>/dev/null; then
+    if systemctl --quiet is-enabled "${UNIT}" 2>/dev/null || \
+       ls ${RCDPREFIX}[S2345].d/S[0-9][0-9]${INITSCRIPTID} >/dev/null 2>&1; then
         RC=104
     else
         RC=101
-- 
2.8.1

_______________________________________________
Pkg-systemd-maintainers mailing list
Pkg-systemd-maintainers@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-systemd-maintainers

Reply via email to