diff mbox series

[1/1] geoip: add quiet flag to xt_geoip_build

Message ID 20200525200542.29000-1-philipp@redfish-solutions.com
State Awaiting Upstream
Delegated to: Pablo Neira
Headers show
Series [1/1] geoip: add quiet flag to xt_geoip_build | expand

Commit Message

Philip Prindeville May 25, 2020, 8:05 p.m. UTC
From: Philip Prindeville <philipp@redfish-solutions.com>

Conceivably someone might want to run a refresh of the geoip database
from within a script, particularly an unattended script such as a cron
job.  Don't generate output in that case.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
---
 geoip/xt_geoip_build | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Jan Engelhardt May 26, 2020, 12:59 p.m. UTC | #1
On Monday 2020-05-25 22:05, Philip Prindeville wrote:

>From: Philip Prindeville <philipp@redfish-solutions.com>
>
>Conceivably someone might want to run a refresh of the geoip database
>from within a script, particularly an unattended script such as a cron
>job.  Don't generate output in that case.

added.
Philip Prindeville July 26, 2020, 5:32 p.m. UTC | #2
> On May 26, 2020, at 6:59 AM, Jan Engelhardt <jengelh@inai.de> wrote:
> 
> On Monday 2020-05-25 22:05, Philip Prindeville wrote:
> 
>> From: Philip Prindeville <philipp@redfish-solutions.com>
>> 
>> Conceivably someone might want to run a refresh of the geoip database
>> from within a script, particularly an unattended script such as a cron
>> job.  Don't generate output in that case.
> 
> added.


Thanks.

BTW, when is 3.10 due out?
Jan Engelhardt July 28, 2020, 12:01 p.m. UTC | #3
On Sunday 2020-07-26 19:32, Philip Prindeville wrote:
>> On May 26, 2020, at 6:59 AM, Jan Engelhardt <jengelh@inai.de> wrote:
>> On Monday 2020-05-25 22:05, Philip Prindeville wrote:
>
>>> Conceivably someone might want to run a refresh of the geoip database
>>> from within a script, particularly an unattended script such as a cron
>>> job.  Don't generate output in that case.
>
>BTW, when is 3.10 due out?

I have tagged 3.10 and produced the tarballs.
Take note that the homepage etc. has moved to

	https://inai.de/projects/xtables-addons/

Downloads, new git location, and redirects from sf.net
should be all there.
Philip Prindeville July 28, 2020, 10:56 p.m. UTC | #4
> On Jul 28, 2020, at 6:01 AM, Jan Engelhardt <jengelh@inai.de> wrote:
> 
> On Sunday 2020-07-26 19:32, Philip Prindeville wrote:
>>> On May 26, 2020, at 6:59 AM, Jan Engelhardt <jengelh@inai.de> wrote:
>>> On Monday 2020-05-25 22:05, Philip Prindeville wrote:
>> 
>>>> Conceivably someone might want to run a refresh of the geoip database
>>>> from within a script, particularly an unattended script such as a cron
>>>> job.  Don't generate output in that case.
>> 
>> BTW, when is 3.10 due out?
> 
> I have tagged 3.10 and produced the tarballs.
> Take note that the homepage etc. has moved to
> 
> 	https://inai.de/projects/xtables-addons/
> 
> Downloads, new git location, and redirects from sf.net
> should be all there.


Awesome. Thanks!
diff mbox series

Patch

diff --git a/geoip/xt_geoip_build b/geoip/xt_geoip_build
index e7ad9bfdcc1e3b617ada77872f9be87e126b885f..84333892e61e463269790580b08ac5c33d994018 100644
--- a/geoip/xt_geoip_build
+++ b/geoip/xt_geoip_build
@@ -17,11 +17,14 @@  my $csv = Text::CSV_XS->new({
 	binary => 1,
 	eol => $/,
 }); # or Text::CSV
+
+my $quiet = 0;
 my $source_dir = ".";
 my $target_dir = ".";
 
 &Getopt::Long::Configure(qw(bundling));
 &GetOptions(
+	"q" => \$quiet,
 	"D=s" => \$target_dir,
 	"S=s" => \$source_dir,
 );
@@ -63,12 +66,12 @@  sub collect
 			$country{$cc}->{pool_v6}->add_range($range);
 		}
 
-		if ($. % 4096 == 0) {
+		if (!$quiet && $. % 4096 == 0) {
 			print STDERR "\r\e[2K$. entries";
 		}
 	}
 
-	print STDERR "\r\e[2K$. entries total\n";
+	print STDERR "\r\e[2K$. entries total\n" unless ($quiet);
 
 	close($fh);
 
@@ -106,7 +109,7 @@  sub writeCountry
 	printf "%5u IPv%s ranges for %s\n",
 		scalar(@ranges),
 		($family == AF_INET ? '4' : '6'),
-		$iso_code;
+		$iso_code unless ($quiet);
 
 	my $file = "$target_dir/".uc($iso_code).".iv".($family == AF_INET ? '4' : '6');
 	if (!open($fh, '>', $file)) {