Control: tags -1 +patch

Hi

I created a patch to use /usr/sbin/service as suggested earlier in this
report to start/stop/status/restart services on Debian. I'm a bit
reluctant to just NMU puppet and would prefer if one of the maintainers
and/or Faidon could have a look at my patch first. If you approve I can
then do the NMU if you are short on time.

I tested the patch locally and as far as I can see it works fine with
systemd and does call the right command. I don't have a system with
system V handy to test on.

Gaudenz

From 2eae3a2a71de50889535f0e917ac6f4ecaeb8975 Mon Sep 17 00:00:00 2001
From: Gaudenz Steinlin <gaud...@soziologie.ch>
Date: Sat, 31 Jan 2015 16:09:08 +0100
Subject: [PATCH] Use /usr/sbin/service in Debian service provider

Closes: #775795
---
 .../0004-debian-service-provider-use-service.patch | 56 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 2 files changed, 57 insertions(+)
 create mode 100644 debian/patches/0004-debian-service-provider-use-service.patch

diff --git a/debian/patches/0004-debian-service-provider-use-service.patch b/debian/patches/0004-debian-service-provider-use-service.patch
new file mode 100644
index 0000000..29a4277
--- /dev/null
+++ b/debian/patches/0004-debian-service-provider-use-service.patch
@@ -0,0 +1,56 @@
+From: Gaudenz Steinlin <gaud...@debian.org>
+Subject: Use /usr/sbin/service for service management on Debian
+
+In Debian jessie systemd will be the default init system. But the old system V
+and other alternative init systems are still supported. /usr/sbin/service
+provides an abstraction layer which is able to start, stop and restart
+services independent of the init system used.
+
+Bug: https://tickets.puppetlabs.com/browse/PUP-2023
+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=775795
+---
+Index: puppet/lib/puppet/provider/service/debian.rb
+===================================================================
+--- puppet.orig/lib/puppet/provider/service/debian.rb	2015-01-31 17:30:09.000000000 +0100
++++ puppet/lib/puppet/provider/service/debian.rb	2015-01-31 23:05:10.477108925 +0100
+@@ -16,6 +16,11 @@
+   # is resolved.
+   commands :invoke_rc => "/usr/sbin/invoke-rc.d"
+ 
++  # This isn't being used directly, it's just here to ensure
++  # that the /usr/sbin/service binary is available.
++  service = "/usr/sbin/service"
++  commands :service_cmd => service
++
+   defaultfor :operatingsystem => :debian
+ 
+   # Remove the symlinks
+@@ -61,4 +66,28 @@
+     update_rc "-f", @resource[:name], "remove"
+     update_rc @resource[:name], "defaults"
+   end
++
++  # The start, stop, restart and status command use service
++  # this makes sure that these commands work with whatever init
++  # system is installed
++  def startcmd
++    [service, @resource[:name], :start]
++  end
++
++  # The stop command is just the init script with 'stop'.
++  def stopcmd
++    [service, @resource[:name], :stop]
++  end
++
++  def restartcmd
++    (@resource[:hasrestart] == :true) && [service, @resource[:name], :restart]
++  end
++
++  # If it was specified that the init script has a 'status' command, then
++  # we just return that; otherwise, we return false, which causes it to
++  # fallback to other mechanisms.
++  def statuscmd
++    (@resource[:hasstatus] == :true) && [service, @resource[:name], :status]
++  end
++
+ end
diff --git a/debian/patches/series b/debian/patches/series
index 471a23b..6543a01 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
 0001-Do-not-require-rubygems.patch
 0002-Set-passenger-puppet-master-document-root.patch
 0003-fix-puppet-master-logcheck-rule.patch
+0004-debian-service-provider-use-service.patch
-- 
2.1.4

Attachment: signature.asc
Description: PGP signature

Reply via email to