1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

No error when tunnel interface not here

This commit is contained in:
Ycarus 2018-08-21 17:44:29 +02:00
parent 552d2af6fb
commit 3ccf83ccae

View file

@ -10,11 +10,11 @@ while true; do
iface=$(uci -q get openvpn.omr.dev)
fi
addr=$(ubus call network.interface.omrvpn status | jsonfilter -q -e '@["ipv4-address"][0].address' | tr -d "\n")
if [ -d "/sys/class/net/$iface" ]; then
[ -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 -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 "$addr" ] && exit 0
[ -z "$peer" ] && exit 0
[ -n "$addr" ] && [ -n "$peer" ] && {
if [ "$addr" != "$(uci -q get network.omr6in4.ipaddr)" ] || [ "$peer" != "$(uci -q get network.omr6in4.peeraddr)" ]; then
logger -t "omr6in4" "Set network for OMR 6in4 to local $addr peer $peer"
uci -q batch <<-EOF
@ -28,5 +28,7 @@ while true; do
ifup omr6in4
fi
fi
}
fi
sleep 10
done