net/mwan3: move global mwan3track into main function

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
Florian Eckert 2017-04-04 15:01:34 +02:00
parent 23fada1e8c
commit 23339d7ae1

View file

@ -1,5 +1,7 @@
#!/bin/sh
main() {
[ -z "$12" ] && echo "Error: should not be started manually" && exit 0
if [ -e /var/run/mwan3track-$1.pid ] ; then
@ -9,11 +11,11 @@ fi
echo "$$" > /var/run/mwan3track-$1.pid
score=$(($7+$8))
track_ips=$(echo $* | cut -d ' ' -f 12-99)
host_up_count=0
lost=0
sleep_time=0
local score=$(($7+$8))
local track_ips=$(echo $* | cut -d ' ' -f 12-99)
local host_up_count=0
local lost=0
local sleep_time=0
while true; do
@ -38,19 +40,13 @@ while true; do
fi
if [ $score -eq $8 ]; then
logger -t mwan3track -p notice "Interface $1 ($2) is offline"
env -i ACTION=ifdown INTERFACE=$1 DEVICE=$2 /sbin/hotplug-call iface
score=0
fi
else
if [ $score -lt $(($7+$8)) ] && [ $lost -gt 0 ]; then
logger -t mwan3track -p info "Lost $(($lost*$4)) ping(s) on interface $1 ($2)"
fi
let score++
@ -63,7 +59,6 @@ while true; do
fi
if [ $score -eq $8 ]; then
logger -t mwan3track -p notice "Interface $1 ($2) is online"
env -i ACTION=ifup INTERFACE=$1 DEVICE=$2 /sbin/hotplug-call iface
rm /var/run/mwan3track-$1.pid
@ -74,5 +69,6 @@ while true; do
host_up_count=0
sleep $sleep_time
done
}
exit 1
main "$@"