1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-13 11:01:50 +00:00
openmptcprouter-feeds/luci-app-openmptcprouter/root/etc/hotplug.d/net/99-omr-rename
2020-07-03 19:12:42 +02:00

25 lines
687 B
Bash

#!/bin/sh
# Copyright (C) 2020 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> for OpenMPTCProuter
[ "$ACTION" = "add" ] || exit
[ -n "${INTERFACE}" ] || exit
[ -n "${DEVPATH}" ] || exit
. /lib/functions.sh
_set_intf_name() {
local intfname=$1
local device
local ifname
config_get device $intfname device
config_get ifname $intfname ifname
[ -n "$device" ] && [ -n "$ifname" ] && [ "/sys${DEVPATH}" = "$device" ] && [ "$INTERFACE" != "$ifname" ] && {
logger -t "OMR-Rename" "Rename ${INTERFACE} to ${ifname}"
ip link set ${INTERFACE} down
ip link set ${INTERFACE} name ${ifname}
ip link set ${ifname} up
}
}
config_load network
config_foreach _set_intf_name interface