Merge pull request #856 from stevehodgkiss/fix_error_when_changing_users
Cleanup any tmp files set by vagrant to fix a permissions issue when switching users.
This commit is contained in:
commit
00c4193b43
|
@ -22,6 +22,7 @@ module Vagrant
|
|||
# Remove previous Vagrant-managed network interfaces
|
||||
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.conf > /tmp/vagrant-network-interfaces")
|
||||
vm.channel.sudo("cat /tmp/vagrant-network-interfaces > /etc/rc.conf")
|
||||
vm.channel.sudo("rm /tmp/vagrant-network-interfaces")
|
||||
|
||||
# Configure the network interfaces
|
||||
interfaces = Set.new
|
||||
|
@ -45,6 +46,7 @@ module Vagrant
|
|||
|
||||
# Reconfigure the network interfaces
|
||||
vm.channel.sudo("cat /tmp/vagrant-network-entry >> /etc/rc.conf")
|
||||
vm.channel.sudo("rm /tmp/vagrant-network-entry")
|
||||
vm.channel.sudo("/etc/rc.d/network restart")
|
||||
|
||||
interfaces.each do |interface|
|
||||
|
|
|
@ -14,6 +14,7 @@ module Vagrant
|
|||
# from the interface file.
|
||||
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces")
|
||||
vm.channel.sudo("su -c 'cat /tmp/vagrant-network-interfaces > /etc/network/interfaces'")
|
||||
vm.channel.sudo("rm /tmp/vagrant-network-interfaces")
|
||||
|
||||
# Accumulate the configurations to add to the interfaces file as
|
||||
# well as what interfaces we're actually configuring since we use that
|
||||
|
@ -45,6 +46,7 @@ module Vagrant
|
|||
end
|
||||
|
||||
vm.channel.sudo("cat /tmp/vagrant-network-entry >> /etc/network/interfaces")
|
||||
vm.channel.sudo("rm /tmp/vagrant-network-entry")
|
||||
|
||||
# Bring back up each network interface, reconfigured
|
||||
interfaces.each do |interface|
|
||||
|
|
|
@ -21,6 +21,7 @@ module Vagrant
|
|||
vm.channel.sudo("touch #{network_scripts_dir}/ifcfg-p7p#{network[:interface]}")
|
||||
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-p7p#{network[:interface]} > /tmp/vagrant-ifcfg-p7p#{network[:interface]}")
|
||||
vm.channel.sudo("cat /tmp/vagrant-ifcfg-p7p#{network[:interface]} > #{network_scripts_dir}/ifcfg-p7p#{network[:interface]}")
|
||||
vm.channel.sudo("rm /tmp/vagrant-ifcfg-p7p#{network[:interface]}")
|
||||
|
||||
# Render and upload the network entry file to a deterministic
|
||||
# temporary location.
|
||||
|
@ -41,6 +42,7 @@ module Vagrant
|
|||
interfaces.each do |interface|
|
||||
vm.channel.sudo("/sbin/ifdown p7p#{interface} 2> /dev/null", :error_check => false)
|
||||
vm.channel.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-p7p#{interface}")
|
||||
vm.channel.sudo("rm /tmp/vagrant-network-entry_#{interface}")
|
||||
vm.channel.sudo("/sbin/ifup p7p#{interface} 2> /dev/null")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -67,6 +67,8 @@ module Vagrant
|
|||
:options => network)
|
||||
vm.channel.upload(StringIO.new(entry), "/tmp/vagrant-network-entry")
|
||||
vm.channel.sudo("su -m root -c 'cat /tmp/vagrant-network-entry >> /etc/rc.conf'")
|
||||
vm.channel.sudo("rm /tmp/vagrant-network-entry")
|
||||
|
||||
if network[:type].to_sym == :static
|
||||
vm.channel.sudo("ifconfig em#{network[:interface]} inet #{network[:ip]} netmask #{network[:netmask]}")
|
||||
elsif network[:type].to_sym == :dhcp
|
||||
|
|
|
@ -12,6 +12,7 @@ module Vagrant
|
|||
# Remove any previous host only network additions to the interface file
|
||||
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces")
|
||||
vm.channel.sudo("cat /tmp/vagrant-network-interfaces > /etc/conf.d/net")
|
||||
vm.channel.sudo("rm /tmp/vagrant-network-interfaces")
|
||||
|
||||
# Configure each network interface
|
||||
networks.each do |network|
|
||||
|
@ -30,6 +31,7 @@ module Vagrant
|
|||
vm.channel.sudo("ln -fs /etc/init.d/net.lo /etc/init.d/net.eth#{network[:interface]}")
|
||||
vm.channel.sudo("/etc/init.d/net.eth#{network[:interface]} stop 2> /dev/null")
|
||||
vm.channel.sudo("cat /tmp/vagrant-network-entry >> /etc/conf.d/net")
|
||||
vm.channel.sudo("rm /tmp/vagrant-network-entry")
|
||||
vm.channel.sudo("/etc/init.d/net.eth#{network[:interface]} start")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,6 +22,7 @@ module Vagrant
|
|||
vm.channel.sudo("touch #{network_scripts_dir}/ifcfg-eth#{network[:interface]}")
|
||||
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-eth#{network[:interface]} > /tmp/vagrant-ifcfg-eth#{network[:interface]}")
|
||||
vm.channel.sudo("cat /tmp/vagrant-ifcfg-eth#{network[:interface]} > #{network_scripts_dir}/ifcfg-eth#{network[:interface]}")
|
||||
vm.channel.sudo("rm /tmp/vagrant-ifcfg-eth#{network[:interface]}")
|
||||
|
||||
# Render and upload the network entry file to a deterministic
|
||||
# temporary location.
|
||||
|
@ -42,6 +43,7 @@ module Vagrant
|
|||
interfaces.each do |interface|
|
||||
vm.channel.sudo("/sbin/ifdown eth#{interface} 2> /dev/null", :error_check => false)
|
||||
vm.channel.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-eth#{interface}")
|
||||
vm.channel.sudo("rm /tmp/vagrant-network-entry_#{interface}")
|
||||
vm.channel.sudo("/sbin/ifup eth#{interface} 2> /dev/null")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue