]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
geoip: Use stdout for output and stderr for errors/diag 6/head
authorChristopher Layne <clayne@anodized.com>
Sun, 9 Apr 2023 17:24:31 +0000 (10:24 -0700)
committerChristopher Layne <clayne@anodized.com>
Sun, 9 Apr 2023 17:24:31 +0000 (10:24 -0700)
* 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
geoip/xt_geoip_build_maxmind

index e76663ab88d3f11d50176d2255d0ceb8cf92acee..74a16e8f359341dbef94eb377be82dfa5a401efe 100755 (executable)
@@ -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);
 
index feb9607c78290abc9e59c575c60fb61281bdcf31..05a726c236de55310647a3e98ec0f602b0ee50d5 100755 (executable)
@@ -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);