equal
deleted
inserted
replaced
1 # Example |
|
2 # $Id$ |
|
3 # $URL$ |
|
4 |
|
5 # remove the next line if you know, what you're doing |
|
6 die "Sure? You should adapt this file to your needs!"; |
|
7 |
|
8 package local; |
|
9 |
|
10 # in: zone name |
|
11 # src ip |
|
12 # out: 0 failure ($@ contains message) |
|
13 # !0 ok ($@ may contain message) |
|
14 sub addZone($$) { |
|
15 my ($zone, $src) = @_; |
|
16 |
|
17 # Filename ist für das File selbst und auch für die Konfig |
|
18 (my $file = $zone) =~ s/[\/&|]/_/g; |
|
19 |
|
20 my $txt = <<__; |
|
21 // Autoadded %time by $0 |
|
22 zone "$zone" IN { |
|
23 type slave; |
|
24 file "/etc/bind/s/$file"; |
|
25 masters { %masters; }; |
|
26 allow-query { any; }; |
|
27 allow-transfer { none; }; |
|
28 }; |
|
29 |
|
30 __ |
|
31 |
|
32 $txt =~ s/%time/scalar localtime/eg; |
|
33 $txt =~ s/%masters/$src/g; |
|
34 |
|
35 if (-f ($_ = "/etc/bind/zones.d/$file")) { |
|
36 $@ = "$_ already exists"; |
|
37 return 0; |
|
38 } |
|
39 |
|
40 open(OUT, $_ = ">$_") or die "Can't open $_: $!\n"; |
|
41 print OUT $txt; |
|
42 |
|
43 open(OUT, $_ = ">>/etc/bind/zones.all") or die "Can't open $_: $!\n"; |
|
44 print OUT $txt; |
|
45 |
|
46 close OUT; |
|
47 |
|
48 # return 0 == system("rndc reload"); |
|
49 local @ARGV = qw(/var/run/bind/run/named.pid); |
|
50 chomp($_ = <>); |
|
51 warn "Sending HUP to $_\n"; |
|
52 $@ = "Nameserver reloaded (HUP sent)"; |
|
53 kill "HUP", $_ and return 1; |
|
54 |
|
55 $@ = "No process $_"; |
|
56 return 0; |
|
57 } |
|
58 |
|
59 |
|
60 1; |
|
61 # vim:sts=4 sw=4 aw ai sm: |
|