Module: Specinfra::Command::Module::Service::Systemd

Included in:
Base::Service, Specinfra::Command::Module::Systemd
Defined in:
lib/specinfra/command/module/service/systemd.rb

Instance Method Summary collapse

Instance Method Details

#check_is_enabled_under_systemd(service, level = "multi-user.target") ⇒ Object


6
7
8
9
10
11
12
13
14
15
# File 'lib/specinfra/command/module/service/systemd.rb', line 6

def check_is_enabled_under_systemd(service, level="multi-user.target")
  if level.to_s =~ /^\d+$/
    level = "runlevel#{level}.target"
  end
  unless service.match(/\.(service|mount|device|socket)$/)
    service += '.service'
  end

  "systemctl --plain list-dependencies #{level} | grep '\\(^\\| \\)#{escape(service)}$'"
end

#check_is_running_under_systemd(service) ⇒ Object


17
18
19
# File 'lib/specinfra/command/module/service/systemd.rb', line 17

def check_is_running_under_systemd(service)
  "systemctl is-active #{escape(service)}"
end

#disable_under_systemd(service) ⇒ Object


25
26
27
# File 'lib/specinfra/command/module/service/systemd.rb', line 25

def disable_under_systemd(service)
  "systemctl disable #{escape(service)}"
end

#enable_under_systemd(service) ⇒ Object


21
22
23
# File 'lib/specinfra/command/module/service/systemd.rb', line 21

def enable_under_systemd(service)
  "systemctl enable #{escape(service)}"
end

#reload_under_systemd(service) ⇒ Object


41
42
43
# File 'lib/specinfra/command/module/service/systemd.rb', line 41

def reload_under_systemd(service)
  "systemctl reload #{escape(service)}"
end

#restart_under_systemd(service) ⇒ Object


37
38
39
# File 'lib/specinfra/command/module/service/systemd.rb', line 37

def restart_under_systemd(service)
  "systemctl restart #{escape(service)}"
end

#start_under_systemd(service) ⇒ Object


29
30
31
# File 'lib/specinfra/command/module/service/systemd.rb', line 29

def start_under_systemd(service)
  "systemctl start #{escape(service)}"
end

#stop_under_systemd(service) ⇒ Object


33
34
35
# File 'lib/specinfra/command/module/service/systemd.rb', line 33

def stop_under_systemd(service)
  "systemctl stop #{escape(service)}"
end