Module: Vagabond::Helpers::Commands

Defined in:
lib/vagabond/helpers/commands.rb

Instance Method Summary collapse

Instance Method Details

#build_command(command, args = {}) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/vagabond/helpers/commands.rb', line 33

def build_command(command, args={})
  command = "#{via_bundle}#{command}" unless args[:no_bundle]
  command = "#{sudo}#{command}" if args[:sudo]
  pre_args = args[:shellout] || {}
  debug(command)
  cmd = Mixlib::ShellOut.new(
    command, {
      :live_stream => options[:debug],
      :timeout => 3600
    }.merge(pre_args)
  )
  cmd
end

#direct_container_command(command, args = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vagabond/helpers/commands.rb', line 9

def direct_container_command(command, args={})
  _lxc = args[:lxc] || lxc
  com = "#{sudo}ssh root@#{lxc.container_ip} -i #{Settings[:ssh_key]} -oStrictHostKeyChecking=no '#{command}'"
  debug(com)
  begin
    cmd = Mixlib::ShellOut.new(com,
      :live_stream => args[:live_stream] || options[:debug],
      :timeout => args[:timeout] || 1200
    )
    cmd.run_command
    cmd.error!
    cmd
  rescue
    raise if args[:raise_on_failure]
    false
  end
end

#via_bundleObject



27
28
29
30
31
# File 'lib/vagabond/helpers/commands.rb', line 27

def via_bundle
  if(defined?(Bundler) && Bundler.bundle_path)
    'bundle exec '
  end
end