summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2015-04-01 18:10:11 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2015-04-01 18:10:11 (GMT)
commitaa0a3f7cbd7fd1b230386f434ad472bc06f01b6e (patch) (side-by-side diff)
treeceff5f76bc521497c01116232fbe31489d8de240
parent74828acdf2dcce9e66318a2852ec4473364c7458 (diff)
downloaddnstools-aa0a3f7cbd7fd1b230386f434ad472bc06f01b6e.tar.gz
dnstools-aa0a3f7cbd7fd1b230386f434ad472bc06f01b6e.tar.bz2
nsdbimport: add makefiles
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile2
-rw-r--r--nsdbimport/GNUmakefile2
-rw-r--r--nsdbimport/MANIFEST5
-rw-r--r--nsdbimport/Makefile.PL37
-rwxr-xr-xnsdbimport/nsdbimport22
5 files changed, 64 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 87e377f..36cc766 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-SUBDIRS = dnsdbck rpsl2acl axfr2acl vhostcname renewck whoseip
+SUBDIRS = dnsdbck rpsl2acl axfr2acl vhostcname renewck whoseip nsdbimport
include Make.vars
diff --git a/nsdbimport/GNUmakefile b/nsdbimport/GNUmakefile
new file mode 100644
index 0000000..e61b3c3
--- a/dev/null
+++ b/nsdbimport/GNUmakefile
@@ -0,0 +1,2 @@
+include ../Make.vars
+include ../Make.rules
diff --git a/nsdbimport/MANIFEST b/nsdbimport/MANIFEST
new file mode 100644
index 0000000..822ea34
--- a/dev/null
+++ b/nsdbimport/MANIFEST
@@ -0,0 +1,5 @@
+MANIFEST
+Makefile.PL
+inc/ExtUtils/AutoInstall.pm
+nsdbimport
+
diff --git a/nsdbimport/Makefile.PL b/nsdbimport/Makefile.PL
new file mode 100644
index 0000000..9deb44e
--- a/dev/null
+++ b/nsdbimport/Makefile.PL
@@ -0,0 +1,37 @@
+# -*- perl -*-
+# Copyright (C) 2015 Sergey Poznyakoff <gray@gnu.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+use lib 'inc';
+use ExtUtils::AutoInstall (
+ -core => [
+ 'Getopt::Long' => 2.34,
+ 'Pod::Usage' => 1.51,
+ 'Pod::Man' => 2.25,
+ 'DBI' => 1.607,
+ 'String::Regexp' => 1.00
+ ]
+);
+
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+ 'NAME' => 'nsdbimport',
+ 'AUTHOR' => 'Sergey Poznyakoff <gray@gnu.org>',
+ 'ABSTRACT' => 'converts BIND zone files to SQL database',
+ 'FIRST_MAKEFILE' => 'Makefile',
+ 'VERSION' => '1.00',
+ 'EXE_FILES' => [ 'nsdbimport' ],
+);
diff --git a/nsdbimport/nsdbimport b/nsdbimport/nsdbimport
index dc93c6d..7c72f71 100755
--- a/nsdbimport/nsdbimport
+++ b/nsdbimport/nsdbimport
@@ -36,10 +36,12 @@ my $progname = basename($0); # This script name;
my $progdescr = "converts BIND zone files to SQL database";
my $debug;
my $dry_run;
+my $verbose;
my $bind_directory;
my $bind_config;
my $dbd;
my $generate_seen;
+my $record_count;
sub error {
my $msg = shift;
@@ -61,6 +63,12 @@ sub abend {
exit $code;
}
+END {
+ if ($record_count and ($verbose or $?)) {
+ print "$progname: $record_count records processed successfully\n";
+ }
+}
+
my %config;
sub readconfig {
@@ -195,6 +203,7 @@ sub sql_query {
$dbd->do($q)
or abend(EX_UNAVAILABLE, $dbd->errstr."\nFailed query: $q");
}
+ ++$record_count;
}
# generate($expr, $origin, $file, $line);
@@ -413,6 +422,7 @@ GetOptions("h" => sub {
"bind-config|from-config=s" => \$bind_config,
"origin=s" => \$origin,
"debug|d+" => \$debug,
+ "verbose|v+" => \$verbose,
"dry-run|n" => \$dry_run,
"config|c=s" => \$conffile) or exit(EX_USAGE);
@@ -466,7 +476,7 @@ $arg = 'DBI:mysql'.$arg;
$dbd = DBI->connect($arg, $config{user}, $config{password},
{ PrintError => 0, AutoCommit => 1})
- or exit(EX_UNAVAILABLE);
+ or abend(EX_UNAVAILABLE, "can't connect to the database: ".$DBI::errstr);
if (defined($bind_config)) {
abend(EX_USAGE, "extra input files") if $#ARGV >= 0;
@@ -493,7 +503,7 @@ nsdbimport - import data from BIND-compatible zone files to SQL database
=head1 SYNOPSIS
B<nsdbimport>
-[B<-dhn>]
+[B<-dhnv>]
[B<-C> I<DIR>]
[B<-c> I<FILE>]
[B<--bind-config=>I<FILE>]
@@ -504,7 +514,8 @@ B<nsdbimport>
[B<--from-config=>I<FILE>]
[B<--help>]
[B<--origin=>I<ZONE>]
-[B<--usage>]
+[B<--usage>]
+[B<--verbose>]
[I<ZONEFILE>...]
=head1 DESCRIPTION
@@ -557,6 +568,11 @@ Don't actually import data, print what would have been done instead.
Set initial origin. Useful when processing individual files.
+=item B<-v>, B<--verbose>
+
+Verbose mode. Report count of successfully processed records at the
+end of the run.
+
=back
The following options cause the program to display informative text and

Return to:

Send suggestions and report system problems to the System administrator.