mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Set device initial name
This commit is contained in:
parent
f6589d981e
commit
044cf9100d
1 changed files with 18 additions and 4 deletions
|
@ -21,12 +21,26 @@ omr_intf_set() {
|
|||
local multipath
|
||||
config_get multipath "$1" multipath
|
||||
config_get ifname "$1" ifname
|
||||
config_get device "$1" device
|
||||
config_get proto "$1" proto
|
||||
devicename=$(echo "$device" | cut -d'/' -f3)
|
||||
|
||||
[ -n "$ifname" ] && [ -L /sys/class/net/${ifname} ] && ([ "$proto" = "static" ] || [ "$proto" = "dhcp" ]) && {
|
||||
device=$(readlink -f /sys/class/net/${ifname})
|
||||
[ "$(echo ${device} | grep virtual)" = "" ] && uci -q set network.$1.device="$device"
|
||||
}
|
||||
if [ -n "$ifname" ] && [ -L /sys/class/net/${ifname} ]; then
|
||||
devicepath=$(readlink -f /sys/class/net/${ifname})
|
||||
if [ -n "$devicepath" ] && [ "$(echo ${devicepath} | grep virtual)" = "" ]; then
|
||||
uci -q set network.$1.modalias="$(cat /sys/class/net/${ifname}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')"
|
||||
uci -q set network.$1.product="$(cat /sys/class/net/${ifname}/device/uevent | grep PRODUCT | cut -d '=' -f2 | tr -d '\n')"
|
||||
elif [ -n "$devicepath" ] && [ "$(echo ${devicepath} | grep virtual)" != "" ]; then
|
||||
uci -q delete network.$1.device
|
||||
uci -q delete network.$1.modalias
|
||||
fi
|
||||
elif [ -n "$device" ] && [ -L /sys/bus/usb-serial/devices/${devicename} ]; then
|
||||
devicepath=$(readlink -f /sys/bus/usb-serial/devices/${devicename})
|
||||
[ -n "$devicepath" ] && {
|
||||
uci -q set network.$1.modalias="$(cat /sys/bus/usb-serial/devices/${devicename}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')"
|
||||
uci -q set network.$1.product="$(cat /sys/bus/usb-serial/devices/${devicename}/device/uevent | grep PRODUCT | cut -d '=' -f2 | tr -d '\n')"
|
||||
}
|
||||
fi
|
||||
|
||||
[ -z "$multipath" ] || [ "$multipath" = "off" ] && [ "$1" != "omrvpn" ] && [ "$1" != "glorytun" ] && return
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue