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



4
5
6
7
8
9
# File 'lib/osctld/container_control/utils/runscript.rb', line 4

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

#cleanup_init_scriptObject



24
25
26
# File 'lib/osctld/container_control/utils/runscript.rb', line 24

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

#init_scriptObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/osctld/container_control/utils/runscript.rb', line 11

def init_script
  return @init_script if @init_script

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

  @init_script = f
end


28
29
30
31
32
# File 'lib/osctld/container_control/utils/runscript.rb', line 28

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