From f16ed5c6bf15bb250f58d29815b87bc9b6d5da98 Mon Sep 17 00:00:00 2001 From: Christopher Layne Date: Sun, 9 Apr 2023 10:24:31 -0700 Subject: [PATCH] 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. --- geoip/xt_geoip_build | 4 ++-- geoip/xt_geoip_build_maxmind | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) 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); -- 2.47.2