aws: Let udev rename all network interfaces

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Michael Tremer
2018-08-22 14:00:39 +01:00
parent caf5dcb1e7
commit c5465a9453
2 changed files with 8 additions and 24 deletions

View File

@@ -50,22 +50,6 @@ prefix2netmask() {
to_address "$(( netmask ^ 0xffffffff ))"
}
find_interface() {
local mac="${1}"
local path
for path in /sys/class/net/*; do
local address="$(<${path}/address)"
if [ "${mac}" = "${address}" ]; then
basename "${path}"
return 0
fi
done
return 1
}
import_aws_configuration() {
local instance_id="$(get meta-data/instance-id)"
@@ -243,19 +227,13 @@ import_aws_configuration() {
) >> /var/ipfire/ethernet/settings
;;
esac
# Rename interface
local interface="$(find_interface "${mac}")"
if [ -n "${interface}" ] && [ -n "${interface_name}" ] && [ "${interface}" != "${interface_name}" ]; then
ip link set "${interface}" down
ip link set "${interface}" name "${interface_name}"
fi
done
# Save CONFIG_TYPE
echo "CONFIG_TYPE=${config_type}" >> /var/ipfire/ethernet/settings
# Actions performed only on the very first start
if [ ! -e "/var/ipfire/main/firstsetup_ok" ]; then
# Enable SSH
@@ -322,6 +300,9 @@ case "${reason}" in
# Remove all IP addresses
ip addr flush dev "${interface}"
# Shut down the interface
ip link set "${interface}" down
;;
*)

View File

@@ -60,6 +60,9 @@ case "${1}" in
# End DHCP client immediately
dhclient -sf /etc/rc.d/helper/aws-setup -r "${intf}" &>/dev/null
# Rename network devices
udevadm trigger --action="add" --subsystem-match="net"
exit 0
;;