mwan3: use MWAN3TRACK_STATUS_DIR variable throughout
authorAaron Goodman <aaronjg@stanford.edu>
Mon, 31 Aug 2020 19:49:17 +0000 (15:49 -0400)
committerAaron Goodman <aaronjg@stanford.edu>
Fri, 16 Oct 2020 13:54:48 +0000 (09:54 -0400)
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
net/mwan3/files/lib/mwan3/common.sh
net/mwan3/files/lib/mwan3/mwan3.sh
net/mwan3/files/usr/sbin/mwan3track

index 62a736b37310041762a0120e67c80ad07a9f6c17..3b1560897e573e9f2a8f79ebff856fc39b74639f 100644 (file)
@@ -6,6 +6,7 @@ get_uptime() {
 }
 
 SCRIPTNAME="$(basename "$0")"
+MWAN3TRACK_STATUS_DIR="/var/run/mwan3track"
 LOG()
 {
        local facility=$1; shift
index e9b3feda88f953e8e4fac62b5e0fa5e7ba622777..4d42f89540df00bbb95e47b13f50dde0e535ad1e 100644 (file)
@@ -24,7 +24,6 @@ IPv6_REGEX="${IPv6_REGEX}::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-
 IPv6_REGEX="${IPv6_REGEX}([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])"
 
 MWAN3_STATUS_DIR="/var/run/mwan3"
-MWAN3TRACK_STATUS_DIR="/var/run/mwan3track"
 MWAN3_INTERFACE_MAX=""
 DEFAULT_LOWEST_METRIC=256
 MMX_MASK=""
index a48df72b5eb62a9c95da9d60bc35d3141a6376e3..863eb76ff422ea2df7127dd2798245701d30431e 100755 (executable)
@@ -73,9 +73,9 @@ disconnected() {
 }
 
 connected() {
-       echo "online" > /var/run/mwan3track/$INTERFACE/STATUS
-       echo "0" > /var/run/mwan3track/$INTERFACE/OFFLINE
-       get_uptime > /var/run/mwan3track/$INTERFACE/ONLINE
+       echo "online" > $MWAN3TRACK_STATUS_DIR/$INTERFACE/STATUS
+       echo "0" > $MWAN3TRACK_STATUS_DIR/$INTERFACE/OFFLINE
+       get_uptime > $MWAN3TRACK_STATUS_DIR/$INTERFACE/ONLINE
        host_up_count=0
        lost=0
        turn=0
@@ -96,10 +96,10 @@ firstconnect() {
 update_status() {
        local track_ip=$1
 
-       echo "$2" > /var/run/mwan3track/$INTERFACE/TRACK_${track_ip}
+       echo "$2" > $MWAN3TRACK_STATUS_DIR/$INTERFACE/TRACK_${track_ip}
        [ -z "$3" ] && return
-       echo "$3" > /var/run/mwan3track/$INTERFACE/LATENCY_${track_ip}
-       echo "$4" > /var/run/mwan3track/$INTERFACE/LOSS_${track_ip}
+       echo "$3" > $MWAN3TRACK_STATUS_DIR/$INTERFACE/LATENCY_${track_ip}
+       echo "$4" > $MWAN3TRACK_STATUS_DIR/$INTERFACE/LOSS_${track_ip}
 }
 
 main() {
@@ -280,7 +280,7 @@ main() {
                        lost=0
 
                        if [ $score -gt $up ]; then
-                               echo "online" > /var/run/mwan3track/$INTERFACE/STATUS
+                               echo "online" > $MWAN3TRACK_STATUS_DIR/$INTERFACE/STATUS
                                score=$((down+up))
                        elif [ $score -le $up ]; then
                                sleep_time=$recovery_interval
@@ -292,11 +292,11 @@ main() {
                fi
 
                let turn++
-               mkdir -p "/var/run/mwan3track/${1}"
-               echo "${lost}" > /var/run/mwan3track/$INTERFACE/LOST
-               echo "${score}" > /var/run/mwan3track/$INTERFACE/SCORE
-               echo "${turn}" > /var/run/mwan3track/$INTERFACE/TURN
-               get_uptime > /var/run/mwan3track/$INTERFACE/TIME
+               mkdir -p "$MWAN3TRACK_STATUS_DIR/${1}"
+               echo "${lost}" > $MWAN3TRACK_STATUS_DIR/$INTERFACE/LOST
+               echo "${score}" > $MWAN3TRACK_STATUS_DIR/$INTERFACE/SCORE
+               echo "${turn}" > $MWAN3TRACK_STATUS_DIR/$INTERFACE/TURN
+               get_uptime > $MWAN3TRACK_STATUS_DIR/$INTERFACE/TIME
 
                host_up_count=0
                sleep "${sleep_time}" &