# File lib/foreman_maintain/utils/service/systemd.rb, line 4 def initialize(name, priority, _options = {}) super @sys = SystemHelpers.new end
# File lib/foreman_maintain/utils/service/systemd.rb, line 9 def command(action, options = {}) do_wait = options.fetch(:wait, true) # wait for service to start if do_wait && File.exist?('/usr/sbin/service-wait') "service-wait #{@name} #{action}" else "systemctl #{action} #{@name}" end end
# File lib/foreman_maintain/utils/service/systemd.rb, line 34 def disable execute('disable', :wait => false) end
# File lib/foreman_maintain/utils/service/systemd.rb, line 30 def enable execute('enable', :wait => false) end
# File lib/foreman_maintain/utils/service/systemd.rb, line 42 def exist? if @sys.systemd_installed? systemd = @sys.execute("systemctl is-enabled #{@name} 2>&1 | tail -1").strip systemd == 'enabled' || systemd == 'disabled' else File.exist?("/etc/init.d/#{service}") end end
# File lib/foreman_maintain/utils/service/systemd.rb, line 38 def running? status.first == 0 end
# File lib/foreman_maintain/utils/service/systemd.rb, line 22 def start execute('start') end
# File lib/foreman_maintain/utils/service/systemd.rb, line 18 def status execute('status') end
# File lib/foreman_maintain/utils/service/systemd.rb, line 26 def stop execute('stop') end
# File lib/foreman_maintain/utils/service/systemd.rb, line 53 def execute(action, options = {}) @sys.execute_with_status(command(action, options)) end