mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
add quiet options when jsonfilter is used
This commit is contained in:
parent
eb9658bcb1
commit
f6efdc51c9
6 changed files with 13 additions and 13 deletions
|
@ -38,7 +38,7 @@ interface_multipath_settings() {
|
||||||
local intf="$2"
|
local intf="$2"
|
||||||
|
|
||||||
config_get iface "$config" ifname
|
config_get iface "$config" ifname
|
||||||
[ -z "$iface" ] && iface=$(ifstatus "$config" | jsonfilter -e '@["l3_device"]')
|
[ -z "$iface" ] && iface=$(ifstatus "$config" | jsonfilter -q -e '@["l3_device"]')
|
||||||
count=$(($count+1))
|
count=$(($count+1))
|
||||||
id=$count
|
id=$count
|
||||||
[ -n "$intf" ] && [ "$iface" != "$intf" ] && return 0
|
[ -n "$intf" ] && [ "$iface" != "$intf" ] && return 0
|
||||||
|
@ -71,8 +71,8 @@ interface_multipath_settings() {
|
||||||
ipaddr=$(ip -4 addr show dev $iface | grep inet | awk '{print $2}' | cut -d/ -f1 | tr -d "\n")
|
ipaddr=$(ip -4 addr show dev $iface | grep inet | awk '{print $2}' | cut -d/ -f1 | tr -d "\n")
|
||||||
gateway=$(ip -4 r list dev $iface | grep -v default | awk '/proto static/ {print $1}' | tr -d "\n")
|
gateway=$(ip -4 r list dev $iface | grep -v default | awk '/proto static/ {print $1}' | tr -d "\n")
|
||||||
[ -z "$gateway" ] && gateway=$(uci -q get "network.$config.gateway")
|
[ -z "$gateway" ] && gateway=$(uci -q get "network.$config.gateway")
|
||||||
[ -z "$gateway" ] && gateway=$(ubus call network.interface.$config status | jsonfilter -e '@.route[0].nexthop' | tr -d "\n")
|
[ -z "$gateway" ] && gateway=$(ubus call network.interface.$config status | jsonfilter -q -e '@.route[0].nexthop' | tr -d "\n")
|
||||||
[ -z "$gateway" ] && gateway=$(ubus call network.interface.$config status | jsonfilter -e '@.inactive.route[0].nexthop' | tr -d "\n")
|
[ -z "$gateway" ] && gateway=$(ubus call network.interface.$config status | jsonfilter -q -e '@.inactive.route[0].nexthop' | tr -d "\n")
|
||||||
netmask=$(ip -4 addr show dev $iface | grep inet | awk '{print $2}' | cut -d/ -f2 | tr -d "\n")
|
netmask=$(ip -4 addr show dev $iface | grep inet | awk '{print $2}' | cut -d/ -f2 | tr -d "\n")
|
||||||
network=`ipcalc.sh $ipaddr $netmask | sed -n '/NETWORK=/{;s/.*=//;s/ .*//;p;}'`
|
network=`ipcalc.sh $ipaddr $netmask | sed -n '/NETWORK=/{;s/.*=//;s/ .*//;p;}'`
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -7,17 +7,17 @@ set_route() {
|
||||||
PREVINTERFACE=$2
|
PREVINTERFACE=$2
|
||||||
multipath_config=$(uci -q get network.$INTERFACE.multipath || echo "off")
|
multipath_config=$(uci -q get network.$INTERFACE.multipath || echo "off")
|
||||||
interface_if=$(uci -q get network.$INTERFACE.ifname)
|
interface_if=$(uci -q get network.$INTERFACE.ifname)
|
||||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "$INTERFACE" | jsonfilter -e '@["l3_device"]')
|
[ -z "$interface_if" ] && interface_if=$(ifstatus "$INTERFACE" | jsonfilter -q -e '@["l3_device"]')
|
||||||
multipath_current_config=$(multipath $interface_if | grep deactivated)
|
multipath_current_config=$(multipath $interface_if | grep deactivated)
|
||||||
if [ "$multipath_config" != "off" ] && [ "$SETROUTE" != true ] && [ "$INTERFACE" != "$PREVINTERFACE" ] && [ "$multipath_current_config" = "" ]; then
|
if [ "$multipath_config" != "off" ] && [ "$SETROUTE" != true ] && [ "$INTERFACE" != "$PREVINTERFACE" ] && [ "$multipath_current_config" = "" ]; then
|
||||||
#if [ "$multipath_config" != "off" ] && [ "$SETROUTE" != true ]; then
|
#if [ "$multipath_config" != "off" ] && [ "$SETROUTE" != true ]; then
|
||||||
#if [ "$multipath_config" != "off" ] && [ "$INTERFACE" != "$PREVINTERFACE" ] && [ "$SETROUTE" != true ]; then
|
#if [ "$multipath_config" != "off" ] && [ "$INTERFACE" != "$PREVINTERFACE" ] && [ "$SETROUTE" != true ]; then
|
||||||
interface_gw="$(uci -q get network.$INTERFACE.gateway)"
|
interface_gw="$(uci -q get network.$INTERFACE.gateway)"
|
||||||
if [ -z "$interface_gw" ]; then
|
if [ -z "$interface_gw" ]; then
|
||||||
interface_gw=$(ubus call network.interface.$INTERFACE status | jsonfilter -e '@.route[0].nexthop' | tr -d "\n")
|
interface_gw=$(ubus call network.interface.$INTERFACE status | jsonfilter -q -e '@.route[0].nexthop' | tr -d "\n")
|
||||||
fi
|
fi
|
||||||
if [ -z "$interface_gw" ]; then
|
if [ -z "$interface_gw" ]; then
|
||||||
interface_gw=$(ubus call network.interface.$INTERFACE status | jsonfilter -e '@.inactive.route[0].nexthop' | tr -d "\n")
|
interface_gw=$(ubus call network.interface.$INTERFACE status | jsonfilter -q -e '@.inactive.route[0].nexthop' | tr -d "\n")
|
||||||
fi
|
fi
|
||||||
if [ "$interface_gw" != "" ]; then
|
if [ "$interface_gw" != "" ]; then
|
||||||
_log "$PREVINTERFACE down. Replace default route by $interface_gw dev $interface_if"
|
_log "$PREVINTERFACE down. Replace default route by $interface_gw dev $interface_if"
|
||||||
|
|
|
@ -16,9 +16,9 @@ reload_service() {
|
||||||
elif [ "$(uci -q get openvpn.omr.enabled)" = "1" ]; then
|
elif [ "$(uci -q get openvpn.omr.enabled)" = "1" ]; then
|
||||||
iface=$(uci -q get openvpn.omr.dev)
|
iface=$(uci -q get openvpn.omr.dev)
|
||||||
fi
|
fi
|
||||||
addr=$(ubus call network.interface.omrvpn status | jsonfilter -e '@["ipv4-address"][0].address' | tr -d "\n")
|
addr=$(ubus call network.interface.omrvpn status | jsonfilter -q -e '@["ipv4-address"][0].address' | tr -d "\n")
|
||||||
[ -z "$addr" ] && [ -n "$iface" ] && addr=$(ip -4 addr show dev $iface | grep inet | awk '{print $2}' | cut -d/ -f1 | tr -d "\n")
|
[ -z "$addr" ] && [ -n "$iface" ] && addr=$(ip -4 addr show dev $iface | grep inet | awk '{print $2}' | cut -d/ -f1 | tr -d "\n")
|
||||||
peer=$(ubus call network.interface.omrvpn status | jsonfilter -e '@.route[0].nexthop' | tr -d "\n")
|
peer=$(ubus call network.interface.omrvpn status | jsonfilter -q -e '@.route[0].nexthop' | tr -d "\n")
|
||||||
[ -z "$peer" ] && [ -n "$iface" ] && peer=$(ip -4 r list dev $iface | grep kernel | awk '/proto kernel/ {print $1}' | grep -v / | tr -d "\n")
|
[ -z "$peer" ] && [ -n "$iface" ] && peer=$(ip -4 r list dev $iface | grep kernel | awk '/proto kernel/ {print $1}' | grep -v / | tr -d "\n")
|
||||||
[ -z "$addr" ] && exit 0
|
[ -z "$addr" ] && exit 0
|
||||||
[ -z "$peer" ] && exit 0
|
[ -z "$peer" ] && exit 0
|
||||||
|
|
|
@ -10,8 +10,8 @@ shift
|
||||||
|
|
||||||
# main loop
|
# main loop
|
||||||
while true; do
|
while true; do
|
||||||
rx=`vnstat -i $OMR_QUOTA_INTERFACE --json | jsonfilter -e '@.interfaces[0].traffic.months[-1].rx' | tr -d "\n"`
|
rx=`vnstat -i $OMR_QUOTA_INTERFACE --json | jsonfilter -q -e '@.interfaces[0].traffic.months[-1].rx' | tr -d "\n"`
|
||||||
tx=`vnstat -i $OMR_QUOTA_INTERFACE --json | jsonfilter -e '@.interfaces[0].traffic.months[-1].tx' | tr -d "\n"`
|
tx=`vnstat -i $OMR_QUOTA_INTERFACE --json | jsonfilter -q -e '@.interfaces[0].traffic.months[-1].tx' | tr -d "\n"`
|
||||||
tt=$((rx + tx))
|
tt=$((rx + tx))
|
||||||
[ -n "$OMR_QUOTA_RX" ] && [ "$OMR_QUOTA_RX" -gt 0 ] && [ -n "$rx" ] && [ "$OMR_QUOTA_RX" -ge "$rx" ] && ifdown $OMR_QUOTA_INTERFACE \
|
[ -n "$OMR_QUOTA_RX" ] && [ "$OMR_QUOTA_RX" -gt 0 ] && [ -n "$rx" ] && [ "$OMR_QUOTA_RX" -ge "$rx" ] && ifdown $OMR_QUOTA_INTERFACE \
|
||||||
|| \
|
|| \
|
||||||
|
|
|
@ -152,10 +152,10 @@ while true; do
|
||||||
OMR_TRACKER_DEVICE_GATEWAY=$(uci -q get "network.$OMR_TRACKER_INTERFACE.gateway")
|
OMR_TRACKER_DEVICE_GATEWAY=$(uci -q get "network.$OMR_TRACKER_INTERFACE.gateway")
|
||||||
fi
|
fi
|
||||||
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
||||||
OMR_TRACKER_DEVICE_GATEWAY=$(ubus call network.interface.$OMR_TRACKER_INTERFACE status | jsonfilter -e '@.route[0].nexthop' | tr -d "\n")
|
OMR_TRACKER_DEVICE_GATEWAY=$(ubus call network.interface.$OMR_TRACKER_INTERFACE status | jsonfilter -q -e '@.route[0].nexthop' | tr -d "\n")
|
||||||
fi
|
fi
|
||||||
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
||||||
OMR_TRACKER_DEVICE_GATEWAY=$(ubus call network.interface.$OMR_TRACKER_INTERFACE status | jsonfilter -e '@.inactive.route[0].nexthop' | tr -d "\n")
|
OMR_TRACKER_DEVICE_GATEWAY=$(ubus call network.interface.$OMR_TRACKER_INTERFACE status | jsonfilter -q -e '@.inactive.route[0].nexthop' | tr -d "\n")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# execute specific tracker
|
# execute specific tracker
|
||||||
|
|
|
@ -42,7 +42,7 @@ _launch_tracker() {
|
||||||
|
|
||||||
local ifname ip4table
|
local ifname ip4table
|
||||||
config_get ifname "$1" ifname
|
config_get ifname "$1" ifname
|
||||||
[ -z "$ifname" ] && ifname=$(ifstatus "$1" | jsonfilter -e '@["l3_device"]')
|
[ -z "$ifname" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["l3_device"]')
|
||||||
|
|
||||||
config_get multipath "$1" multipath
|
config_get multipath "$1" multipath
|
||||||
config_get gateway "$1" gateway
|
config_get gateway "$1" gateway
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue