Class: OsCtl::ExportFS::Operations::Runit::Generate
- Defined in:
- lib/osctl/exportfs/operations/runit/generate.rb
Overview
Generate system files for runit
Note that this operation has to be called from inside the server's mount namespace.
Instance Attribute Summary collapse
-
#server ⇒ Object
readonly
protected
Returns the value of attribute server.
-
#vars ⇒ Object
readonly
protected
Returns the value of attribute vars.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(server, config) ⇒ Generate
constructor
A new instance of Generate.
- #write_script(template, path) ⇒ Object protected
- #write_service(template, runsvdir, name) ⇒ Object protected
Methods inherited from Base
Constructor Details
#initialize(server, config) ⇒ Generate
Returns a new instance of Generate.
12 13 14 15 16 17 18 |
# File 'lib/osctl/exportfs/operations/runit/generate.rb', line 12 def initialize(server, config) @server = server @vars = { server: server, config: config, } end |
Instance Attribute Details
#server ⇒ Object (readonly, protected)
Returns the value of attribute server.
37 38 39 |
# File 'lib/osctl/exportfs/operations/runit/generate.rb', line 37 def server @server end |
#vars ⇒ Object (readonly, protected)
Returns the value of attribute vars.
37 38 39 |
# File 'lib/osctl/exportfs/operations/runit/generate.rb', line 37 def vars @vars end |
Instance Method Details
#execute ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/osctl/exportfs/operations/runit/generate.rb', line 20 def execute FileUtils.mkdir_p('/etc/runit') %w(1 2 3).each do |v| write_script("runit/#{v}", "/etc/runit/#{v}") end FileUtils.mkdir_p('/etc/runit/runsvdir') %w(rpcbind nfsd statd).each do |sv| write_service("runsvdir/#{sv}", '/etc/runit/runsvdir', sv) end unless File.exist?('/service') File.symlink('/etc/runit/runsvdir', '/service') end end |
#write_script(template, path) ⇒ Object (protected)
47 48 49 50 |
# File 'lib/osctl/exportfs/operations/runit/generate.rb', line 47 def write_script(template, path) ErbTemplate.render_to(template, vars, path) File.chmod(0755, path) end |
#write_service(template, runsvdir, name) ⇒ Object (protected)
39 40 41 42 43 44 45 |
# File 'lib/osctl/exportfs/operations/runit/generate.rb', line 39 def write_service(template, runsvdir, name) svdir = File.join(runsvdir, name) FileUtils.mkdir_p(svdir) runfile = File.join(svdir, 'run') write_script(template, runfile) end |