mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-27 19:23:24 +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 ))"
|
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() {
|
import_aws_configuration() {
|
||||||
local instance_id="$(get meta-data/instance-id)"
|
local instance_id="$(get meta-data/instance-id)"
|
||||||
|
|
||||||
@@ -243,19 +227,13 @@ import_aws_configuration() {
|
|||||||
) >> /var/ipfire/ethernet/settings
|
) >> /var/ipfire/ethernet/settings
|
||||||
;;
|
;;
|
||||||
esac
|
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
|
done
|
||||||
|
|
||||||
# Save CONFIG_TYPE
|
# Save CONFIG_TYPE
|
||||||
echo "CONFIG_TYPE=${config_type}" >> /var/ipfire/ethernet/settings
|
echo "CONFIG_TYPE=${config_type}" >> /var/ipfire/ethernet/settings
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Actions performed only on the very first start
|
# Actions performed only on the very first start
|
||||||
if [ ! -e "/var/ipfire/main/firstsetup_ok" ]; then
|
if [ ! -e "/var/ipfire/main/firstsetup_ok" ]; then
|
||||||
# Enable SSH
|
# Enable SSH
|
||||||
@@ -322,6 +300,9 @@ case "${reason}" in
|
|||||||
|
|
||||||
# Remove all IP addresses
|
# Remove all IP addresses
|
||||||
ip addr flush dev "${interface}"
|
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
|
# End DHCP client immediately
|
||||||
dhclient -sf /etc/rc.d/helper/aws-setup -r "${intf}" &>/dev/null
|
dhclient -sf /etc/rc.d/helper/aws-setup -r "${intf}" &>/dev/null
|
||||||
|
|
||||||
|
# Rename network devices
|
||||||
|
udevadm trigger --action="add" --subsystem-match="net"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user