diff --git a/luci-app-openmptcprouter/root/etc/init.d/openmptcprouter b/luci-app-openmptcprouter/root/etc/init.d/openmptcprouter index 0632b6ee2..077fcc8bb 100755 --- a/luci-app-openmptcprouter/root/etc/init.d/openmptcprouter +++ b/luci-app-openmptcprouter/root/etc/init.d/openmptcprouter @@ -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