1
0
Fork 0
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:
Ycarus (Yannick Chabanois) 2021-07-04 07:20:55 +02:00
parent ec6cdb8209
commit 18a6613650
5 changed files with 62 additions and 28 deletions

View file

@ -1,7 +1,7 @@
#!/bin/sh /etc/rc.common
# shellcheck disable=SC2039
# 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.
# shellcheck disable=SC2034
@ -12,6 +12,7 @@
}
. /usr/lib/unbound/iptools.sh
. /lib/functions/network.sh
_validate_section() {
local tmp_hosts=$hosts tmp_hosts6=$hosts6 tmp_timeout=$timeout tmp_tries=$tries
@ -53,7 +54,9 @@ _launch_tracker() {
_validate_section "interface" "$1"
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" ] && config_get ifname "$1" device
[ -n "$(echo $ifname | grep '@')" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["device"]')
@ -69,6 +72,9 @@ _launch_tracker() {
[ "${ifenabled}" = "0" ] && return
[ "${enabled}" = "0" ] && 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
procd_open_instance