5 -z --zonesdir=s Where the named.conf's are expected [$opt_zonesdir] |
5 -z --zonesdir=s Where the named.conf's are expected [$opt_zonesdir] |
6 -u --[no]update Update the \"masters\"-entries [$opt_update] |
6 -u --[no]update Update the \"masters\"-entries [$opt_update] |
7 -f --[no]follow Follow the end of the logfile [$opt_follow] |
7 -f --[no]follow Follow the end of the logfile [$opt_follow] |
8 -d --[no]debug extra debug output [$opt_debug] |
8 -d --[no]debug extra debug output [$opt_debug] |
9 -h --help This text [$opt_help] |
9 -h --help This text [$opt_help] |
|
10 --daemon go into background [$opt_daemon] |
|
11 -p --pidfile=s file to store the pid [$opt_pidfile] |
10 # |
12 # |
11 # Es wird ein Verzeichnis geben, in diesem Verzeichnis liegt für |
13 # Es wird ein Verzeichnis geben, in diesem Verzeichnis liegt für |
12 # *jede* Zone eine eigene Konfigurations-Datei. |
14 # *jede* Zone eine eigene Konfigurations-Datei. |
13 # Diese ganzen Konfigurationsdateien werden dann zusammengefaßt |
15 # Diese ganzen Konfigurationsdateien werden dann zusammengefaßt |
14 # und diese zusammengefaßte wird dem bind per "include" mitgeteilt. |
16 # und diese zusammengefaßte wird dem bind per "include" mitgeteilt. |
50 "212.80.235.130" => "pu.schlittermann.de", |
52 "212.80.235.130" => "pu.schlittermann.de", |
51 "212.80.235.132" => "mango.compot.com", |
53 "212.80.235.132" => "mango.compot.com", |
52 "145.253.160.50" => "bastion.actech.de", |
54 "145.253.160.50" => "bastion.actech.de", |
53 "62.144.175.34" => "ns.add-on.de", |
55 "62.144.175.34" => "ns.add-on.de", |
54 "195.145.19.34" => "ns.datom.de", |
56 "195.145.19.34" => "ns.datom.de", |
|
57 "62.157.194.1" => "ns.mueritzcomp.de", |
|
58 "212.80.235.137" => "ns.flaemingnet.de omni.flaemingnet.de", |
|
59 "212.80.235.152" => "www.proton24.de", |
55 # "194.162.141.17" => "dalx1.nacamar.de", |
60 # "194.162.141.17" => "dalx1.nacamar.de", |
56 ); |
61 ); |
57 |
62 |
58 $SIG{__DIE__} = sub { syslog(LOG_ERR, $_[0]); exit -1; }; |
63 $SIG{__DIE__} = sub { syslog(LOG_ERR, $_[0]); exit -1; }; |
59 $SIG{__WARN__} = sub { syslog(LOG_WARNING, $_[0]); }; |
64 $SIG{__WARN__} = sub { syslog(LOG_WARNING, $_[0]); }; |
60 |
65 |
61 my %seen; |
66 my %seen; |
62 |
67 |
63 my $opt_help = 0; |
68 my $opt_help = 0; |
|
69 my $opt_pidfile = "/var/run/$ME.pid"; |
64 my $opt_logfile = "/var/log/syslog"; |
70 my $opt_logfile = "/var/log/syslog"; |
65 my $opt_zonesdir = "/etc/bind/zones.d"; |
71 my $opt_zonesdir = "/etc/bind/zones.d"; |
66 my $opt_follow = 0; |
72 my $opt_follow = 0; |
67 my $opt_update = 0; |
73 my $opt_update = 0; |
68 my $opt_debug = 0; |
74 my $opt_debug = 0; |
|
75 my $opt_daemon = 0; |
69 |
76 |
70 my $naptime = 60; |
77 my $naptime = 60; |
71 |
78 |
72 |
79 |
73 sub updateFile($$$); |
80 sub updateFile($$$); |
83 "help" => \$opt_help, |
90 "help" => \$opt_help, |
84 "logfile=s" => \$opt_logfile, |
91 "logfile=s" => \$opt_logfile, |
85 "follow!" => \$opt_follow, |
92 "follow!" => \$opt_follow, |
86 "update!" => \$opt_update, |
93 "update!" => \$opt_update, |
87 "debug!" => \$opt_debug, |
94 "debug!" => \$opt_debug, |
|
95 "daemon!" => \$opt_daemon, |
|
96 "pidfile=s" => \$opt_pidfile, |
88 "zonesdir=s" => \$opt_zonesdir) |
97 "zonesdir=s" => \$opt_zonesdir) |
89 or die "$ME: Bad Usage\n"; |
98 or die "$ME: Bad Usage\n"; |
90 |
99 |
91 if ($opt_help) { |
100 if ($opt_help) { |
92 print eval "\"$USAGE\""; |
101 print eval "\"$USAGE\""; |
93 exit 0; |
102 exit 0; |
94 } |
103 } |
95 |
104 |
96 open (LOGFILE, $_ = "<$opt_logfile") or die "Can't open $_: $!\n"; |
105 open (LOGFILE, $_ = "<$opt_logfile") or die "Can't open $_: $!\n"; |
|
106 |
|
107 # Go Daemon |
|
108 #if ($opt_daemon) { |
|
109 # my $pid = fork(); |
|
110 # if |
|
111 # } |
|
112 |
|
113 # Create the PID-File |
|
114 { |
|
115 open(PID, $_ = ">$opt_pidfile.$$") or die "Can't open $opt_pidfile: $!\n"; |
|
116 print PID "$$\n"; |
|
117 close(PID); |
|
118 |
|
119 if (!rename($_ = "$opt_pidfile.$$", $opt_pidfile)) { |
|
120 unlink "$opt_pidfile.$$"; |
|
121 die "There's another $ME running. Bad. Stop."; |
|
122 } |
|
123 } |
|
124 |
97 for (;;) { |
125 for (;;) { |
98 my (%masters, %missing, %nomasters); |
126 my (%masters, %missing, %nomasters); |
99 while (<LOGFILE>) { |
127 while (<LOGFILE>) { |
100 |
128 |
101 my ($domain, $ip); |
129 my ($domain, $ip); |