diff --git a/net/mwan3/Makefile b/net/mwan3/Makefile index 4a0856edc..394a642f9 100644 --- a/net/mwan3/Makefile +++ b/net/mwan3/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mwan3 -PKG_VERSION:=2.5.1 +PKG_VERSION:=2.5.2 PKG_RELEASE:=5 PKG_MAINTAINER:=Florian Eckert PKG_LICENSE:=GPLv2 diff --git a/net/mwan3/files/etc/hotplug.d/iface/15-mwan3 b/net/mwan3/files/etc/hotplug.d/iface/15-mwan3 index a13ff8324..e3fd16cef 100644 --- a/net/mwan3/files/etc/hotplug.d/iface/15-mwan3 +++ b/net/mwan3/files/etc/hotplug.d/iface/15-mwan3 @@ -11,12 +11,6 @@ if [ "$ACTION" == "ifup" ]; then [ -n "$DEVICE" ] || exit 3 fi -[ -x /usr/bin/ip ] || exit 4 -[ -x /usr/sbin/ipset ] || exit 5 -[ -x /usr/sbin/iptables ] || exit 6 -[ -x /usr/sbin/ip6tables ] || exit 7 -[ -x /usr/bin/logger ] || exit 8 - mwan3_set_connected_iptables config_load mwan3 diff --git a/net/mwan3/files/lib/mwan3/mwan3.sh b/net/mwan3/files/lib/mwan3/mwan3.sh index f0ebcc42e..3798d7eb0 100644 --- a/net/mwan3/files/lib/mwan3/mwan3.sh +++ b/net/mwan3/files/lib/mwan3/mwan3.sh @@ -1,11 +1,11 @@ #!/bin/sh -IP4="/usr/bin/ip -4" -IP6="/usr/bin/ip -6" -IPS="/usr/sbin/ipset" -IPT4="/usr/sbin/iptables -t mangle -w" -IPT6="/usr/sbin/ip6tables -t mangle -w" -LOG="/usr/bin/logger -t mwan3 -p" +IP4="ip -4" +IP6="ip -6" +IPS="ipset" +IPT4="iptables -t mangle -w" +IPT6="ip6tables -t mangle -w" +LOG="logger -t mwan3 -p" CONNTRACK_FILE="/proc/net/nf_conntrack" mwan3_get_iface_id() @@ -390,10 +390,7 @@ mwan3_track() } config_list_foreach $1 track_ip mwan3_list_track_ips - if [ -e /var/run/mwan3track-$1.pid ] ; then - kill $(cat /var/run/mwan3track-$1.pid) &> /dev/null - fi - + kill $(pgrep -f "mwan3track $1") &> /dev/null if [ -n "$track_ips" ]; then [ -x /usr/sbin/mwan3track ] && /usr/sbin/mwan3track $1 $2 $track_ips & fi @@ -401,18 +398,13 @@ mwan3_track() mwan3_track_signal() { - local pid status + local pid - if [ -f "/var/run/mwan3track-${1}.pid" ]; then - pid="$(cat "/var/run/mwan3track-${1}.pid")" - status="$(pgrep -f mwan3track | grep "${pid}")" - if [ "${status}" != "" ]; then - kill -USR1 "${pid}" - else - $LOG warn "Unable to send signal USR1 to mwan3track on interface $1 with pid ${pid}" - fi + pid="$(pgrep -f "mwan3track $1")" + if [ "${pid}" != "" ]; then + kill -USR1 "${pid}" else - $LOG warn "Unable to find \"/var/run/mwan3track-${1}.pid\" file for mwan3track on interface $1" + $LOG warn "Unable to send signal USR1 to mwan3track on interface $1 with pid ${pid}" fi } diff --git a/net/mwan3/files/usr/libexec/rpcd/mwan3 b/net/mwan3/files/usr/libexec/rpcd/mwan3 index 028dafe1d..bbc570f6c 100755 --- a/net/mwan3/files/usr/libexec/rpcd/mwan3 +++ b/net/mwan3/files/usr/libexec/rpcd/mwan3 @@ -6,9 +6,9 @@ MWAN3_STATUS_DIR="/var/run/mwan3track" MWAN3_PID_FILE="/var/run/mwan3track" -IPS="/usr/sbin/ipset" -IPT4="/usr/sbin/iptables -t mangle -w" -IPT6="/usr/sbin/ip6tables -t mangle -w" +IPS="ipset" +IPT4="iptables -t mangle -w" +IPT6="ip6tables -t mangle -w" report_connected_v4() { local address @@ -34,16 +34,12 @@ get_mwan3_status() { local iface="${1}" local iface_select="${2}" local running="0" - local pid="" - local status="" + local pid if [ "${iface}" = "${iface_select}" ] || [ "${iface_select}" = "" ]; then - if [ -f "${MWAN3_PID_FILE}-${iface}.pid" ]; then - pid="$(cat "${MWAN3_PID_FILE}-${iface}.pid")" - status="$(pgrep -f mwan3track | grep "${pid}")" - if [ "${status}" != "" ]; then - running="1" - fi + pid="$(pgrep -f "mwan3track $iface_selected")" + if [ "${pid}" != "" ]; then + running="1" fi json_add_object "${iface}" diff --git a/net/mwan3/files/usr/sbin/mwan3 b/net/mwan3/files/usr/sbin/mwan3 index 63617316c..f23d2e71b 100755 --- a/net/mwan3/files/usr/sbin/mwan3 +++ b/net/mwan3/files/usr/sbin/mwan3 @@ -1,11 +1,5 @@ #!/bin/sh -[ -x /usr/bin/ip ] || exit 4 -[ -x /usr/sbin/ipset ] || exit 5 -[ -x /usr/sbin/iptables ] || exit 6 -[ -x /usr/sbin/ip6tables ] || exit 7 -[ -x /usr/bin/logger ] || exit 8 - . /lib/functions.sh . /lib/functions/network.sh . /lib/mwan3/mwan3.sh @@ -42,9 +36,7 @@ ifdown() ACTION=ifdown INTERFACE=$1 /sbin/hotplug-call iface - if [ -e /var/run/mwan3track-$1.pid ] ; then - kill $(cat /var/run/mwan3track-$1.pid) - fi + kill $(pgrep -f "mwan3track $1") &> /dev/null } ifup() diff --git a/net/mwan3/files/usr/sbin/mwan3track b/net/mwan3/files/usr/sbin/mwan3track index 0d7b5ab5d..8afe90129 100755 --- a/net/mwan3/files/usr/sbin/mwan3track +++ b/net/mwan3/files/usr/sbin/mwan3track @@ -2,7 +2,7 @@ . /lib/functions.sh -LOG="/usr/bin/logger -t $(basename "$0")[$$] -p" +LOG="logger -t $(basename "$0")[$$] -p" INTERFACE="" DEVICE="" @@ -10,8 +10,9 @@ IFDOWN_EVENT=0 clean_up() { $LOG notice "Stopping mwan3track for interface \"${INTERFACE}\"" - rm "/var/run/mwan3track-${INTERFACE}.pid" &> /dev/null - rm -rf "/var/run/mwan3track/${INTERFACE}" &> /dev/null + if [ "$(pgrep -f "mwan3track ${INTERFACE}")" = "" ]; then + rm -rf "/var/run/mwan3track/${INTERFACE}" &> /dev/null + fi if [ -z "$(ls -A "/var/run/mwan3track")" ]; then rm -rf "/var/run/mwan3track" fi @@ -31,7 +32,6 @@ main() { INTERFACE=$1 DEVICE=$2 - echo "$$" > /var/run/mwan3track-$1.pid mkdir -p /var/run/mwan3track/$1 trap clean_up SIGINT SIGTERM trap if_down SIGUSR1 @@ -103,13 +103,13 @@ main() { if [ $score -eq $up ]; then $LOG notice "Interface $1 ($2) is online" env -i ACTION=ifup INTERFACE=$1 DEVICE=$2 /sbin/hotplug-call iface - rm /var/run/mwan3track-$1.pid rm -rf "/var/run/mwan3track/${1}" &> /dev/null exit 0 fi fi let turn++ + mkdir -p "/var/run/mwan3track/${1}" echo "${lost}" > /var/run/mwan3track/$1/LOST echo "${score}" > /var/run/mwan3track/$1/SCORE echo "${turn}" > /var/run/mwan3track/$1/TURN