From: Christopher Layne Date: Sun, 9 Apr 2023 17:24:31 +0000 (-0700) Subject: geoip: Use stdout for output and stderr for errors/diag X-Git-Tag: v3.24~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f16ed5c6bf15bb250f58d29815b87bc9b6d5da98;p=thirdparty%2Fxtables-addons.git geoip: Use stdout for output and stderr for errors/diag * xt_geoip_build, xt_geoip_build_maxmind: These scripts are emitting "normal" output to stderr meaning that cronjobs basically have to sink all output in order to avoid noise. Unfortunately, by doing that, one also loses errors in the error case and said error might be transient. A simple 1>/dev/null should work for the normal cron case. * xt_geoip_build_maxmind: Fix missing $quiet check in the v4 case. --- diff --git a/geoip/xt_geoip_build b/geoip/xt_geoip_build index e76663a..74a16e8 100755 --- a/geoip/xt_geoip_build +++ b/geoip/xt_geoip_build @@ -65,11 +65,11 @@ sub collect } if (!$quiet && $. % 4096 == 0) { - print STDERR "\r\e[2K$. entries"; + print STDOUT "\r\e[2K$. entries"; } } - print STDERR "\r\e[2K$. entries total\n" unless ($quiet); + print STDOUT "\r\e[2K$. entries total\n" unless ($quiet); close($fh); diff --git a/geoip/xt_geoip_build_maxmind b/geoip/xt_geoip_build_maxmind index feb9607..05a726c 100755 --- a/geoip/xt_geoip_build_maxmind +++ b/geoip/xt_geoip_build_maxmind @@ -168,12 +168,12 @@ sub collect $cidr = $row->[net]; $country{$cc}->{pool_v4}->add($cidr); - if ($. % 4096 == 0) { - print STDERR "\r\e[2K$. entries"; + if (!$quiet && $. % 4096 == 0) { + print STDOUT "\r\e[2K$. entries"; } } - print STDERR "\r\e[2K$. entries total\n"; + print STDOUT "\r\e[2K$. entries total\n" unless ($quiet); close($fh); @@ -203,11 +203,11 @@ sub collect $country{$cc}->{pool_v6}->add($cidr); if (!$quiet && $. % 4096 == 0) { - print STDERR "\r\e[2K$. entries"; + print STDOUT "\r\e[2K$. entries"; } } - print STDERR "\r\e[2K$. entries total\n" unless ($quiet); + print STDOUT "\r\e[2K$. entries total\n" unless ($quiet); close($fh);