Please find the attached debdiff trying to address the issue.

Any suggestion to enhance it is welcome. :)
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 <didro...@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 
15:01:24.000000000 +0100
@@ -77,4 +77,21 @@
     }
 }
 
-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) {
+        my $job_status = `/bin/systemctl status $unit`;
+        if (($job_status =~ /disabled/) && ("$action" eq "start")) {
+            print STDERR "$unit is disabled, don't start it.\n";
+            exit 0;
+        } elsif (($job_status =~ /disabled/) && ($job_status !~ /running/) && 
("$action" eq "restart")) {
+            print STDERR "$unit is disabled and not running, don't start 
it.\n";
+            exit 0;
+        }
+        exec '/bin/systemctl', "$action", "$unit";
+    }
+} else {
+    exec '/bin/systemctl', @ARGV;
+}

Reply via email to