Bug#768456: Second version of the patch

Didier Roche didrocks at ubuntu.com
Fri Nov 7 15:36:46 GMT 2014


Here is a second version of the patch after feedback on OFTC. It uses
more robust commands then parsing the status output.
Note that I don't use try-restart as it doesn't map the case of job
enabled but stopped -> restart on package upgrade is supposed to start
the daemon (as with init case).
Do not hesitate if you see any other needed changes.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-systemd-maintainers/attachments/20141107/5935d1b4/attachment.html>
-------------- next part --------------
diff -Nru init-system-helpers-1.21/debian/changelog init-system-helpers-1.22/debian/changelog
--- init-system-helpers-1.21/debian/changelog	2014-08-21 07:40:58.000000000 +0200
+++ init-system-helpers-1.22/debian/changelog	2014-11-07 15:13:08.000000000 +0100
@@ -1,3 +1,16 @@
+init-system-helpers (1.22) UNRELEASED; urgency=medium
+
+  * deb-system-invoke: don't start disabled systemd services (in case
+    of systemd only services), when there is no init script.
+    Add some conditions to start the job on deb-system-invoke [restart|start],
+    during package upgrade: (Closes: #768456)
+    - deb-system-invoke start <unit> don't do anything on systemd if the
+      service is disabled.
+    - deb-system-invoke restart <unit> only restart a disabled service if
+      if the daemon was already running (forced by the admin).
+
+ -- Didier Roche <didrocks at ubuntu.com>  Fri, 07 Nov 2014 15:01:27 +0100
+
 init-system-helpers (1.21) unstable; urgency=medium
 
   * Demote augeas-tools to Suggests and let the systemd2init tool error out
diff -Nru init-system-helpers-1.21/script/deb-systemd-invoke init-system-helpers-1.22/script/deb-systemd-invoke
--- init-system-helpers-1.21/script/deb-systemd-invoke	2014-08-21 07:40:58.000000000 +0200
+++ init-system-helpers-1.22/script/deb-systemd-invoke	2014-11-07 16:10:39.000000000 +0100
@@ -77,4 +77,24 @@
     }
 }
 
-exec '/bin/systemctl', @ARGV;
+# If the job is disabled and is not currently running, the job is not started or restarted.
+# However, if the job is disabled but has been forced into the running state, we *do* stop
+# and restart it since this is expected behaviour for the admin who forced the start.
+if (grep("/^$action$/", ["start", "restart"])) {
+    for my $unit (@units) {
+        system("systemctl --quiet is-enabled $unit");
+        my $unit_enabled = $?>>8;
+        system("systemctl --quiet is-active $unit");
+        my $unit_active = $?>>8;
+        if (($unit_enabled != 0) && ("$action" eq "start")) {
+            print STDERR "$unit is disabled, don't start it.\n";
+        } elsif (($unit_enabled != 0) && ($unit_active != 0) && ("$action" eq "restart")) {
+            print STDERR "$unit is disabled and not running, don't start it.\n";
+        }
+        else {
+            system('/bin/systemctl', "$action", "$unit");
+        }
+    }
+} else {
+    exec '/bin/systemctl', @ARGV;
+}


More information about the Pkg-systemd-maintainers mailing list