Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/linux_admin/distro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def initialize

class RedHat < Distro
COMMANDS = {:service => '/sbin/service',
:systemctl => '/bin/systemctl',
:chkconfig => '/sbin/chkconfig',
:parted => '/sbin/parted',
:mount => '/bin/mount',
:umount => '/bin/umount',
Expand Down
11 changes: 4 additions & 7 deletions lib/linux_admin/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ class Service < LinuxAdmin

private

def systemctl(cmd)
run!(cmd(:systemctl),
:params => { nil => [cmd, "#{id}.service"] })
end

public

def initialize(id)
Expand All @@ -26,12 +21,14 @@ def running?
end

def enable
systemctl 'enable'
run!(cmd(:chkconfig),
:params => { nil => [id, "on"] })
self
end

def disable
systemctl 'disable'
run!(cmd(:chkconfig),
:params => { nil => [id, "off"] })
self
end

Expand Down
8 changes: 4 additions & 4 deletions spec/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
describe "#enable" do
it "enables service" do
@service.should_receive(:run!).
with(@service.cmd(:systemctl),
:params => { nil => [ 'enable', 'foo.service']})
with(@service.cmd(:chkconfig),
:params => { nil => [ 'foo', 'on']})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old reliable "foo" service... 😄

@service.enable
end

Expand All @@ -51,8 +51,8 @@
describe "#disable" do
it "disable service" do
@service.should_receive(:run!).
with(@service.cmd(:systemctl),
:params => { nil => [ 'disable', 'foo.service']})
with(@service.cmd(:chkconfig),
:params => { nil => [ 'foo', 'off']})
@service.disable
end

Expand Down