Skip to content

Commit

Permalink
(puppetlabs#5908) Add support for new update-rc.d enable/disable API
Browse files Browse the repository at this point in the history
Added support for the new enable/disable API to update-rc.d and
added spec tests to check this functionality.

Paired-with:Matt Robinson, Jacob Helwig
  • Loading branch information
Max Martin committed Mar 22, 2011
1 parent 3875b5b commit be5c00c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/puppet/provider/service/debian.rb
Expand Up @@ -22,8 +22,12 @@ def self.defpath

# Remove the symlinks
def disable
update_rc "-f", @resource[:name], "remove"
update_rc @resource[:name], "stop", "00", "1", "2", "3", "4", "5", "6", "."
if `dpkg --compare-versions $(dpkg-query -W --showformat '${Version}' sysv-rc) ge 2.88 ; echo $?`.to_i == 0
update_rc @resource[:name], "disable"
else
update_rc "-f", @resource[:name], "remove"
update_rc @resource[:name], "stop", "00", "1", "2", "3", "4", "5", "6", "."
end
end

def enabled?
Expand Down
16 changes: 14 additions & 2 deletions spec/unit/provider/service/debian_spec.rb
Expand Up @@ -52,8 +52,20 @@
end

describe "when disabling" do
it "should call update-rc.d twice" do
@provider.expects(:update_rc).twice
it "should be able to disable services with newer sysv-rc versions" do
@provider.stubs(:`).with("dpkg --compare-versions $(dpkg-query -W --showformat '${Version}' sysv-rc) ge 2.88 ; echo $?").returns "0"

@provider.expects(:update_rc).with(@resource[:name], "disable")

@provider.disable
end

it "should be able to enable services with older sysv-rc versions" do
@provider.stubs(:`).with("dpkg --compare-versions $(dpkg-query -W --showformat '${Version}' sysv-rc) ge 2.88 ; echo $?").returns "1"

@provider.expects(:update_rc).with("-f", @resource[:name], "remove")
@provider.expects(:update_rc).with(@resource[:name], "stop", "00", "1", "2", "3", "4", "5", "6", ".")

@provider.disable
end
end
Expand Down

0 comments on commit be5c00c

Please sign in to comment.