Class: Vagrant::LXC::SudoWrapper

Inherits:
Object
  • Object
show all
Includes:
Util::Retryable
Defined in:
lib/vagrant-lxc/sudo_wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wrapper_path = nil) ⇒ SudoWrapper

Returns a new instance of SudoWrapper.



9
10
11
12
# File 'lib/vagrant-lxc/sudo_wrapper.rb', line 9

def initialize(wrapper_path = nil)
  @wrapper_path = wrapper_path
  @logger       = Log4r::Logger.new("vagrant::lxc::sudo_wrapper")
end

Instance Attribute Details

#wrapper_pathObject (readonly)

Returns the value of attribute wrapper_path.



7
8
9
# File 'lib/vagrant-lxc/sudo_wrapper.rb', line 7

def wrapper_path
  @wrapper_path
end

Instance Method Details

#run(*command) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/vagrant-lxc/sudo_wrapper.rb', line 14

def run(*command)
  options = command.last.is_a?(Hash) ? command.last : {}
  if @wrapper_path && !options[:no_wrapper]
    command.unshift @wrapper_path
    execute *(['sudo'] + command)
  else
    execute *(['sudo', '/usr/bin/env'] + command)
  end
end