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

Merge branch 'test' into develop

This commit is contained in:
suyuan 2021-01-30 01:12:27 +08:00
commit 510a9df2d7
15 changed files with 192 additions and 93 deletions

View file

@ -20,17 +20,22 @@ _set_intf_name() {
fi
[ -n "$modalias" ] && {
if [ -f /sys/class/net/${INTERFACE}/device/uevent ]; then
mac=""
if [ -f /sys/class/net/${INTERFACE}/address ]; then
mac="$(cat /sys/class/net/${INTERFACE}/address | tr -d '\n')"
fi
chk_modalias=$MODALIAS
[ -z "$chk_modalias" ] && chk_modalias="$(cat /sys/class/net/${INTERFACE}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')"
if [ -n "$chk_modalias" ]; then
chk_modalias="${chk_modalias}-${mac}"
logger -t "OMR-Rename" "modalias: $modalias - chk_modalias: $chk_modalias - ifname: $ifname - INTERFACE: $INTERFACE"
if [ "$modalias" = "$chk_modalias" ] && [ "$INTERFACE" != "$ifname" ]; then
logger -t "OMR-Rename" "Rename ${INTERFACE} to ${ifname}"
existif=0
existif="0"
ip link set ${INTERFACE} down 2>&1 >/dev/null
[ "$(ip link show ${ifname} 2>/dev/null)" != "" ] && {
ip link set ${ifname} name ${ifname}tmp 2>&1 >/dev/null
existif=1
existif="1"
}
ip link set ${INTERFACE} name ${ifname} 2>&1 >/dev/null
ip link set ${ifname} up 2>&1 >/dev/null
@ -48,10 +53,10 @@ _set_intf_name() {
logger -t "OMR-Rename" "device: $device - devpath: $DEVPATH - ifname: $ifname - INTERFACE: $INTERFACE"
logger -t "OMR-Rename" "Rename ${INTERFACE} to ${ifname}"
ip link set ${INTERFACE} down 2>&1 >/dev/null
existif=0
existif="0"
[ "$(ip link show ${ifname} 2>/dev/null)" != "" ] && {
ip link set ${ifname} name ${ifname}tmp 2>&1 >/dev/null
existif=1
existif="1"
}
ip link set ${INTERFACE} name ${ifname} 2>&1 >/dev/null
ip link set ${ifname} up 2>&1 >/dev/null
@ -62,5 +67,5 @@ _set_intf_name() {
if [ "$(uci -q get openmptcprouter.settings.disableintfrename)" != "1" ]; then
config_load network
config_foreach _set_intf_name interface
config_foreach _set_intf_name interface
# config_foreach _set_intf_name interface
fi

View file

@ -27,7 +27,11 @@ omr_intf_set() {
if [ "$type" != "macvlan" ] && [ -n "$ifname" ] && [ -f /sys/class/net/${ifname}/device/uevent ]; then
devicepath=$(readlink -f /sys/class/net/${ifname})
if [ -n "$devicepath" ] && [ "$(echo ${devicepath} | grep virtual)" = "" ] && [ "$(cat /sys/class/net/${ifname}/device/uevent | grep PRODUCT)" != "" ] && [ "$(cat /sys/class/net/${ifname}/device/uevent | grep PCI_SLOT_NAME)" = "" ]; then
uci -q set network.$1.modalias="$(cat /sys/class/net/${ifname}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')"
mac=""
if [ -f /sys/class/net/${ifname}/address ]; then
mac="$(cat /sys/class/net/${ifname}/address | tr -d '\n')"
fi
uci -q set network.$1.modalias="$(cat /sys/class/net/${ifname}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')-$mac"
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)" != "" ] || [ "$(echo ${devicepath} | grep virtual)" = "" ] && [ "$(cat /sys/class/net/${ifname}/device/uevent | grep PRODUCT)" = "" ] || [ "$(cat /sys/class/net/${ifname}/device/uevent | grep PCI_SLOT_NAME)" != "" ] || [ "$(cat /sys/class/net/${ifname}tmp/device/uevent)" != "" ]); then
uci -q delete network.$1.device
@ -35,7 +39,11 @@ omr_intf_set() {
uci -q delete network.$1.product
fi
elif [ "$type" != "macvlan" ] && [ -n "$device" ] && [ -f /sys/bus/usb-serial/devices/${devicename}/device/uevent ] && [ "$(cat /sys/class/net/${ifname}/device/uevent | grep PRODUCT)" != "" ]; then
uci -q set network.$1.modalias="$(cat /sys/bus/usb-serial/devices/${devicename}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')"
mac=""
if [ -f /sys/class/net/${ifname}/address ]; then
mac="$(cat /sys/class/net/${ifname}/address | tr -d '\n')"
fi
uci -q set network.$1.modalias="$(cat /sys/bus/usb-serial/devices/${devicename}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')-$mac"
uci -q set network.$1.product="$(cat /sys/bus/usb-serial/devices/${devicename}/device/uevent | grep PRODUCT | cut -d '=' -f2 | tr -d '\n')"
else
uci -q delete network.$1.modalias

View file

@ -1115,6 +1115,7 @@ function interfaces_status()
local gateway6 = section["ip6gw"] or ""
local multipath = section["multipath"]
local enabled = section["auto"]
local proto = section["proto"] or ""
--if not ipaddr or not gateway then return end
-- Don't show if0 in the overview
@ -1130,7 +1131,7 @@ function interfaces_status()
duplicateif = false
if ifname ~= "" and ifname ~= nil then
if allintf[ifname] then
if allintf[ifname] and not section["ifname"]:match("^@.*") then
connectivity = "ERROR"
duplicateif = true
else
@ -1144,10 +1145,10 @@ function interfaces_status()
if enabled == "0" then return end
local connectivity = "OK"
if ipaddr == "" and ifname ~= nil and ifname ~= "" then
if ipaddr == "" and ifname ~= nil and ifname ~= "" and proto ~= "dhcpv6" then
ipaddr = ut.trim(sys.exec("ip -4 -br addr ls dev " .. ifname .. " | awk -F'[ /]+' '{print $3}' | tr -d '\n'"))
end
if ipaddr == "" and ifname ~= nil and ifname ~= "" then
if ipaddr == "" and ifname ~= nil and ifname ~= "" and proto ~= "dhcpv6" then
ipaddr = ut.trim(sys.exec("ip -4 addr show dev " .. ifname .. " | grep -m 1 inet | awk '{print $2}' | cut -d'/' -s -f1 | tr -d '\n'"))
end
if ip6addr == "" and ifname ~= nil and ifname ~= "" then
@ -1195,14 +1196,16 @@ function interfaces_status()
local gw_ping = "UP"
local gw_ping6 = "UP"
if ifname ~= nil and not (ifname:match("^tun.*") or interface:match("^ovpn.*")) then
gateway = ut.trim(sys.exec("ip -4 r list dev " .. ifname .. " | grep via | grep -v default | grep -v metric | awk '{print $1}' | tr -d '\n'"))
if proto ~= "dhcpv6" then
gateway = ut.trim(sys.exec("ip -4 r list dev " .. ifname .. " | grep via | grep -v default | grep -v metric | awk '{print $1}' | tr -d '\n'"))
end
gateway6 = ut.trim(sys.exec("ip -6 r list dev " .. ifname .. " | grep via | grep -v default | grep -v metric | awk '{print $1}' | tr -d '\n'"))
end
if gateway == "" then
if gateway == "" and proto ~= "dhcpv6" then
gateway = get_gateway(interface)
end
if gateway == "" and ifname ~= nil and ifname ~= "" then
if gateway == "" and ifname ~= nil and ifname ~= "" and proto ~= "dhcpv6" then
if fs.access("/sys/class/net/" .. ifname) then
gateway = ut.trim(sys.exec("ip -4 r list dev " .. ifname .. " | grep kernel | awk '/proto kernel/ {print $1}' | grep -v / | tr -d '\n'"))
if gateway == "" then
@ -1263,7 +1266,7 @@ function interfaces_status()
end
if ifname ~= "" and ifname ~= nil then
local proto = section['proto']
--local proto = section['proto']
if proto == "qmi" then
local device = section['device']
intfdata = ut.trim(sys.exec("omr-qmi " .. device .. " all"))
@ -1438,6 +1441,7 @@ function interfaces_status()
phonenumber = phonenumber,
donglestate = donglestate,
networktype = networktype,
proto = proto,
rx = rx,
tx = tx,
}