Hi

Gaudenz Steinlin <gaud...@debian.org> writes:

> Stephen Gran <sg...@debian.org> writes:
>
>> Hi,
>>
>> This one time, at band camp, Stig Sandbeck Mathisen said:
>>> 
>>> Hello,
>>> 
>>> Thanks for the patch.  It looks like it has the correct solution, using
>>> the Debian abstraction layer over the alternative init systems.
>>> 
>>> However, I've found a problem with it using the "puppet resource"
>>> command. Could you see if you find what causes it?
>
> The idea in my patch is to add the service_cmd definition to ensure that
> this provider is only choosen if the service command is available. But
> you can't use this command because of the way the provider works. The
> problem is that startcmd, stopcmd, etc. should return an array with the
> command and it's argument.
>
> The problem is probably that I replaced the hardcoded /usr/sbin/service
> by a variable after testing the patch and screwed that up somehow. I'm
> right now looking into this and will send a new patch as soon as it's
> fixed.

Attached is an updated patch that uses a propoer Ruby constant for
/usr/sbin/service. The first patch was botched by my "Pythonistic"
approach to code this.

>
> If I understand Stephens patch correctly it directly executes the
> service comamnd during the call to XXXcmd. As far as I can see this is
> not the way things should work (looking at provider/service/base.rb).

I did not manage to get this patch to run at all :-(.

Gaudenz
From 089cb15a2ec53831def122a958965e950709b664 Mon Sep 17 00:00:00 2001
From: Gaudenz Steinlin <gaud...@debian.org>
Date: Thu, 5 Feb 2015 12:14:06 +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..0a81c3e
--- /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-02-05 12:07:37.451292892 +0100
++++ puppet/lib/puppet/provider/service/debian.rb	2015-02-05 12:13:06.500095957 +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