From 158d82ea392addd422a93ffb138ad9ba59ad692d Mon Sep 17 00:00:00 2001 From: me Date: Thu, 5 Dec 2013 15:16:59 +0100 Subject: [PATCH] Avoid udev rule masking and configure ifaces with sed instead. --- plugins/guests/arch/cap/configure_networks.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/guests/arch/cap/configure_networks.rb b/plugins/guests/arch/cap/configure_networks.rb index b1706d42a..299e86410 100644 --- a/plugins/guests/arch/cap/configure_networks.rb +++ b/plugins/guests/arch/cap/configure_networks.rb @@ -18,9 +18,20 @@ module VagrantPlugins temp.write(entry) temp.close + # Only consider nth line of sed's output below. There certainly is a + # better way to do this + snth = network[:interface] + 1 + machine.communicate.upload(temp.path, "/tmp/vagrant_network") - machine.communicate.sudo("ln -sf /dev/null /etc/udev/rules.d/80-net-name-slot.rules") machine.communicate.sudo("mv /tmp/vagrant_network /etc/netctl/eth#{network[:interface]}") + + # A hack not to rely on udev rule 80-net-name-slot.rules masking: + # ln -sf /dev/null /etc/udev/80-net-name-slot.rules that + # I assume this to be the most portable solution because + # otherwise we would need to rely on the Virtual Machine implementation + # to provide details on the configured interfaces, e.g mac address + # to write a custom udev rule. + machine.communicate.sudo("sed -i s/eth#{network[:interface]}/`systemctl list-units -t device | sed -n 's/.*subsystem.net-devices-\\(.*\\).device.*/\\1/p' | sed -n #{snth}p`/g /etc/netctl/eth#{network[:interface]}") machine.communicate.sudo("netctl start eth#{network[:interface]}") end end