mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-10 02:55:55 +02:00
aws: Let udev rename all network interfaces
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
@@ -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
|
||||
;;
|
||||
|
||||
*)
|
||||
|
||||
@@ -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
|
||||
;;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user