equal
deleted
inserted
replaced
19 use File::Basename; |
19 use File::Basename; |
20 use File::Copy; |
20 use File::Copy; |
21 use FindBin; |
21 use FindBin; |
22 |
22 |
23 my @configs = ( "$FindBin::Bin/dnstools.conf", "/etc/dnstools.conf" ); |
23 my @configs = ( "$FindBin::Bin/dnstools.conf", "/etc/dnstools.conf" ); |
|
24 my @dnssec_killkeys |
|
25 = ( "$FindBin::Bin/dnssec-killkey", "/usr/bin/dnstools/dnssec-killkey" ); |
|
26 my $dnssec_killkey; |
|
27 my @dnssec_creatkeys |
|
28 = ( "$FindBin::Bin/dnssec-creatkey", "/usr/bin/dnstools/dnssec-creatkey" ); |
|
29 my $dnssec_creatkey; |
24 my @dnssec_signs |
30 my @dnssec_signs |
25 = ( "$FindBin::Bin/dnssec-sign", "/usr/bin/dnstools/dnssec-sign" ); |
31 = ( "$FindBin::Bin/dnssec-sign", "/usr/bin/dnstools/dnssec-sign" ); |
26 my %config; |
32 my %config; |
27 my $dnssec_sign; |
33 my $dnssec_sign; |
28 my @change_names = (); |
34 my @change_names = (); |
31 open( CONFIG, $_ ) or die "Can't open $_: $!\n"; |
37 open( CONFIG, $_ ) or die "Can't open $_: $!\n"; |
32 } |
38 } |
33 |
39 |
34 unless ( seek( CONFIG, 0, 0 ) ) { |
40 unless ( seek( CONFIG, 0, 0 ) ) { |
35 die "Can't open config (searched: @configs)\n"; |
41 die "Can't open config (searched: @configs)\n"; |
|
42 } |
|
43 foreach ( grep {-f} @dnssec_killkeys ) { |
|
44 if ( -x $_ ) { |
|
45 $dnssec_killkey = $_; |
|
46 } |
|
47 else { |
|
48 die "Can't run $_\n"; |
|
49 } |
|
50 } |
|
51 foreach ( grep {-f} @dnssec_creatkeys ) { |
|
52 if ( -x $_ ) { |
|
53 $dnssec_creatkey = $_; |
|
54 } |
|
55 else { |
|
56 die "Can't run $_\n"; |
|
57 } |
36 } |
58 } |
37 foreach ( grep {-f} @dnssec_signs ) { |
59 foreach ( grep {-f} @dnssec_signs ) { |
38 if ( -x $_ ) { |
60 if ( -x $_ ) { |
39 $dnssec_sign = $_; |
61 $dnssec_sign = $_; |
40 } |
62 } |
63 my $verbose = 0; |
85 my $verbose = 0; |
64 my $opt_yes = 0; |
86 my $opt_yes = 0; |
65 my @Zones; |
87 my @Zones; |
66 my $file; |
88 my $file; |
67 |
89 |
|
90 |
68 sub cleanup() { unlink @tmpfiles; } |
91 sub cleanup() { unlink @tmpfiles; } |
69 END { cleanup(); } |
92 END { cleanup(); } |
70 |
93 |
71 for (@ARGV) { |
94 for (@ARGV) { |
72 if ( $_ eq "-y" ) { |
95 if ( $_ eq "-y" ) { |
76 } |
99 } |
77 |
100 |
78 @Zones = @ARGV ? @ARGV : glob("$master_dir/*"); |
101 @Zones = @ARGV ? @ARGV : glob("$master_dir/*"); |
79 |
102 |
80 MAIN: { |
103 MAIN: { |
81 my $changed; |
104 my $changed = 0; |
82 my ( $dd, $mm, $yy ) = ( localtime() )[ 3 .. 5 ]; |
105 my ( $dd, $mm, $yy ) = ( localtime() )[ 3 .. 5 ]; |
83 my $date; |
106 my $date; |
84 $mm++; |
107 $mm++; |
85 |
108 |
86 # prueft jede domain, die ein verzeichnis in $master_dir hat, ob sie |
109 # prueft jede domain, die ein verzeichnis in $master_dir hat, ob sie |
107 for (@c_content) { |
130 for (@c_content) { |
108 if (m{(.*)($zone_file)(";)}) { |
131 if (m{(.*)($zone_file)(";)}) { |
109 print "$2 ==> $2.signed\n"; |
132 print "$2 ==> $2.signed\n"; |
110 $_ = "$1$2.signed$3\n"; |
133 $_ = "$1$2.signed$3\n"; |
111 } |
134 } |
112 |
|
113 open( FILE, ">$conf_file" ) or die "$conf_file: $!\n"; |
|
114 print FILE @c_content; |
|
115 close(FILE); |
|
116 |
|
117 } |
135 } |
|
136 |
|
137 open( FILE, ">$conf_file" ) or die "$conf_file: $!\n"; |
|
138 print FILE @c_content; |
|
139 close(FILE); |
|
140 |
118 } |
141 } |
119 else { |
142 else { |
120 |
143 |
121 open( FILE, "<$conf_file" ) or die "$conf_file: $!\n"; |
144 open( FILE, "<$conf_file" ) or die "$conf_file: $!\n"; |
122 @c_content = <FILE>; |
145 @c_content = <FILE>; |
134 close(FILE); |
157 close(FILE); |
135 } |
158 } |
136 } |
159 } |
137 |
160 |
138 # erzeugt eine named.conf-datei aus den entsprechenden vorlagen. |
161 # erzeugt eine named.conf-datei aus den entsprechenden vorlagen. |
|
162 print "** creat named.conf.zones **\n"; |
139 open( TO, ">$bind_dir/named.conf.zones" ) |
163 open( TO, ">$bind_dir/named.conf.zones" ) |
140 or die "$bind_dir/named.conf.zones: $!\n"; |
164 or die "$bind_dir/named.conf.zones: $!\n"; |
141 while (<$conf_dir/*>) { |
165 while (<$conf_dir/*>) { |
142 open( FROM, "$_" ) or die "$_: $! \n"; |
166 open( FROM, "$_" ) or die "$_: $! \n"; |
143 print TO <FROM>; |
167 print TO <FROM>; |
144 close(FROM); |
168 close(FROM); |
145 } |
169 } |
146 close(TO); |
170 close(TO); |
147 |
171 |
|
172 # aufruf von sign-killkey |
|
173 print "** execute dnssec-killkey for keyrollover **\n"; |
|
174 system "$dnssec_killkey"; |
|
175 die "$dnssec_killkey not found ($!)" if $? == -1; |
|
176 exit 1 if $?; |
|
177 |
|
178 # aufruf von sign-creatkey |
|
179 print "** execute dnssec-creatkey for keyrollover **\n"; |
|
180 system "$dnssec_creatkey"; |
|
181 die "$dnssec_creatkey not found ($!)" if $? == -1; |
|
182 exit 1 if $?; |
|
183 |
148 # update-serial |
184 # update-serial |
|
185 print "** update serial **\n"; |
149 foreach ( $dd, $mm ) { s/^\d$/0$&/; } |
186 foreach ( $dd, $mm ) { s/^\d$/0$&/; } |
150 $yy += 1900; |
187 $yy += 1900; |
151 $date = "$yy$mm$dd"; |
188 $date = "$yy$mm$dd"; |
152 |
189 |
153 while ( my $file = shift @Zones ) { |
190 while ( my $file = shift @Zones ) { |
219 print "\n"; |
256 print "\n"; |
220 } |
257 } |
221 |
258 |
222 my $pidfile; |
259 my $pidfile; |
223 |
260 |
224 print |
261 unless ($changed == 0) { |
225 "** Changed $changed files, the nameserver needs to be reloaded!\n"; |
262 print "Changed $changed files.\n"; |
|
263 } |
|
264 |
226 foreach ( |
265 foreach ( |
227 qw(/var/run/bind/run/named.pid /var/run/named.pid /etc/named.pid)) |
266 qw(/var/run/bind/run/named.pid /var/run/named.pid /etc/named.pid)) |
228 { |
267 { |
229 -f $_ and $pidfile = $_ and last; |
268 -f $_ and $pidfile = $_ and last; |
230 } |
269 } |
231 |
270 |
232 # dnssec-sign aufruf fuer geanderten domains |
271 # dnssec-sign aufruf fuer geanderten domains |
|
272 print "** execute dnssec-sign **\n"; |
233 system "$dnssec_sign @change_names"; |
273 system "$dnssec_sign @change_names"; |
234 die "$dnssec_sign not found ($!)" if $? == -1; |
274 die "$dnssec_sign not found ($!)" if $? == -1; |
235 exit 1 if $?; |
275 exit 1 if $?; |
236 |
276 |
237 if ($pidfile) { |
277 if ($pidfile) { |