1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-15 03:51:51 +00:00

Fix rename interfaces

This commit is contained in:
Ycarus (Yannick Chabanois) 2020-11-03 21:33:09 +01:00 committed by suyuan
parent 18b04d3218
commit 18565f869f

View file

@ -16,22 +16,23 @@ _set_intf_name() {
config_get ifname $intfname ifname config_get ifname $intfname ifname
[ -n "$modalias" ] && { [ -n "$modalias" ] && {
if [ -f /sys/class/net/${INTERFACE}/device/uevent ]; then if [ -f /sys/class/net/${INTERFACE}/device/uevent ]; then
#chk_modalias="$(cat /sys/class/net/${INTERFACE}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')"
chk_modalias=$MODALIAS chk_modalias=$MODALIAS
logger -t "OMR-Rename" "dir: $i - modalias: $modalias - chk_modalias: $chk_modalias - ifname: $ifname - INTERFACE: $INTERFACE" [ -z "$chk_modalias" ] && chk_modalias="$(cat /sys/class/net/${INTERFACE}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')"
if [ "$modalias" = "$chk_modalias" ] && [ "$INTERFACE" != "$ifname" ]; then if [ -n "$chk_modalias" ]; then
logger -t "OMR-Rename" "Rename ${INTERFACE} to ${ifname}" logger -t "OMR-Rename" "dir: $i - modalias: $modalias - chk_modalias: $chk_modalias - ifname: $ifname - INTERFACE: $INTERFACE"
existif=0 if [ "$modalias" = "$chk_modalias" ] && [ "$INTERFACE" != "$ifname" ]; then
ip link set ${INTERFACE} down logger -t "OMR-Rename" "Rename ${INTERFACE} to ${ifname}"
[ "$(ip link show ${ifname} 2>/dev/null)" != "" ] && { existif=0
ip link set ${ifname} name ${ifname}tmp ip link set ${INTERFACE} down
existif=1 [ "$(ip link show ${ifname} 2>/dev/null)" != "" ] && {
} ip link set ${ifname} name ${ifname}tmp
ip link set ${INTERFACE} name ${ifname} existif=1
ip link set ${ifname} up }
[ "$existif" = "1" ] && ip link set ${ifname}tmp ${$INTERFACE} ip link set ${INTERFACE} name ${ifname}
fi ip link set ${ifname} up
elif [ -f /dev/${DEVICE_NAME} ] && [ "$modalias" = "$MODALIAS" ]; then [ "$existif" = "1" ] && ip link set ${ifname}tmp ${$INTERFACE}
fi
elif [ -f /dev/${DEVICE_NAME} ] && [ -n "$MODALIAS" ] && [ "$modalias" = "$MODALIAS" ]; then
if [ "$device" != "/dev/${DEVICE_NAME}" ]; then if [ "$device" != "/dev/${DEVICE_NAME}" ]; then
ln -s /dev/${DEVICE_NAME} /dev/$intfname ln -s /dev/${DEVICE_NAME} /dev/$intfname
uci -q set network.${intfname}.device="/dev/${intfname}" uci -q set network.${intfname}.device="/dev/${intfname}"