Changeset 547 for branches/stable/tiny-import.pl
- Timestamp:
- 12/11/13 15:45:18 (10 years ago)
- Location:
- branches/stable
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable
-
branches/stable/tiny-import.pl
r545 r547 27 27 28 28 use lib '.'; 29 use DNSDB qw(:ALL); 30 31 if (!loadConfig()) { 32 warn "Using default configuration; unable to load custom settings: $DNSDB::errstr"; 33 } 29 use DNSDB; 30 31 my $dnsdb = new DNSDB; 34 32 35 33 usage() if !@ARGV; … … 77 75 78 76 my $code; 79 my ($dbh,$msg) = connectDB($config{dbname}, $config{dbuser}, $config{dbpass}, $config{dbhost}); 80 initGlobals($dbh) if $dbh; 77 my $dbh = $dnsdb->{dbh}; 81 78 82 79 $dbh->{AutoCommit} = 0; … … 85 82 my %cnt; 86 83 my @deferred; 84 my $converted = 0; 87 85 my $errstr = ''; 88 86 … … 167 165 168 166 # .. but we can at least say how many records weren't imported. 169 print "$ok OK, ".scalar(@deferred)." deferred records in $flatfile\n";170 $#deferred = -1;171 167 print "$ok OK, ".scalar(@deferred)." deferred, $converted downconverted records in $flatfile\n"; 168 undef @deferred; 169 $converted = 0; 172 170 173 171 # Sub for various nonstandard types with lots of pure bytes expressed in octal … … 250 248 my $nodefer = shift || 0; 251 249 my $impok = 1; 250 my $msg; 252 251 253 252 $errstr = $rec; # this way at least we have some idea what went <splat> … … 268 267 $loc = '' if !$loc; 269 268 $loc = '' if $loc =~ /^:+$/; 270 my $fparent = DNSDB::_hostparent($dbh,$host);269 my $fparent = $dnsdb->_hostparent($host); 271 270 my ($rparent) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >> ?", undef, ($ip)); 272 271 if ($fparent && $rparent) { 273 272 $recsth->execute($fparent, $rparent, $host, 65280, $ip, 0, 0, 0, $ttl, $loc); 274 273 } else { 275 push @deferred, $rec unless $nodefer; 276 $impok = 0; 277 # print "$tmporig deferred; can't find both forward and reverse zone parents\n"; 274 if ($importcfg{conv}) { 275 # downconvert A+PTR if forward zone is not found 276 $recsth->execute(0, $rparent, $host, 12, $ip, 0, 0, 0, $ttl, $loc); 277 $converted++; 278 } else { 279 push @deferred, $rec unless $nodefer; 280 $impok = 0; 281 # print "$tmporig deferred; can't find both forward and reverse zone parents\n"; 282 } 278 283 } 279 284 … … 301 306 302 307 } else { 303 my $fparent = DNSDB::_hostparent($dbh,$host);308 my $fparent = $dnsdb->_hostparent($host); 304 309 if ($fparent) { 305 310 $recsth->execute($fparent, 0, $host, 5, $targ, 0, 0, 0, $ttl, $loc); … … 337 342 } 338 343 } else { 339 my $fparent = DNSDB::_hostparent($dbh,$zone);344 my $fparent = $dnsdb->_hostparent($zone); 340 345 if ($fparent) { 341 346 $recsth->execute($fparent, 0, $zone, 2, $ns, 0, 0, 0, $ttl, $loc); … … 389 394 $loc = '' if $loc =~ /^:+$/; 390 395 391 my $domid = DNSDB::_hostparent($dbh,$host);396 my $domid = $dnsdb->_hostparent($host); 392 397 if ($domid) { 393 398 $recsth->execute($domid, 0, $host, 1, $ip, 0, 0, 0, $ttl, $loc); … … 440 445 441 446 # allow for subzone MXes, since it's perfectly legitimate to simply stuff it all in a single parent zone 442 my $domid = DNSDB::_hostparent($dbh,$zone);447 my $domid = $dnsdb->_hostparent($zone); 443 448 if ($domid) { 444 449 $recsth->execute($domid, 0, $zone, 15, $host, $dist, 0, 0, $ttl, $loc); … … 466 471 $recsth->execute(0, $rparent, $rdata, 16, "$msg", 0, 0, 0, $ttl, $loc); 467 472 } else { 468 my $domid = DNSDB::_hostparent($dbh,$fqdn);473 my $domid = $dnsdb->_hostparent($fqdn); 469 474 if ($domid) { 470 475 $recsth->execute($domid, 0, $fqdn, 16, $rdata, 0, 0, 0, $ttl, $loc); … … 581 586 # } 582 587 583 my $domid = DNSDB::_hostparent($dbh,$fqdn);588 my $domid = $dnsdb->_hostparent($fqdn); 584 589 if ($domid) { 585 590 $recsth->execute($domid, 0, $fqdn, 33, $target, $prio, $weight, $port, $ttl, $loc) if $domid; … … 599 604 my $val = NetAddr::IP->new(join(':', @v6)); 600 605 601 my $fparent = DNSDB::_hostparent($dbh,$fqdn);606 my $fparent = $dnsdb->_hostparent($fqdn); 602 607 if ($fparent) { 603 608 $recsth->execute($fparent, 0, $fqdn, 28, $val->addr, 0, 0, 0, $ttl, $loc); … … 621 626 } 622 627 } else { 623 my $domid = DNSDB::_hostparent($dbh,$fqdn);628 my $domid = $dnsdb->_hostparent($fqdn); 624 629 if ($domid) { 625 630 $recsth->execute($domid, 0, $fqdn, 16, $txtstring, 0, 0, 0, $ttl, $loc); … … 649 654 } 650 655 } else { 651 my $domid = DNSDB::_hostparent($dbh,$fqdn);656 my $domid = $dnsdb->_hostparent($fqdn); 652 657 if ($domid) { 653 658 $recsth->execute($domid, 0, $fqdn, 17, "$email $txtrec", 0, 0, 0, $ttl, $loc); … … 665 670 666 671 # these do not make sense in a reverse zone, since they're logically attached to an A record 667 my $domid = DNSDB::_hostparent($dbh,$fqdn);672 my $domid = $dnsdb->_hostparent($fqdn); 668 673 if ($domid) { 669 674 $recsth->execute($domid, 0, $fqdn, 44, $sshfp, 0, 0, 0, $ttl, $loc);
Note:
See TracChangeset
for help on using the changeset viewer.