freeside/bin bind.import,1.3.4.1,1.3.4.2
ivan
ivan at pouncequick.420.am
Tue Mar 30 01:20:37 PST 2004
Update of /home/cvs/cvsroot/freeside/bin
In directory pouncequick:/tmp/cvs-serv17764
Modified Files:
Tag: FREESIDE_1_4_BRANCH
bind.import
Log Message:
add -s and -c flags, add ipv6 default zones to list of ignored zones, add nameservice records to existing domains, update for API change inDNS::ZoneParse 0.84
Index: bind.import
===================================================================
RCS file: /home/cvs/cvsroot/freeside/bin/bind.import,v
retrieving revision 1.3.4.1
retrieving revision 1.3.4.2
diff -u -d -r1.3.4.1 -r1.3.4.2
--- bind.import 12 Feb 2004 10:44:13 -0000 1.3.4.1
+++ bind.import 30 Mar 2004 09:20:35 -0000 1.3.4.2
@@ -1,11 +1,16 @@
#!/usr/bin/perl -w
#
-# $Id$
-
-#need to manually put header in /usr/local/etc/freeside/export.<datasrc./bind/<machine>/named.conf.HEADER
+# -s: import slave zones as master. useful if you need to recreate your
+# primary nameserver from a secondary
+# -c chroot_dir: import data from chrooted bind (corrects the path for
+# downloading zone files
+#
+# need to manually put header in
+# /usr/local/etc/freeside/export.<datasrc./bind/<machine>/named.conf.HEADER
use strict;
use vars qw( %d_part_svc );
+use Getopt::Std;
use Term::Query qw(query);
#use BIND::Conf_Parser;
#use DNS::ZoneParse 0.81;
@@ -20,6 +25,9 @@
#use FS::svc_acct;
#use FS::part_svc;
+use vars qw($opt_s $opt_c);
+getopts("sc:");
+
my $user = shift or die &usage;
adminsuidsetup $user;
@@ -99,18 +107,28 @@
sub handle_zone {
my($self, $name, $class, $type, $options) = @_;
return unless $class eq 'in';
- return if grep { $name eq $_ }
- ( qw( . localhost 127.in-addr.arpa 0.in-addr.arpa 255.in-addr.arpa ) );
+ return if grep { $name eq $_ } (qw(
+ . localhost 127.in-addr.arpa 0.in-addr.arpa 255.in-addr.arpa
+ 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa
+ 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.int
+ ));
- my $domain = new FS::svc_domain( {
- svcpart => $main::domain_svcpart,
- domain => $name,
- action => 'N',
- } );
- my $error = $domain->insert;
- die $error if $error;
+ use FS::Record qw(qsearchs);
+ use FS::svc_domain;
- if ( $type eq 'slave' ) {
+ my $domain =
+ qsearchs('svc_domain', { 'domain' => $name } )
+ || new FS::svc_domain( {
+ svcpart => $main::domain_svcpart,
+ domain => $name,
+ action => 'N',
+ } );
+ unless ( $domain->svcnum ) {
+ my $error = $domain->insert;
+ die $error if $error;
+ }
+
+ if ( $type eq 'slave' && !$main::opt_s ) {
#use Data::Dumper;
#print Dumper($options);
@@ -128,7 +146,7 @@
die $error if $error;
}
- } elsif ( $type eq 'master' ) {
+ } elsif ( $type eq 'master' || ( $type eq 'slave' && $main::opt_s ) ) {
my $file = $options->{file};
@@ -136,14 +154,16 @@
my $basefile = basename($file);
my $sourcefile = $file;
$sourcefile = "$named_dir/$sourcefile" unless $file =~ /^\//;
+ $sourcefile = "$main::opt_c/$sourcefile" if $main::opt_c;
+
use Net::SCP qw(iscp scp);
scp("root\@$main::named_machine:$sourcefile",
- "$main::prefix/$basefile.import");
+ "$main::prefix/$basefile.import");
- use DNS::ZoneParse 0.81;
+ use DNS::ZoneParse 0.84;
my $zone = DNS::ZoneParse->new("$main::prefix/$basefile.import");
- my $dump = $zone->Dump;
+ my $dump = $zone->dump;
#use Data::Dumper;
#print "$name: ". Dumper($dump);
@@ -183,6 +203,8 @@
}
}
+ #} else {
+ # die "unrecognized type $type\n";
}
}
More information about the freeside-commits
mailing list