Changeset 821 for trunk/bind-import
- Timestamp:
- 12/04/20 13:26:33 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bind-import
r820 r821 31 31 32 32 my $dnsdb = new DNSDB; 33 my $d oimport = 1;33 my $dryrun = 0; 34 34 35 35 #print Dumper(\%reverse_typemap); … … 59 59 "skip=s" => \@skipdefs, 60 60 "skipfile=s" => \$skipfile, 61 "test|dry-run" => sub { $doimport = 0; },61 "test|dry-run" => \$dryrun, 62 62 ); 63 63 … … 72 72 A file containing patterns to skip. Patterns from the file and 73 73 any --skip arguments are merged. 74 --dry-run 75 Do everything except finalize the import 74 76 zonename 75 77 The name of the zone to import. Required. … … 131 133 ##fixme: this is wrong, BIND zone files are generally complete and we're adding. merging records is an entire fridge full of worms. 132 134 ##fixme: for import, should arguably check for zone *non*existence 135 133 136 if ($zname =~ /\.arpa\.?$/ || $zname =~ m,^[\d./]+$,) { 134 137 $rev = 'y'; … … 137 140 if ($zid) { 138 141 die "zone $origzone already present, not merging records\n"; 139 $zname = new NetAddr::IP $zname; 140 $zname = DNSDB::_ZONE($zname, 'ZONE', 'r', '.').($zname->{isv6} ? '.ip6.arpa' : '.in-addr.arpa'); 142 #print "dbg: skip add domain\n"; 143 # $zname = new NetAddr::IP $zname; 144 # $zname = DNSDB::_ZONE($zname, 'ZONE', 'r', '.').($zname->{isv6} ? '.ip6.arpa' : '.in-addr.arpa'); 141 145 } 142 146 ($zid) = $dnsdb->{dbh}->selectrow_array("INSERT INTO revzones (revnet,group_id,status,default_location,zserial) VALUES (?,?,?,?,?) RETURNING rnds_id", … … 144 148 145 149 } else { 146 print "dbg: forward zone\n";147 150 $zid = $dnsdb->domainID($zname,':ANY:'); 148 151 if ($zid) { 149 #die "zone $origzone already present, not merging records\n";150 print "dbg: skip add domain\n";151 } else {152 152 die "zone $origzone already present, not merging records\n"; 153 #print "dbg: skip add domain\n"; 154 } 155 ($zid) = $dnsdb->{dbh}->selectrow_array("INSERT INTO domains (domain,group_id,status,default_location,zserial) VALUES (?,?,?,?,?) RETURNING domain_id", 153 156 undef, ($zname, $group, $status, $location, $serial)); 154 }155 157 156 158 } … … 557 559 } 558 560 559 no warnings qw(uninitialized); 560 #print "parsed: '$curlabel' '$class' '$ttl' '$type'->'$itype' '$rdata'\n"; 561 #print; 562 #;imap IN 900 CNAME deepnet.cx. 563 ##fixme: not sure how to handle the case where someone leaves off the class. 564 if ($doimport) { 561 ##fixme: need to dig out a subtransaction widget or extract a core of addRec() that doesn't dbh->commit(), so --dry-run works 562 # unless ($dryrun) { 565 563 my ($code, $msg); 566 564 if ($rev eq 'n') { … … 572 570 } 573 571 print "$code: $msg\n" if $code ne 'OK'; 574 }572 # } 575 573 # $i++; 576 574 } 577 575 576 if ($dryrun) { 577 $dnsdb->{dbh}->rollback; 578 } else { 579 $dnsdb->{dbh}->commit; 580 } 578 581 }; 579 582 if ($@) {
Note:
See TracChangeset
for help on using the changeset viewer.