]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
aws: Let udev rename all network interfaces
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 22 Aug 2018 13:00:39 +0000 (14:00 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 22 Aug 2018 13:00:39 +0000 (14:00 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/initscripts/helper/aws-setup
src/initscripts/system/aws

index 893246ba1689bccec0076d71bc850a8dd6948411..b2bb5a966962d3ba3692bb64169299411835430e 100644 (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
                ;;
 
        *)
index 6fce670a03a79e8d75332bf677068ae78c5c6a35..2a556801ac8ca5854798096b31b0fa65277a7cf3 100644 (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
                ;;