local.pm.ex
changeset 13 82ecd75a4ee2
parent 11 d1dd256c037a
equal deleted inserted replaced
12:2a605c25d2c5 13:82ecd75a4ee2
    12 # out:  0 failure ($@ contains message)
    12 # out:  0 failure ($@ contains message)
    13 #      !0 ok      ($@ may contain message)
    13 #      !0 ok      ($@ may contain message)
    14 sub addZone($$) {
    14 sub addZone($$) {
    15     my ($zone, $src) = @_;
    15     my ($zone, $src) = @_;
    16 
    16 
       
    17     # Filename ist für das File selbst und auch für die Konfig
       
    18     (my $file = $zone) =~ s/[\/&|]/_/g;
       
    19 
    17     my $txt = <<__;
    20     my $txt = <<__;
    18 // Autoadded %time by $0
    21 // Autoadded %time by $0
    19 zone "$zone" IN {
    22 zone "$zone" IN {
    20     type slave;
    23     type slave;
    21     file "/var/cache/bind/slave/$zone";
    24     file "/etc/bind/s/$file";
    22     masters { %masters; };
    25     masters { %masters; };
    23     allow-query { any; };
    26     allow-query { any; };
    24     allow-transfer { none; };
    27     allow-transfer { none; };
    25 };
    28 };
    26 
    29 
    27 __
    30 __
    28 
    31 
    29     $txt =~ s/%time/scalar localtime/eg;
    32     $txt =~ s/%time/scalar localtime/eg;
    30     $txt =~ s/%masters/$src/g;
    33     $txt =~ s/%masters/$src/g;
    31 
    34 
    32     if (-f ($_ = "/etc/bind/zones.auto/$zone")) {
    35     if (-f ($_ = "/etc/bind/zones.d/$file")) {
    33 	$@ = "$_ already exists";
    36 	$@ = "$_ already exists";
    34 	return 0;
    37 	return 0;
    35     }
    38     }
    36 
    39 
    37     open(OUT, $_ = ">$_") or die "Can't open $_: $!\n";
    40     open(OUT, $_ = ">$_") or die "Can't open $_: $!\n";