Browse Source

net/mwan3: add clean_up trap function for SIGINT SIGTERM

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
lilik-openwrt-22.03
Florian Eckert 8 years ago
parent
commit
5b55223d80
3 changed files with 9 additions and 8 deletions
  1. +0
    -1
      net/mwan3/files/lib/mwan3/mwan3.sh
  2. +0
    -2
      net/mwan3/files/usr/sbin/mwan3
  3. +9
    -5
      net/mwan3/files/usr/sbin/mwan3track

+ 0
- 1
net/mwan3/files/lib/mwan3/mwan3.sh View File

@ -393,7 +393,6 @@ mwan3_track()
if [ -e /var/run/mwan3track-$1.pid ] ; then if [ -e /var/run/mwan3track-$1.pid ] ; then
kill $(cat /var/run/mwan3track-$1.pid) &> /dev/null kill $(cat /var/run/mwan3track-$1.pid) &> /dev/null
rm /var/run/mwan3track-$1.pid &> /dev/null
fi fi
if [ -n "$track_ips" ]; then if [ -n "$track_ips" ]; then


+ 0
- 2
net/mwan3/files/usr/sbin/mwan3 View File

@ -44,7 +44,6 @@ ifdown()
if [ -e /var/run/mwan3track-$1.pid ] ; then if [ -e /var/run/mwan3track-$1.pid ] ; then
kill $(cat /var/run/mwan3track-$1.pid) kill $(cat /var/run/mwan3track-$1.pid)
rm /var/run/mwan3track-$1.pid
fi fi
} }
@ -129,7 +128,6 @@ stop()
local ipset route rule table IP IPT local ipset route rule table IP IPT
killall mwan3track &> /dev/null killall mwan3track &> /dev/null
rm /var/run/mwan3track-* &> /dev/null
for IP in "$IP4" "$IP6"; do for IP in "$IP4" "$IP6"; do


+ 9
- 5
net/mwan3/files/usr/sbin/mwan3track View File

@ -1,17 +1,21 @@
#!/bin/sh #!/bin/sh
LOG="/usr/bin/logger -t $(basename "$0")[$$] -p" LOG="/usr/bin/logger -t $(basename "$0")[$$] -p"
INTERFACE=""
clean_up() {
$LOG notice "Stopping mwan3track for interface \"${INTERFACE}\""
rm "/var/run/mwan3track-${INTERFACE}.pid" &> /dev/null
exit 0
}
main() { main() {
[ -z "$12" ] && echo "Error: should not be started manually" && exit 0 [ -z "$12" ] && echo "Error: should not be started manually" && exit 0
if [ -e /var/run/mwan3track-$1.pid ] ; then
kill $(cat /var/run/mwan3track-$1.pid) &> /dev/null
rm /var/run/mwan3track-$1.pid &> /dev/null
fi
INTERFACE=$1
echo "$$" > /var/run/mwan3track-$1.pid echo "$$" > /var/run/mwan3track-$1.pid
trap clean_up SIGINT SIGTERM
local score=$(($7+$8)) local score=$(($7+$8))
local track_ips=$(echo $* | cut -d ' ' -f 12-99) local track_ips=$(echo $* | cut -d ' ' -f 12-99)


Loading…
Cancel
Save