]>
git.ipfire.org Git - ipfire-2.x.git/blob - config/udev/network-hotplug-rename
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2015 IPFire Team <info@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 .
/etc
/rc.d
/init.d
/networking
/functions.network
24 # Check if all appropriate variables are set
25 [ -n "${INTERFACE}" ] ||
exit 2
27 # Ignore virtual interfaces, etc.
28 case "${INTERFACE}" in
40 # Check if INTERFACE actually exists
41 [ -d "/sys/class/net/${INTERFACE}" ] ||
exit 1
43 # If the network configuration is not readable,
45 if [ ! -r "/var/ipfire/ethernet/settings" ]; then
49 # Change MAC addresses of QMI interface
50 if [ -d "/sys/class/net/${INTERFACE}/qmi" ]; then
51 if ! qmi_assign_address
"${INTERFACE}"; then
56 # Read network settings
57 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/ethernet
/settings
)
60 ZONES
="RED GREEN ORANGE BLUE"
62 # Determine the address of INTERFACE
63 ADDRESS
="$(</sys/class/net/${INTERFACE}/address)"
65 # Walk through all zones and find the matching interface
66 for zone
in ${ZONES}; do
67 address
="${zone}_MACADDR"
70 slaves
="${zone}_SLAVES"
72 # Return DEV when the address matches
73 if [ "${!address,,}" = "${ADDRESS,,}" ]; then
78 # If a matching interface has been found we will
79 # print the name to which udev will rename it.
83 for slave
in ${!slaves}; do
84 if [ "${slave,,}" = "${ADDRESS,,}" ]; then
85 echo "${!device}p${counter}"
93 # If we get here we have not found a matching device,
94 # but we won't return an error any way. The new device
95 # will remain with the previous name.