Cleanup tempfiles when done.

This commit is contained in:
Brian Johnson 2013-06-17 22:36:21 -07:00
parent 782168492c
commit 2a190a299e
1 changed files with 4 additions and 0 deletions

View File

@ -26,6 +26,7 @@ module VagrantPlugins
end end
env.machine(name,p).communicate.upload(path.join("hosts.#{name}"), '/tmp/hosts') env.machine(name,p).communicate.upload(path.join("hosts.#{name}"), '/tmp/hosts')
env.machine(name,p).communicate.sudo("mv /tmp/hosts /etc/hosts") env.machine(name,p).communicate.sudo("mv /tmp/hosts /etc/hosts")
FileUtils.rm(path.join("hosts.#{name}"))
end end
end end
@ -53,6 +54,7 @@ module VagrantPlugins
machine.communicate.upload(path.join("hosts.#{name}"), '/tmp/hosts') machine.communicate.upload(path.join("hosts.#{name}"), '/tmp/hosts')
machine.communicate.sudo("mv /tmp/hosts /etc/hosts") machine.communicate.sudo("mv /tmp/hosts /etc/hosts")
end end
FileUtils.rm(path.join("hosts.#{name}"))
end end
end end
end end
@ -95,6 +97,7 @@ module VagrantPlugins
@logger.warn "Running sudo to replace local hosts file, enter your local password if prompted..." @logger.warn "Running sudo to replace local hosts file, enter your local password if prompted..."
@logger.info `sudo cp -v #{temp_file_name} #{file_name}` @logger.info `sudo cp -v #{temp_file_name} #{file_name}`
end end
FileUtils.rm(temp_file_name)
end end
def delete_entry(machine,file_name,sudo=false) def delete_entry(machine,file_name,sudo=false)
@ -117,6 +120,7 @@ module VagrantPlugins
machine.env.ui.info I18n.t('vagrant_hostmanager.action.run_sudo') machine.env.ui.info I18n.t('vagrant_hostmanager.action.run_sudo')
@logger.info `sudo cp -v #{temp_file_name} #{file_name}` @logger.info `sudo cp -v #{temp_file_name} #{file_name}`
end end
FileUtils.rm(temp_file_name)
else else
@logger.warn "Machine id to delete was empty, skipping..." @logger.warn "Machine id to delete was empty, skipping..."
end end