Class: Vagrant::LXC::SudoWrapper
- Inherits:
-
Object
- Object
- Vagrant::LXC::SudoWrapper
- Includes:
- Util::Retryable
- Defined in:
- lib/vagrant-lxc/sudo_wrapper.rb
Instance Method Summary collapse
-
#initialize(wrapper_path = nil) ⇒ SudoWrapper
constructor
A new instance of SudoWrapper.
- #run(*command) ⇒ Object
- #su_c(command) ⇒ Object
Constructor Details
#initialize(wrapper_path = nil) ⇒ SudoWrapper
Returns a new instance of SudoWrapper.
7 8 9 10 |
# File 'lib/vagrant-lxc/sudo_wrapper.rb', line 7 def initialize(wrapper_path = nil) @wrapper_path = wrapper_path @logger = Log4r::Logger.new("vagrant::lxc::sudo_wrapper") end |
Instance Method Details
#run(*command) ⇒ Object
12 13 14 15 |
# File 'lib/vagrant-lxc/sudo_wrapper.rb', line 12 def run(*command) command.unshift @wrapper_path if @wrapper_path execute *(['sudo'] + command) end |
#su_c(command) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/vagrant-lxc/sudo_wrapper.rb', line 17 def su_c(command) su_command = if @wrapper_path "#{@wrapper_path} \"#{command}\"" else "su root -c \"#{command}\"" end @logger.debug "Running 'sudo #{su_command}'" system "sudo #{su_command}" end |