Merge pull request #4410 from lsimons/use-rm-with-f

Use -f argument to rm to force-remove files.
This commit is contained in:
Mitchell Hashimoto 2014-08-29 07:40:27 -07:00
commit cd4ac1b542
11 changed files with 17 additions and 17 deletions

View File

@ -12,7 +12,7 @@ module VagrantPlugins
machine.communicate.tap do |comm| machine.communicate.tap do |comm|
# clear prior symlink # clear prior symlink
if comm.test("test -L \"#{guestpath}\"", sudo: true) if comm.test("test -L \"#{guestpath}\"", sudo: true)
comm.sudo("rm \"#{guestpath}\"") comm.sudo("rm -f \"#{guestpath}\"")
end end
# clear prior directory if exists # clear prior directory if exists

View File

@ -15,7 +15,7 @@ module VagrantPlugins
# from the interface file. # from the interface file.
comm.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces") comm.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces")
comm.sudo("su -c 'cat /tmp/vagrant-network-interfaces > /etc/network/interfaces'") comm.sudo("su -c 'cat /tmp/vagrant-network-interfaces > /etc/network/interfaces'")
comm.sudo("rm /tmp/vagrant-network-interfaces") comm.sudo("rm -f /tmp/vagrant-network-interfaces")
# Accumulate the configurations to add to the interfaces file as # Accumulate the configurations to add to the interfaces file as
# well as what interfaces we're actually configuring since we use that # well as what interfaces we're actually configuring since we use that
@ -48,7 +48,7 @@ module VagrantPlugins
end end
comm.sudo("cat /tmp/vagrant-network-entry >> /etc/network/interfaces") comm.sudo("cat /tmp/vagrant-network-entry >> /etc/network/interfaces")
comm.sudo("rm /tmp/vagrant-network-entry") comm.sudo("rm -f /tmp/vagrant-network-entry")
# Bring back up each network interface, reconfigured # Bring back up each network interface, reconfigured
interfaces.each do |interface| interfaces.each do |interface|

View File

@ -20,7 +20,7 @@ module VagrantPlugins
# symlink vmfs volume to :guestpath # symlink vmfs volume to :guestpath
if comm.test("test -L '#{guestpath}'") if comm.test("test -L '#{guestpath}'")
comm.execute("rm '#{guestpath}'") comm.execute("rm -f '#{guestpath}'")
end end
if comm.test("test -d '#{guestpath}'") if comm.test("test -d '#{guestpath}'")
comm.execute("rmdir '#{guestpath}'") comm.execute("rmdir '#{guestpath}'")

View File

@ -64,7 +64,7 @@ module VagrantPlugins
machine.communicate.sudo("touch #{network_scripts_dir}/ifcfg-#{interface}") machine.communicate.sudo("touch #{network_scripts_dir}/ifcfg-#{interface}")
machine.communicate.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-#{interface} > /tmp/vagrant-ifcfg-#{interface}") machine.communicate.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-#{interface} > /tmp/vagrant-ifcfg-#{interface}")
machine.communicate.sudo("cat /tmp/vagrant-ifcfg-#{interface} > #{network_scripts_dir}/ifcfg-#{interface}") machine.communicate.sudo("cat /tmp/vagrant-ifcfg-#{interface} > #{network_scripts_dir}/ifcfg-#{interface}")
machine.communicate.sudo("rm /tmp/vagrant-ifcfg-#{interface}") machine.communicate.sudo("rm -f /tmp/vagrant-ifcfg-#{interface}")
# Render and upload the network entry file to a deterministic # Render and upload the network entry file to a deterministic
# temporary location. # temporary location.
@ -89,7 +89,7 @@ module VagrantPlugins
machine.communicate.sudo("/sbin/ifup #{interface}") machine.communicate.sudo("/sbin/ifup #{interface}")
end end
machine.communicate.sudo("rm /tmp/vagrant-network-entry_#{interface}") machine.communicate.sudo("rm -f /tmp/vagrant-network-entry_#{interface}")
end end
end end
end end

View File

@ -37,7 +37,7 @@ module VagrantPlugins
machine.communicate.upload(temp.path, "/tmp/vagrant-network-entry") machine.communicate.upload(temp.path, "/tmp/vagrant-network-entry")
machine.communicate.sudo("su -m root -c 'cat /tmp/vagrant-network-entry >> /etc/rc.conf'", {shell: "sh"}) machine.communicate.sudo("su -m root -c 'cat /tmp/vagrant-network-entry >> /etc/rc.conf'", {shell: "sh"})
machine.communicate.sudo("rm /tmp/vagrant-network-entry", {shell: "sh"}) machine.communicate.sudo("rm -f /tmp/vagrant-network-entry", {shell: "sh"})
if network[:type].to_sym == :static if network[:type].to_sym == :static
machine.communicate.sudo("ifconfig #{ifname} inet #{network[:ip]} netmask #{network[:netmask]}", {shell: "sh"}) machine.communicate.sudo("ifconfig #{ifname} inet #{network[:ip]} netmask #{network[:netmask]}", {shell: "sh"})

View File

@ -13,7 +13,7 @@ module VagrantPlugins
# Remove any previous host only network additions to the interface file # Remove any previous host only network additions to the interface file
comm.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces") comm.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces")
comm.sudo("cat /tmp/vagrant-network-interfaces > /etc/conf.d/net") comm.sudo("cat /tmp/vagrant-network-interfaces > /etc/conf.d/net")
comm.sudo("rm /tmp/vagrant-network-interfaces") comm.sudo("rm -f /tmp/vagrant-network-interfaces")
# Configure each network interface # Configure each network interface
networks.each do |network| networks.each do |network|
@ -32,7 +32,7 @@ module VagrantPlugins
comm.sudo("ln -fs /etc/init.d/net.lo /etc/init.d/net.eth#{network[:interface]}") comm.sudo("ln -fs /etc/init.d/net.lo /etc/init.d/net.eth#{network[:interface]}")
comm.sudo("/etc/init.d/net.eth#{network[:interface]} stop 2> /dev/null") comm.sudo("/etc/init.d/net.eth#{network[:interface]} stop 2> /dev/null")
comm.sudo("cat /tmp/vagrant-network-entry >> /etc/conf.d/net") comm.sudo("cat /tmp/vagrant-network-entry >> /etc/conf.d/net")
comm.sudo("rm /tmp/vagrant-network-entry") comm.sudo("rm -f /tmp/vagrant-network-entry")
comm.sudo("/etc/init.d/net.eth#{network[:interface]} start") comm.sudo("/etc/init.d/net.eth#{network[:interface]} start")
end end
end end

View File

@ -28,7 +28,7 @@ module VagrantPlugins
# upload it and append it to the new rc.conf file # upload it and append it to the new rc.conf file
machine.communicate.upload(temp.path, "/tmp/vagrant-network-entry") machine.communicate.upload(temp.path, "/tmp/vagrant-network-entry")
machine.communicate.sudo("cat /tmp/vagrant-network-entry >> #{newrcconf}") machine.communicate.sudo("cat /tmp/vagrant-network-entry >> #{newrcconf}")
machine.communicate.sudo("rm /tmp/vagrant-network-entry") machine.communicate.sudo("rm -f /tmp/vagrant-network-entry")
ifname = "wm#{network[:interface]}" ifname = "wm#{network[:interface]}"
# remove old configuration # remove old configuration

View File

@ -26,7 +26,7 @@ module VagrantPlugins
machine.communicate.sudo("touch #{network_scripts_dir}/ifcfg-eth#{network[:interface]}") machine.communicate.sudo("touch #{network_scripts_dir}/ifcfg-eth#{network[:interface]}")
machine.communicate.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-eth#{network[:interface]} > /tmp/vagrant-ifcfg-eth#{network[:interface]}") machine.communicate.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-eth#{network[:interface]} > /tmp/vagrant-ifcfg-eth#{network[:interface]}")
machine.communicate.sudo("cat /tmp/vagrant-ifcfg-eth#{network[:interface]} > #{network_scripts_dir}/ifcfg-eth#{network[:interface]}") machine.communicate.sudo("cat /tmp/vagrant-ifcfg-eth#{network[:interface]} > #{network_scripts_dir}/ifcfg-eth#{network[:interface]}")
machine.communicate.sudo("rm /tmp/vagrant-ifcfg-eth#{network[:interface]}") machine.communicate.sudo("rm -f /tmp/vagrant-ifcfg-eth#{network[:interface]}")
# Render and upload the network entry file to a deterministic # Render and upload the network entry file to a deterministic
# temporary location. # temporary location.
@ -51,7 +51,7 @@ module VagrantPlugins
machine.communicate.sudo("/sbin/ifup eth#{interface} 2> /dev/null") machine.communicate.sudo("/sbin/ifup eth#{interface} 2> /dev/null")
end end
machine.communicate.sudo("rm /tmp/vagrant-network-entry_#{interface}") machine.communicate.sudo("rm -f /tmp/vagrant-network-entry_#{interface}")
end end
end end
end end

View File

@ -93,7 +93,7 @@ module VagrantPlugins
block.call(type, data) block.call(type, data)
end end
@host_vm.communicate.execute("rm #{remote_temp}", error_check: false) @host_vm.communicate.execute("rm -f #{remote_temp}", error_check: false)
return result return result
end end
@ -118,7 +118,7 @@ module VagrantPlugins
"#{container_ssh_command} 'cat >#{to}' <#{to_temp}") "#{container_ssh_command} 'cat >#{to}' <#{to_temp}")
# Remove the temporary file # Remove the temporary file
@host_vm.communicate.execute("rm #{to_temp}", error_check: false) @host_vm.communicate.execute("rm -f #{to_temp}", error_check: false)
end end
#------------------------------------------------------------------- #-------------------------------------------------------------------

View File

@ -103,7 +103,7 @@ module VagrantPlugins
def rm(cid) def rm(cid)
if created?(cid) if created?(cid)
execute('docker', 'rm', '-v', cid) execute('docker', 'rm', '-f', '-v', cid)
end end
end end

View File

@ -159,7 +159,7 @@ describe VagrantPlugins::DockerProvider::Driver do
before { subject.stub(created?: true) } before { subject.stub(created?: true) }
it 'removes the container' do it 'removes the container' do
subject.should_receive(:execute).with('docker', 'rm', '-v', cid) subject.should_receive(:execute).with('docker', 'rm', '-f', '-v', cid)
subject.rm(cid) subject.rm(cid)
end end
end end
@ -168,7 +168,7 @@ describe VagrantPlugins::DockerProvider::Driver do
before { subject.stub(created?: false) } before { subject.stub(created?: false) }
it 'does not attempt to remove the container' do it 'does not attempt to remove the container' do
subject.should_not_receive(:execute).with('docker', 'rm', '-v', cid) subject.should_not_receive(:execute).with('docker', 'rm', '-f', '-v', cid)
subject.rm(cid) subject.rm(cid)
end end
end end