Class: DanarchyDeploy::Services::Init::Openrc
- Inherits:
-
Object
- Object
- DanarchyDeploy::Services::Init::Openrc
- Defined in:
- lib/danarchy_deploy/services/init/openrc.rb
Instance Method Summary collapse
- #disable ⇒ Object
- #enable ⇒ Object
-
#initialize(service, runlevel = 'default', options) ⇒ Openrc
constructor
A new instance of Openrc.
- #reload ⇒ Object
- #restart ⇒ Object
- #start ⇒ Object
- #status ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(service, runlevel = 'default', options) ⇒ Openrc
Returns a new instance of Openrc.
6 7 8 9 10 11 |
# File 'lib/danarchy_deploy/services/init/openrc.rb', line 6 def initialize(service, runlevel='default', ) @service = service @runlevel = runlevel @options = cleanup_runlevels end |
Instance Method Details
#disable ⇒ Object
67 68 69 70 |
# File 'lib/danarchy_deploy/services/init/openrc.rb', line 67 def disable cmd = "rc-update del #{@service} #{@runlevel}" DanarchyDeploy::Helpers.run_command(cmd, @options) end |
#enable ⇒ Object
62 63 64 65 |
# File 'lib/danarchy_deploy/services/init/openrc.rb', line 62 def enable cmd = "rc-update add #{@service} #{@runlevel}" DanarchyDeploy::Helpers.run_command(cmd, @options) end |
#reload ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/danarchy_deploy/services/init/openrc.rb', line 41 def reload status = self.status cmd = if status[:stderr] # status[:stdout].include?('running') # This used to check for status "running"; and previously "started". # Too specific so I've disabled it since I don't remember what this exception was for, originally. puts " |! Service: #{@service} is not running. Starting it up instead." "rc-service #{@service} start" else "rc-service #{@service} reload" end DanarchyDeploy::Helpers.run_command(cmd, @options) end |
#restart ⇒ Object
57 58 59 60 |
# File 'lib/danarchy_deploy/services/init/openrc.rb', line 57 def restart cmd = "rc-service #{@service} restart" DanarchyDeploy::Helpers.run_command(cmd, @options) end |
#start ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/danarchy_deploy/services/init/openrc.rb', line 19 def start cmd = "rc-service #{@service} start" status = self.status if status[:stdout].include?('started') return status else DanarchyDeploy::Helpers.run_command(cmd, @options) end end |
#status ⇒ Object
13 14 15 16 17 |
# File 'lib/danarchy_deploy/services/init/openrc.rb', line 13 def status cmd = "rc-service #{@service} status" return { stdout: "Fake run: started", stderr: nil } if @options[:pretend] DanarchyDeploy::Helpers.run_command(cmd, @options) end |
#stop ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/danarchy_deploy/services/init/openrc.rb', line 30 def stop cmd = "rc-service #{@service} stop" status = self.status if status[:stdout].include?('stopped') return status else DanarchyDeploy::Helpers.run_command(cmd, @options) end end |