Class: Vagrant::LXC::Action::RemoveTemporaryFiles

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-lxc/action/remove_temporary_files.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ RemoveTemporaryFiles

Returns a new instance of RemoveTemporaryFiles.



5
6
7
8
# File 'lib/vagrant-lxc/action/remove_temporary_files.rb', line 5

def initialize(app, env)
  @app    = app
  @logger = Log4r::Logger.new("vagrant::lxc::action::remove_tmp_files")
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/vagrant-lxc/action/remove_temporary_files.rb', line 10

def call(env)
  @logger.debug 'Removing temporary files'
  driver = env[:machine].provider.driver
  # To prevent host-side data loss, it's important that all mounts under /tmp are unmounted
  # before we proceed with the `rm -rf` operation. See #68 and #360.
  driver.attach("findmnt -R /tmp -o TARGET --list --noheadings | xargs -L 1 --no-run-if-empty umount")
  driver.attach("rm -rf /tmp/*")

  @app.call env
end