From: "Philip Prindeville" <philipp@redfish-solutions.com>
To: netfilter-devel@vger.kernel.org
Cc: Jan Engelhardt <jengelh@inai.de>,
Philip Prindeville <philipp@redfish-solutions.com>
Subject: [PATCH 1/1] geoip: add quiet flag to xt_geoip_build
Date: Mon, 25 May 2020 14:05:42 -0600 [thread overview]
Message-ID: <20200525200542.29000-1-philipp@redfish-solutions.com> (raw)
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(-)
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)) {
--
2.17.2
next reply other threads:[~2020-05-25 20:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-25 20:05 Philip Prindeville [this message]
2020-05-26 12:59 ` [PATCH 1/1] geoip: add quiet flag to xt_geoip_build Jan Engelhardt
2020-07-26 17:32 ` Philip Prindeville
2020-07-28 12:01 ` Xtables-addons 3.10 (Re: [PATCH 1/1] geoip: add quiet flag to xt_geoip_build) Jan Engelhardt
2020-07-28 22:56 ` Philip Prindeville
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200525200542.29000-1-philipp@redfish-solutions.com \
--to=philipp@redfish-solutions.com \
--cc=jengelh@inai.de \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).