mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Get IPv4 in tracker if DHCPv6 not set
This commit is contained in:
parent
01d9b7efc1
commit
b178e7f460
1 changed files with 61 additions and 55 deletions
|
@ -175,6 +175,7 @@ _none() {
|
|||
|
||||
_restart
|
||||
|
||||
OMR_TRACKER_INTERFACE_PROTO="$(uci -q get network.${OMR_TRACKER_INTERFACE_PROTO}.proto)"
|
||||
OMR_TRACKER_PREV_STATUS=""
|
||||
# main loop
|
||||
while true; do
|
||||
|
@ -193,14 +194,11 @@ while true; do
|
|||
if [ -d "/sys/class/net/$OMR_TRACKER_DEVICE" ]; then
|
||||
if [ -n "$(ip link show $OMR_TRACKER_DEVICE | grep UP)" ]; then
|
||||
# retrieve iface ip and gateway
|
||||
if [ "$OMR_TRACKER_INTERFACE_PROTO" != "dhcpv6" ]; then
|
||||
OMR_TRACKER_DEVICE_IP=$(ip -4 -br addr ls dev "$OMR_TRACKER_DEVICE" | awk -F'[ /]+' '{print $3}')
|
||||
if [ -z "$OMR_TRACKER_DEVICE_IP" ]; then
|
||||
OMR_TRACKER_DEVICE_IP=$(ip -4 addr show dev "$OMR_TRACKER_DEVICE" | grep -m 1 inet | awk '{print $2}' | cut -d'/' -s -f1)
|
||||
fi
|
||||
#OMR_TRACKER_DEVICE_IP6=$(ip -6 -br addr ls dev "$OMR_TRACKER_DEVICE" | awk -F'[ /]+' '{print $3}')
|
||||
#if [ -z "$OMR_TRACKER_DEVICE_IP6" ]; then
|
||||
OMR_TRACKER_DEVICE_IP6=$(ip -6 addr show dev "$OMR_TRACKER_DEVICE" | grep -v 'inet6 f' | grep -m 1 inet | awk '{print $2}' | cut -d'/' -s -f1)
|
||||
#fi
|
||||
#OMR_TRACKER_DEVICE_IP=$(ubus call network.interface.$OMR_TRACKER_INTERFACE status | jsonfilter -e '@["ipv4-address"][0].address' | tr -d "\n")
|
||||
#if [ -z "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
||||
# OMR_TRACKER_DEVICE_GATEWAY=$(ip -4 r list dev "$OMR_TRACKER_DEVICE" | grep -v default | awk '/proto static/ {print $1}' | tr -d "\n")
|
||||
|
@ -235,6 +233,11 @@ while true; do
|
|||
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
||||
OMR_TRACKER_DEVICE_GATEWAY=$(ip -4 r list dev "$OMR_TRACKER_DEVICE" | grep kernel | awk '/proto kernel/ {print $1}' | tr -d "\n")
|
||||
fi
|
||||
fi
|
||||
#OMR_TRACKER_DEVICE_IP6=$(ip -6 -br addr ls dev "$OMR_TRACKER_DEVICE" | awk -F'[ /]+' '{print $3}')
|
||||
#if [ -z "$OMR_TRACKER_DEVICE_IP6" ]; then
|
||||
OMR_TRACKER_DEVICE_IP6=$(ip -6 addr show dev "$OMR_TRACKER_DEVICE" | grep -v 'inet6 f' | grep -m 1 inet | awk '{print $2}' | cut -d'/' -s -f1)
|
||||
#fi
|
||||
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY6" ]; then
|
||||
OMR_TRACKER_DEVICE_GATEWAY6=$(uci -q get "network.$OMR_TRACKER_INTERFACE.ip6gw")
|
||||
fi
|
||||
|
@ -250,6 +253,9 @@ while true; do
|
|||
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY6" ] || [ "$OMR_TRACKER_DEVICE_GATEWAY6" = "::" ]; then
|
||||
OMR_TRACKER_DEVICE_GATEWAY6=$(ubus call network.interface.$OMR_TRACKER_INTERFACE status | jsonfilter -q -l 1 -e '@.route[@.target="::"].nexthop' | tr -d "\n")
|
||||
fi
|
||||
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY6" ] || [ "$OMR_TRACKER_DEVICE_GATEWAY6" = "::" ]; then
|
||||
OMR_TRACKER_DEVICE_GATEWAY6=$(ubus call network.interface.$OMR_TRACKER_INTERFACE status | jsonfilter -q -l 1 -e '@.route[@.nexthop="::"].target' | tr -d "\n")
|
||||
fi
|
||||
|
||||
# execute specific tracker
|
||||
if [ -n "$OMR_TRACKER_DEVICE_IP" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue