mwan3: write `mwan3 use` error/debug messages to stderr instead of stdout
authorPhilipp Schmitt <philipp@schmitt.co>
Tue, 18 Feb 2025 16:41:22 +0000 (17:41 +0100)
committerFlorian Eckert <Eckert.Florian@googlemail.com>
Thu, 20 Feb 2025 10:10:34 +0000 (11:10 +0100)
This redirects the debug output to stderr, allowing `mwan3 use` to be used in
scripts without polluting stdout.

Before:

mwan3 use wan curl -fsSL https://ifconfig.co/json | jq -er '.country_iso'
jq: parse error: Invalid numeric literal at line 1, column 8
curl: (23) Failure writing output to destination, passed 389 returned 0

After:

mwan3 use wan curl -fsSL https://ifconfig.co/json | jq -er '.country_iso'
Running 'curl -fsSL https://ifconfig.co/json' with DEVICE=eth2 SRCIP=192.168.0.1 FWMARK=0x3f00 FAMILY=ipv4
DE

Signed-off-by: Philipp Schmitt <philipp@schmitt.co>
net/mwan3/Makefile
net/mwan3/files/usr/sbin/mwan3

index d951b191785e99c3b05980bb85ae086dc5281dd0..1631927a6bc24523d90ef67fd850bbebb29e1ca7 100644 (file)
@@ -8,7 +8,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=mwan3
-PKG_VERSION:=2.11.18
+PKG_VERSION:=2.11.19
 PKG_RELEASE:=5
 PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>, \
                Aaron Goodman <aaronjg@alumni.stanford.edu>
index 9162cb477c0c2de43abd9612ac780d3129857d4e..9916657928dfe352664d5efc1301713c307276b1 100755 (executable)
@@ -222,17 +222,17 @@ use() {
        local interface device src_ip family
 
        interface=$1 ; shift
-       [ -z "$*" ] && echo "no command specified for mwan3 use" && return
+       [ -z "$*" ] && echo "no command specified for mwan3 use" >&2 && return
        network_get_device device $interface
-       [ -z "$device" ] && echo "could not find device for $interface" && return
+       [ -z "$device" ] && echo "could not find device for $interface" >&2 && return
 
        mwan3_get_src_ip src_ip $interface
-       [ -z "$src_ip" ] && echo "could not find src_ip for $interface" && return
+       [ -z "$src_ip" ] && echo "could not find src_ip for $interface" >&2 && return
 
        config_get family $interface family
-       [ -z "$family" ] && echo "could not find family for $interface. Using ipv4." && family='ipv4'
+       [ -z "$family" ] && echo "could not find family for $interface. Using ipv4." >&2 && family='ipv4'
 
-       echo "Running '$*' with DEVICE=$device SRCIP=$src_ip FWMARK=$MMX_DEFAULT FAMILY=$family"
+       echo "Running '$*' with DEVICE=$device SRCIP=$src_ip FWMARK=$MMX_DEFAULT FAMILY=$family" >&2
        # if a program (not a shell builtin) is run: use "exec" for allowing direct process control
        if [ -x "$(command -v "$1")" ]; then
                set -- exec "$@"