mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Use network_get_device to get device
This commit is contained in:
parent
ec6cdb8209
commit
18a6613650
5 changed files with 62 additions and 28 deletions
|
@ -501,9 +501,9 @@ _intf_rule_v2ray_rules() {
|
||||||
|
|
||||||
_intf_rule() {
|
_intf_rule() {
|
||||||
local intf
|
local intf
|
||||||
config_get intf $1 ifname
|
intf=$(ifstatus "$1" | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$intf" ] && intf=$(ifstatus "$1" | jsonfilter -q -e '@["l3_device"]')
|
|
||||||
[ -n "$(echo $intf | grep '@')" ] && intf=$(ifstatus "$1" | jsonfilter -q -e '@["device"]')
|
[ -n "$(echo $intf | grep '@')" ] && intf=$(ifstatus "$1" | jsonfilter -q -e '@["device"]')
|
||||||
|
[ -z "$intf" ] && config_get intf $1 device
|
||||||
#count=$((count+1))
|
#count=$((count+1))
|
||||||
config_get count $1 metric
|
config_get count $1 metric
|
||||||
local mode
|
local mode
|
||||||
|
|
|
@ -6,6 +6,8 @@ START=5
|
||||||
|
|
||||||
USE_PROCD=1
|
USE_PROCD=1
|
||||||
|
|
||||||
|
. /lib/functions/network.sh
|
||||||
|
|
||||||
omr_intf_del() {
|
omr_intf_del() {
|
||||||
[ -z "$1" ] && return
|
[ -z "$1" ] && return
|
||||||
uci -q delete openmptcprouter.$1
|
uci -q delete openmptcprouter.$1
|
||||||
|
@ -18,12 +20,14 @@ omr_intf_check() {
|
||||||
omr_intf_set() {
|
omr_intf_set() {
|
||||||
local device
|
local device
|
||||||
local ifname
|
local ifname
|
||||||
config_get ifname "$1" device
|
network_get_device ifname $1
|
||||||
|
[ -z "$ifname" ] && network_get_physdev ifname $1
|
||||||
|
[ -z "$ifname" ] && config_get ifname "$1" device
|
||||||
[ -z "$ifname" ] && config_get ifname "$1" ifname
|
[ -z "$ifname" ] && config_get ifname "$1" ifname
|
||||||
config_get devicename "$1" _modem_device
|
|
||||||
config_get type "$1" type
|
|
||||||
|
|
||||||
[ -z "$ifname" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["l3_device"]')
|
[ -z "$ifname" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["l3_device"]')
|
||||||
|
#config_get devicename "$1" _modem_device
|
||||||
|
devicename=${ifname}
|
||||||
|
config_get type "$1" type
|
||||||
|
|
||||||
if [ "$type" != "macvlan" ] && [ -n "$ifname" ] && [ -f /sys/class/net/${ifname}/device/uevent ]; then
|
if [ "$type" != "macvlan" ] && [ -n "$ifname" ] && [ -f /sys/class/net/${ifname}/device/uevent ]; then
|
||||||
devicepath=$(readlink -f /sys/class/net/${ifname})
|
devicepath=$(readlink -f /sys/class/net/${ifname})
|
||||||
|
@ -57,7 +61,9 @@ omr_set_settings() {
|
||||||
local ifname
|
local ifname
|
||||||
local multipath
|
local multipath
|
||||||
config_get multipath "$1" multipath
|
config_get multipath "$1" multipath
|
||||||
config_get ifname "$1" device
|
network_get_device ifname $1
|
||||||
|
[ -z "$ifname" ] && network_get_physdev ifname $1
|
||||||
|
[ -z "$ifname" ] && config_get ifname "$1" device
|
||||||
[ -z "$ifname" ] && config_get ifname "$1" ifname
|
[ -z "$ifname" ] && config_get ifname "$1" ifname
|
||||||
config_get device "$1" device
|
config_get device "$1" device
|
||||||
config_get proto "$1" proto
|
config_get proto "$1" proto
|
||||||
|
|
|
@ -85,7 +85,9 @@ interface_multipath_settings() {
|
||||||
local enabled
|
local enabled
|
||||||
|
|
||||||
config_get enabled "$config" auto "1"
|
config_get enabled "$config" auto "1"
|
||||||
config_get iface "$config" device
|
network_get_device iface $config
|
||||||
|
[ -z "$iface" ] && network_get_physdev iface $config
|
||||||
|
[ -z "$iface" ] && config_get iface "$config" device
|
||||||
[ -z "$iface" ] && config_get iface "$config" ifname
|
[ -z "$iface" ] && config_get iface "$config" ifname
|
||||||
config_get txqueuelen "$config" txqueuelen
|
config_get txqueuelen "$config" txqueuelen
|
||||||
[ -z "$iface" ] && iface=$(ifstatus "$config" | jsonfilter -q -e '@["l3_device"]')
|
[ -z "$iface" ] && iface=$(ifstatus "$config" | jsonfilter -q -e '@["l3_device"]')
|
||||||
|
@ -350,7 +352,9 @@ interface_multipath_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
load_interfaces() {
|
load_interfaces() {
|
||||||
config_get ifname "$1" device
|
network_get_device ifname $1
|
||||||
|
[ -z "$ifname" ] && network_get_physdev ifname $1
|
||||||
|
[ -z "$ifname" ] && config_get ifname "$1" device
|
||||||
[ -z "$ifname" ] && config_get ifname "$1" ifname
|
[ -z "$ifname" ] && config_get ifname "$1" ifname
|
||||||
config_get multipath "$1" multipath ""
|
config_get multipath "$1" multipath ""
|
||||||
[ -z "$multipath" ] && multipath="$(uci -q get openmptcprouter.$1.multipath)"
|
[ -z "$multipath" ] && multipath="$(uci -q get openmptcprouter.$1.multipath)"
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
SETROUTE=false
|
SETROUTE=false
|
||||||
|
|
||||||
|
. /lib/functions/network.sh
|
||||||
|
|
||||||
set_route() {
|
set_route() {
|
||||||
local multipath_config_route interface_gw interface_if
|
local multipath_config_route interface_gw interface_if
|
||||||
INTERFACE=$1
|
INTERFACE=$1
|
||||||
|
@ -12,8 +14,9 @@ set_route() {
|
||||||
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
|
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
|
||||||
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${INTERFACE}.multipath || echo "off")"
|
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${INTERFACE}.multipath || echo "off")"
|
||||||
}
|
}
|
||||||
interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
network_get_device interface_if $INTERFACE
|
||||||
interface_up=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
|
interface_up=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
|
||||||
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.device)
|
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.device)
|
||||||
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
|
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
|
||||||
|
@ -50,8 +53,9 @@ set_route6() {
|
||||||
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
|
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
|
||||||
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${INTERFACE}.multipath || echo "off")"
|
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${INTERFACE}.multipath || echo "off")"
|
||||||
}
|
}
|
||||||
interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
network_get_device interface_if $INTERFACE
|
||||||
interface_up=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
|
interface_up=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
|
||||||
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.device)
|
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.device)
|
||||||
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
|
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
|
||||||
|
@ -165,7 +169,8 @@ set_routes_intf() {
|
||||||
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
|
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
|
||||||
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${INTERFACE}.multipath || echo "off")"
|
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${INTERFACE}.multipath || echo "off")"
|
||||||
}
|
}
|
||||||
interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
network_get_device interface_if $INTERFACE
|
||||||
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.device)
|
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.device)
|
||||||
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
|
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
|
||||||
|
@ -220,7 +225,8 @@ set_routes_intf6() {
|
||||||
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
|
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
|
||||||
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${INTERFACE}.multipath || echo "off")"
|
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${INTERFACE}.multipath || echo "off")"
|
||||||
}
|
}
|
||||||
interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
network_get_device interface_if $INTERFACE
|
||||||
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_6" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_6" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.device)
|
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.device)
|
||||||
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
|
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
|
||||||
|
@ -291,7 +297,8 @@ set_route_balancing() {
|
||||||
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
|
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
|
||||||
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${INTERFACE}.multipath || echo "off")"
|
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${INTERFACE}.multipath || echo "off")"
|
||||||
}
|
}
|
||||||
interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
network_get_device interface_if $INTERFACE
|
||||||
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.device)
|
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.device)
|
||||||
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
|
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
|
||||||
|
@ -340,7 +347,8 @@ set_route_balancing6() {
|
||||||
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
|
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
|
||||||
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${INTERFACE}.multipath || echo "off")"
|
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${INTERFACE}.multipath || echo "off")"
|
||||||
}
|
}
|
||||||
interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
network_get_device interface_if $INTERFACE
|
||||||
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.device)
|
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.device)
|
||||||
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
|
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
|
||||||
|
@ -404,7 +412,8 @@ set_server_all_routes() {
|
||||||
[ -n "$serverip" ] && serverip="$(resolveip -4 -t 5 $serverip | head -n 1 | tr -d '\n')"
|
[ -n "$serverip" ] && serverip="$(resolveip -4 -t 5 $serverip | head -n 1 | tr -d '\n')"
|
||||||
config_get disabled $server disabled
|
config_get disabled $server disabled
|
||||||
[ "$disabled" = "1" ] && return
|
[ "$disabled" = "1" ] && return
|
||||||
interface_if=$(uci -q get network.$OMR_TRACKER_INTERFACE.device)
|
network_get_device interface_if $OMR_TRACKER_INTERFACE
|
||||||
|
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$OMR_TRACKER_INTERFACE.device)
|
||||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "${OMR_TRACKER_INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "${OMR_TRACKER_INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" | jsonfilter -q -e '@["device"]')
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" | jsonfilter -q -e '@["device"]')
|
||||||
|
@ -450,7 +459,8 @@ set_server_all_routes6() {
|
||||||
[ -n "$serverip" ] && serverip="$(resolveip -6 -t 5 $serverip | head -n 1 | tr -d '\n')"
|
[ -n "$serverip" ] && serverip="$(resolveip -6 -t 5 $serverip | head -n 1 | tr -d '\n')"
|
||||||
config_get disabled $server disabled
|
config_get disabled $server disabled
|
||||||
[ "$disabled" = "1" ] && return
|
[ "$disabled" = "1" ] && return
|
||||||
interface_if=$(uci -q get network.$OMR_TRACKER_INTERFACE.device)
|
network_get_device interface_if $OMR_TRACKER_INTERFACE
|
||||||
|
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$OMR_TRACKER_INTERFACE.device)
|
||||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "${OMR_TRACKER_INTERFACE}_6" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "${OMR_TRACKER_INTERFACE}_6" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" | jsonfilter -q -e '@["device"]')
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" | jsonfilter -q -e '@["device"]')
|
||||||
|
@ -505,7 +515,8 @@ set_server_route() {
|
||||||
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
|
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
|
||||||
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
|
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
|
||||||
}
|
}
|
||||||
interface_if=$(uci -q get network.$OMR_TRACKER_INTERFACE.device)
|
network_get_device interface_if $OMR_TRACKER_INTERFACE
|
||||||
|
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$OMR_TRACKER_INTERFACE.device)
|
||||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "${OMR_TRACKER_INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "${OMR_TRACKER_INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" | jsonfilter -q -e '@["device"]')
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" | jsonfilter -q -e '@["device"]')
|
||||||
|
@ -541,7 +552,8 @@ set_server_route6() {
|
||||||
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
|
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
|
||||||
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
|
[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
|
||||||
}
|
}
|
||||||
interface_if=$(uci -q get network.$OMR_TRACKER_INTERFACE.device)
|
network_get_device interface_if $OMR_TRACKER_INTERFACE
|
||||||
|
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$OMR_TRACKER_INTERFACE.device)
|
||||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "${OMR_TRACKER_INTERFACE}_6" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "${OMR_TRACKER_INTERFACE}_6" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" | jsonfilter -q -e '@["device"]')
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" | jsonfilter -q -e '@["device"]')
|
||||||
|
@ -660,7 +672,7 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ] || [ "$interface_up" != "true" ]; then
|
||||||
sleep 5
|
sleep 5
|
||||||
_log "Set $OMR_TRACKER_INTERFACE up"
|
_log "Set $OMR_TRACKER_INTERFACE up"
|
||||||
ifup $OMR_TRACKER_INTERFACE
|
ifup $OMR_TRACKER_INTERFACE
|
||||||
sleep 10
|
sleep 20
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$OMR_TRACKER_PREV_STATUS" = "$OMR_TRACKER_STATUS" ]; then
|
if [ "$OMR_TRACKER_PREV_STATUS" = "$OMR_TRACKER_STATUS" ]; then
|
||||||
|
@ -905,8 +917,8 @@ multipath_config=$(uci -q get "openmtpcprouter.$OMR_TRACKER_INTERFACE.multipath"
|
||||||
if [ "$multipath_config" = "master" ]; then
|
if [ "$multipath_config" = "master" ]; then
|
||||||
#if ([ "$default_gw" != "$OMR_TRACKER_DEVICE_GATEWAY" ] || [ "$default_gw" = "" ]) && [ "$OMR_TRACKER_DEVICE_GATEWAY" != "" ] && ([ "$(uci -q get openmptcprouter.settings.master)" != "balancing" ] || [ "$(uci -q get openmptcprouter.settings.vpn)" = "mlvpn" ]); then
|
#if ([ "$default_gw" != "$OMR_TRACKER_DEVICE_GATEWAY" ] || [ "$default_gw" = "" ]) && [ "$OMR_TRACKER_DEVICE_GATEWAY" != "" ] && ([ "$(uci -q get openmptcprouter.settings.master)" != "balancing" ] || [ "$(uci -q get openmptcprouter.settings.vpn)" = "mlvpn" ]); then
|
||||||
if ([ "$default_gw" != "$OMR_TRACKER_DEVICE_GATEWAY" ] || [ "$default_gw" = "" ]) && [ "$OMR_TRACKER_DEVICE_GATEWAY" != "" ] && [ "$(uci -q get openmptcprouter.settings.master)" != "balancing" ]; then
|
if ([ "$default_gw" != "$OMR_TRACKER_DEVICE_GATEWAY" ] || [ "$default_gw" = "" ]) && [ "$OMR_TRACKER_DEVICE_GATEWAY" != "" ] && [ "$(uci -q get openmptcprouter.settings.master)" != "balancing" ]; then
|
||||||
omrvpn_intf=$(uci -q get "network.omrvpn.device" || echo "tun")
|
omrvpn_intf=$(uci -q get "network.omrvpn.device" || echo "tun0")
|
||||||
[ -z "$omrvpn_intf" ] && omrvpn_intf=$(uci -q get "network.omrvpn.ifname" || echo "tun")
|
[ -z "$omrvpn_intf" ] && omrvpn_intf=$(uci -q get "network.omrvpn.ifname" || echo "tun0")
|
||||||
if [ -n "$omrvpn_intf" ] && [ "$(ip route show default | awk '/default/ {print $5}' | grep $omrvpn_intf)" = "" ] && [ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ]; then
|
if [ -n "$omrvpn_intf" ] && [ "$(ip route show default | awk '/default/ {print $5}' | grep $omrvpn_intf)" = "" ] && [ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ]; then
|
||||||
_log "Master up : Replace default route by $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE"
|
_log "Master up : Replace default route by $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE"
|
||||||
ip route replace default scope global nexthop via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE 2>&1 >/dev/null
|
ip route replace default scope global nexthop via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE 2>&1 >/dev/null
|
||||||
|
@ -919,8 +931,8 @@ if [ "$multipath_config" = "master" ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if ([ "$default_gw6" != "$OMR_TRACKER_DEVICE_GATEWAY6" ] || [ "$default_gw6" = "" ]) && [ "$OMR_TRACKER_DEVICE_GATEWAY6" != "" ] && [ "$(uci -q get openmptcprouter.settings.master)" != "balancing" ]; then
|
if ([ "$default_gw6" != "$OMR_TRACKER_DEVICE_GATEWAY6" ] || [ "$default_gw6" = "" ]) && [ "$OMR_TRACKER_DEVICE_GATEWAY6" != "" ] && [ "$(uci -q get openmptcprouter.settings.master)" != "balancing" ]; then
|
||||||
omrvpn_intf=$(uci -q get "network.omrvpn.device" || echo "tun")
|
omrvpn_intf=$(uci -q get "network.omrvpn.device" || echo "tun0")
|
||||||
[ -z "$omrvpn_intf" ] && omrvpn_intf=$(uci -q get "network.omrvpn.ifname" || echo "tun")
|
[ -z "$omrvpn_intf" ] && omrvpn_intf=$(uci -q get "network.omrvpn.ifname" || echo "tun0")
|
||||||
if [ -n "$omrvpn_intf" ] && [ "$(ip route show default | awk '/default/ {print $5}' | grep $omrvpn_intf)" = "" ] && [ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ]; then
|
if [ -n "$omrvpn_intf" ] && [ "$(ip route show default | awk '/default/ {print $5}' | grep $omrvpn_intf)" = "" ] && [ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ]; then
|
||||||
_log "Master up : Replace default route by $OMR_TRACKER_DEVICE_GATEWAY6 dev $OMR_TRACKER_DEVICE"
|
_log "Master up : Replace default route by $OMR_TRACKER_DEVICE_GATEWAY6 dev $OMR_TRACKER_DEVICE"
|
||||||
ip -6 route replace default scope global nexthop via $OMR_TRACKER_DEVICE_GATEWAY6 dev $OMR_TRACKER_DEVICE 2>&1 >/dev/null
|
ip -6 route replace default scope global nexthop via $OMR_TRACKER_DEVICE_GATEWAY6 dev $OMR_TRACKER_DEVICE 2>&1 >/dev/null
|
||||||
|
@ -935,8 +947,8 @@ if [ "$multipath_config" = "master" ]; then
|
||||||
fi
|
fi
|
||||||
#if [ "$(uci -q get openmptcprouter.settings.master)" = "balancing" ] && [ "$(ip route show default | grep weight)" = "" ] && [ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ] && [ "$(uci -q get openmptcprouter.settings.vpn)" != "mlvpn" ]; then
|
#if [ "$(uci -q get openmptcprouter.settings.master)" = "balancing" ] && [ "$(ip route show default | grep weight)" = "" ] && [ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ] && [ "$(uci -q get openmptcprouter.settings.vpn)" != "mlvpn" ]; then
|
||||||
if [ "$(uci -q get openmptcprouter.settings.master)" = "balancing" ] && [ "$(ip route show default | grep weight)" = "" ] && [ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ]; then
|
if [ "$(uci -q get openmptcprouter.settings.master)" = "balancing" ] && [ "$(ip route show default | grep weight)" = "" ] && [ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ]; then
|
||||||
omrvpn_intf=$(uci -q get "network.omrvpn.device" || echo "tun")
|
omrvpn_intf=$(uci -q get "network.omrvpn.device" || echo "tun0")
|
||||||
[ -z "$omrvpn_intf" ] && omrvpn_intf=$(uci -q get "network.omrvpn.ifname" || echo "tun")
|
[ -z "$omrvpn_intf" ] && omrvpn_intf=$(uci -q get "network.omrvpn.ifname" || echo "tun0")
|
||||||
if [ -n "$omrvpn_intf" ] && [ "$(ip route show default | awk '/default/ {print $5}' | grep $omrvpn_intf)" = "" ]; then
|
if [ -n "$omrvpn_intf" ] && [ "$(ip route show default | awk '/default/ {print $5}' | grep $omrvpn_intf)" = "" ]; then
|
||||||
routesbalancing=""
|
routesbalancing=""
|
||||||
routesbalancingbackup=""
|
routesbalancingbackup=""
|
||||||
|
@ -1408,6 +1420,12 @@ if [ "$(pgrep rpcd)" = "" ] && [ -f /etc/init.d/rpcd ]; then
|
||||||
sleep 5
|
sleep 5
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$(pgrep uhttpd)" = "" ] && [ -f /etc/init.d/uhttpd ]; then
|
||||||
|
_log "Can't find uhttpd, restart it..."
|
||||||
|
/etc/init.d/uhttpd restart
|
||||||
|
sleep 5
|
||||||
|
fi
|
||||||
|
|
||||||
#if [ "$(pgrep ModemManager)" = "" ] && [ -f /etc/init.d/modemmanager ] && [ -n "$(uci -q show network | grep modemmanager)" ] && [ "$(uci -q get openmptcprouter.settings.modemmanager)" != "0" ]; then
|
#if [ "$(pgrep ModemManager)" = "" ] && [ -f /etc/init.d/modemmanager ] && [ -n "$(uci -q show network | grep modemmanager)" ] && [ "$(uci -q get openmptcprouter.settings.modemmanager)" != "0" ]; then
|
||||||
# _log "Can't find ModemManager, restart it..."
|
# _log "Can't find ModemManager, restart it..."
|
||||||
# /etc/init.d/modemmanager restart
|
# /etc/init.d/modemmanager restart
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
# shellcheck disable=SC2039
|
# shellcheck disable=SC2039
|
||||||
# vim: set noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 :
|
# vim: set noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 :
|
||||||
# Copyright (C) 2018 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
|
# Copyright (C) 2018-2021 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
|
||||||
# Released under GPL 3. See LICENSE for the full terms.
|
# Released under GPL 3. See LICENSE for the full terms.
|
||||||
|
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
. /usr/lib/unbound/iptools.sh
|
. /usr/lib/unbound/iptools.sh
|
||||||
|
. /lib/functions/network.sh
|
||||||
|
|
||||||
_validate_section() {
|
_validate_section() {
|
||||||
local tmp_hosts=$hosts tmp_hosts6=$hosts6 tmp_timeout=$timeout tmp_tries=$tries
|
local tmp_hosts=$hosts tmp_hosts6=$hosts6 tmp_timeout=$timeout tmp_tries=$tries
|
||||||
|
@ -53,7 +54,9 @@ _launch_tracker() {
|
||||||
_validate_section "interface" "$1"
|
_validate_section "interface" "$1"
|
||||||
|
|
||||||
local ifname ip4table
|
local ifname ip4table
|
||||||
ifname=$(ifstatus "$1" | jsonfilter -q -e '@["l3_device"]')
|
network_get_device ifname $1
|
||||||
|
[ -z "$ifname" ] && network_get_physdev ifname $1
|
||||||
|
[ -z "$ifname" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$ifname" ] && ifname=$(ifstatus "$1_4" | jsonfilter -q -e '@["l3_device"]')
|
[ -z "$ifname" ] && ifname=$(ifstatus "$1_4" | jsonfilter -q -e '@["l3_device"]')
|
||||||
[ -z "$ifname" ] && config_get ifname "$1" device
|
[ -z "$ifname" ] && config_get ifname "$1" device
|
||||||
[ -n "$(echo $ifname | grep '@')" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["device"]')
|
[ -n "$(echo $ifname | grep '@')" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["device"]')
|
||||||
|
@ -69,6 +72,9 @@ _launch_tracker() {
|
||||||
[ "${ifenabled}" = "0" ] && return
|
[ "${ifenabled}" = "0" ] && return
|
||||||
[ "${enabled}" = "0" ] && return
|
[ "${enabled}" = "0" ] && return
|
||||||
[ -z "${hosts}" ] && [ "$type" != "none" ] && return
|
[ -z "${hosts}" ] && [ "$type" != "none" ] && return
|
||||||
|
ifstatus=$(ifstatus "$1" | jsonfilter -q -e '@["up"]')
|
||||||
|
ifdevice=$(ifstatus "$1" | jsonfilter -q -e '@["device"]')
|
||||||
|
[ "${ifstatus}" = "false" ] && [ -z "${ifdevice}" ] && return
|
||||||
[ -z "${interval_tries}" ] && interval_tries=1
|
[ -z "${interval_tries}" ] && interval_tries=1
|
||||||
|
|
||||||
procd_open_instance
|
procd_open_instance
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue