diff --git a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua index ee5090815..5500ec94c 100644 --- a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua +++ b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua @@ -165,7 +165,7 @@ function wizard_add() ucic:delete("qos",intf) ucic:save("qos") ucic:commit("qos") - if defif ~= "" then + if defif ~= nil and defif ~= "" then luci.sys.call("uci -q del_list vnstat.@vnstat[-1].interface=" .. defif) end luci.sys.call("uci -q commit vnstat") @@ -498,7 +498,7 @@ function wizard_add() luci.sys.call("/etc/init.d/shadowsocks restart >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/glorytun restart >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/glorytun-udp restart >/dev/null 2>/dev/null") - luci.sys.call("/etc/init.d/mlvpn restart >/dev/null 2>/dev/null") + --luci.sys.call("/etc/init.d/mlvpn restart >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/openvpn restart >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/omr-tracker restart >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/omr-6in4 restart >/dev/null 2>/dev/null") @@ -1003,6 +1003,7 @@ function interfaces_status() local connectivity local multipath_state = "" + local current_multipath_state = "" if ifname ~= "" and ifname ~= nil then if fs.access("/sys/class/net/" .. ifname) then multipath_state = ut.trim(sys.exec("multipath " .. ifname .. " | grep deactivated")) @@ -1017,23 +1018,25 @@ function interfaces_status() else connectivity = "ERROR" end - local test_current_multipath_state = ut.trim(sys.exec("multipath " .. ifname)) - if string.find(test_current_multipath_state,"deactivated") then - current_multipath_state = "off" - elseif string.find(test_current_multipath_state,"default") then - current_multipath_state = "on" - elseif string.find(test_current_multipath_state,"backup") then - current_multipath_state = "backup" - elseif string.find(test_current_multipath_state,"handover") then - current_multipath_state = "handover" - else - current_multipath_state = "" + if ifname ~= "" and ifname ~= nil then + local test_current_multipath_state = ut.trim(sys.exec("multipath " .. ifname)) + if string.find(test_current_multipath_state,"deactivated") then + current_multipath_state = "off" + elseif string.find(test_current_multipath_state,"default") then + current_multipath_state = "on" + elseif string.find(test_current_multipath_state,"backup") then + current_multipath_state = "backup" + elseif string.find(test_current_multipath_state,"handover") then + current_multipath_state = "handover" + else + current_multipath_state = "" + end end - if ipaddr == "" and ifname ~= nil then + if ipaddr == "" and ifname ~= nil and ifname ~= "" 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 then + if ipaddr == "" and ifname ~= nil and ifname ~= "" 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 ipaddr == "" then diff --git a/luci-app-openmptcprouter/root/etc/init.d/openmptcprouter b/luci-app-openmptcprouter/root/etc/init.d/openmptcprouter index adfe48c34..99efc1082 100755 --- a/luci-app-openmptcprouter/root/etc/init.d/openmptcprouter +++ b/luci-app-openmptcprouter/root/etc/init.d/openmptcprouter @@ -9,6 +9,11 @@ USE_PROCD=1 omr_intf_del() { uci -q delete openmptcprouter.$1 } + +omr_intf_check() { + [ "$(uci -q get network.$1)" = "" ] && omr_intf_del $1 +} + omr_intf_set() { config_get multipath "$1" multipath config_get ifname "$1" ifname @@ -64,8 +69,8 @@ set_ipv6_state() { start_service() { local scaling_min_freq scaling_max_freq - #config_load openmptcprouter - #config_foreach omr_intf_del interface + config_load openmptcprouter + config_foreach omr_intf_check interface config_load network config_foreach omr_intf_set interface