parent
2e55585eff
commit
b190f45f45
4 changed files with 33 additions and 1 deletions
|
@ -7,6 +7,7 @@ FEATURES:
|
|||
|
||||
IMPROVEMENTS:
|
||||
|
||||
- Remove `/tmp` files after the machine has been successfully shut down [#68][]
|
||||
- Clean up base boxes files after they've been configured, resulting in smaller packages
|
||||
- Bump development dependency to Vagrant 1.2+ series
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ require 'vagrant-lxc/action/forward_ports'
|
|||
require 'vagrant-lxc/action/handle_box_metadata'
|
||||
require 'vagrant-lxc/action/is_running'
|
||||
require 'vagrant-lxc/action/message'
|
||||
require 'vagrant-lxc/action/remove_temporary_files'
|
||||
require 'vagrant-lxc/action/setup_package_files'
|
||||
require 'vagrant-lxc/action/share_folders'
|
||||
|
||||
|
@ -117,9 +118,10 @@ module Vagrant
|
|||
# b.use CheckDependencies
|
||||
b.use Vagrant::Action::Builtin::Call, Created do |env, b2|
|
||||
if env[:result]
|
||||
# TODO: If vagrant >=...
|
||||
# TODO: Remove this on / after 0.4
|
||||
b2.use Disconnect
|
||||
b2.use ClearForwardedPorts
|
||||
b2.use RemoveTemporaryFiles
|
||||
b2.use Vagrant::Action::Builtin::Call, Vagrant::Action::Builtin::GracefulHalt, :stopped, :running do |env2, b3|
|
||||
if !env2[:result]
|
||||
b3.use ForcedHalt
|
||||
|
|
23
lib/vagrant-lxc/action/remove_temporary_files.rb
Normal file
23
lib/vagrant-lxc/action/remove_temporary_files.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
module Vagrant
|
||||
module LXC
|
||||
module Action
|
||||
class RemoveTemporaryFiles
|
||||
def initialize(app, env)
|
||||
@app = app
|
||||
@logger = Log4r::Logger.new("vagrant::lxc::action::remove_tmp_files")
|
||||
end
|
||||
|
||||
def call(env)
|
||||
# Continue execution, we need the container to be stopped
|
||||
@app.call env
|
||||
|
||||
if env[:machine].state.id == :stopped
|
||||
@logger.debug 'Removing temporary files'
|
||||
tmp_path = env[:machine].provider.driver.rootfs_path.join('tmp')
|
||||
system "sudo rm -rf #{tmp_path}/*"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -44,6 +44,7 @@ describe 'Sanity check' do
|
|||
before(:all) do
|
||||
destroy_container
|
||||
vagrant_up
|
||||
vagrant_ssh 'touch /tmp/{some,files}'
|
||||
vagrant_halt
|
||||
end
|
||||
|
||||
|
@ -61,6 +62,11 @@ describe 'Sanity check' do
|
|||
processes = `pgrep redir`
|
||||
expect($?.exitstatus).to_not eq 0
|
||||
end
|
||||
|
||||
it 'removes files under `/tmp`' do
|
||||
container_tmp = Pathname("/var/lib/lxc/#{vagrant_container_name}/rootfs/tmp")
|
||||
expect(container_tmp.entries).to have(2).items # basically '.' and '..'
|
||||
end
|
||||
end
|
||||
|
||||
context '`vagrant destroy`' do
|
||||
|
|
Loading…
Reference in a new issue