equal
deleted
inserted
replaced
1 #!/usr/bin/perl |
1 #!/usr/bin/perl |
2 |
2 |
3 use strict; |
3 use strict; |
4 |
4 |
5 my $bind_dir = "/etc/bind"; |
5 my %config; |
6 my $conf_dir = "/etc/bind/zones.d"; |
6 open (CONFIG, "dnstools.conf"); |
7 my $master_dir = "/etc/bind/master"; |
7 while (<CONFIG>) { |
|
8 chomp; |
|
9 s/#.*//; |
|
10 s/\t//g; |
|
11 s/\s//g; |
|
12 |
|
13 next unless length; |
|
14 my ($cname, $ccont) = split (/\s*=\s*/, $_,2); |
|
15 $config{$cname} = $ccont; |
|
16 } |
|
17 close (CONFIG); |
|
18 |
|
19 |
|
20 my $bind_dir = $config{bind_dir}; |
|
21 my $conf_dir = $config{zone_conf_dir}; |
|
22 my $master_dir = $config{master_dir}; |
8 chomp (my @conf_dir_files = `ls $conf_dir`); |
23 chomp (my @conf_dir_files = `ls $conf_dir`); |
9 |
24 |
10 # prueft jede domain, die ein verzeichnis in $master_dir hat, ob es eine |
25 # prueft jede domain, die ein verzeichnis in $master_dir hat, ob es eine |
11 # datei $zone_file.signed gibt und ob diese datei in $config_file eingetragen |
26 # datei $zone_file.signed gibt und ob diese datei in $config_file eingetragen |
12 # ist. |
27 # ist. |
23 |
38 |
24 open (FILE, $conf_file); |
39 open (FILE, $conf_file); |
25 @c_content = <FILE>; |
40 @c_content = <FILE>; |
26 close (FILE); |
41 close (FILE); |
27 |
42 |
28 foreach (@c_content) { |
43 for (@c_content) { |
29 if (m{(.*)($zone_file)(";)}) { |
44 if (m{(.*)($zone_file)(";)}) { |
30 print "$2 ==> $2.signed\n"; |
45 print "$2 ==> $2.signed\n"; |
31 $_ = "$1$2.signed$3\n"; |
46 $_ = "$1$2.signed$3\n"; |
32 } |
47 } |
33 |
48 |
41 |
56 |
42 open (FILE, $conf_file); |
57 open (FILE, $conf_file); |
43 @c_content = <FILE>; |
58 @c_content = <FILE>; |
44 close (FILE); |
59 close (FILE); |
45 |
60 |
46 foreach (@c_content) { |
61 for (@c_content) { |
47 if (m{(.*)($zone_file)\.signed(.*)}) { |
62 if (m{(.*)($zone_file)\.signed(.*)}) { |
48 print "$2.signed ==> $2\n"; |
63 print "$2.signed ==> $2\n"; |
49 $_ = "$1$2$3\n"; |
64 $_ = "$1$2$3\n"; |
50 } |
65 } |
51 } |
66 } |
56 } |
71 } |
57 } |
72 } |
58 |
73 |
59 # erzeugt eine named.conf-datei aus den entsprechenden vorlagen. |
74 # erzeugt eine named.conf-datei aus den entsprechenden vorlagen. |
60 open( TO, ">$bind_dir/named.conf.zones"); |
75 open( TO, ">$bind_dir/named.conf.zones"); |
61 foreach (@conf_dir_files) { |
76 for (@conf_dir_files) { |
62 open (FROM, "$conf_dir/$_"); |
77 open (FROM, "$conf_dir/$_"); |
63 print TO <FROM>; |
78 print TO <FROM>; |
64 close (FROM); |
79 close (FROM); |
65 } |
80 } |
66 close(TO); |
81 close(TO); |