Class: OsCtld::ContainerControl::Commands::Exec::Frontend
- Includes:
- Utils::Runscript::Frontend
- Defined in:
- lib/osctld/container_control/commands/exec.rb
Instance Attribute Summary
Attributes inherited from Frontend
Instance Method Summary collapse
-
#execute(opts) ⇒ Integer
Exit status.
Methods included from Utils::Runscript::Frontend
#add_network_opts, #cleanup_init_script, #init_script, #unlink_file
Methods inherited from Frontend
#exec_runner, #fork_runner, #initialize
Constructor Details
This class inherits a constructor from OsCtld::ContainerControl::Frontend
Instance Method Details
#execute(opts) ⇒ Integer
Returns exit status.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/osctld/container_control/commands/exec.rb', line 26 def execute(opts) runner_opts = { cmd: opts[:cmd] } mode = if ct.running? :running elsif !ct.running? && opts[:run] && opts[:network] :run_network elsif !ct.running? && opts[:run] :run else raise ContainerControl::Error, 'container not running' end if opts[:network] add_network_opts(runner_opts) end if %i[run run_network].include?(mode) ct.ensure_run_conf # Remove any left-over temporary mounts ct.mounts.prune # Pre-start distconfig hook DistConfig.run(ct.run_conf, :pre_start) end ret = exec_runner( args: [mode, runner_opts], stdin: opts[:stdin], stdout: opts[:stdout], stderr: opts[:stderr], reset_subtree_control: mode != :running ) ret.ok? ? ret.data : ret ensure cleanup_init_script end |