Module: OsCtld::ContainerControl::Utils::Runscript::Frontend

Included in:
Commands::Exec::Frontend, Commands::Runscript::Frontend
Defined in:
lib/osctld/container_control/utils/runscript.rb

Instance Method Summary collapse

Instance Method Details

#add_network_opts(opts) ⇒ Object



7
8
9
10
11
12
# File 'lib/osctld/container_control/utils/runscript.rb', line 7

def add_network_opts(opts)
  opts.update(
    init_script: File.join('/', File.basename(init_script.path)),
    net_config: NetConfig.create(ct).export
  )
end

#cleanup_init_scriptObject



27
28
29
# File 'lib/osctld/container_control/utils/runscript.rb', line 27

def cleanup_init_script
  @init_script && unlink_file(@init_script.path)
end

#init_scriptObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/osctld/container_control/utils/runscript.rb', line 14

def init_script
  return @init_script if @init_script

  f = Tempfile.create(['.runscript', '.sh'], ct.get_run_conf.rootfs)
  f.chmod(0o500)
  f.puts('#!/bin/sh')
  f.puts('echo ready')
  f.puts('read _')
  f.close

  @init_script = f
end


31
32
33
34
35
# File 'lib/osctld/container_control/utils/runscript.rb', line 31

def unlink_file(path)
  File.unlink(path)
rescue SystemCallError
  # pass
end