1 |
diff -Nur e-smith-tinydns-2.4.0/createlinks e-smith-tinydns-2.4.0.bz2388/createlinks |
diff -Nur e-smith-tinydns-2.4.0/createlinks e-smith-tinydns-2.4.0.bz2388/createlinks |
2 |
--- e-smith-tinydns-2.4.0/createlinks 2006-03-14 23:01:42.000000000 +0100 |
--- e-smith-tinydns-2.4.0/createlinks 2006-03-14 23:01:42.000000000 +0100 |
3 |
+++ e-smith-tinydns-2.4.0.bz2388/createlinks 2015-01-09 22:18:42.489639249 +0100 |
+++ e-smith-tinydns-2.4.0.bz2388/createlinks 2015-01-17 18:02:35.489764844 +0100 |
4 |
@@ -26,3 +26,24 @@ |
@@ -26,3 +26,19 @@ |
5 |
service_link_enhanced("tinydns", "K65", "6"); |
service_link_enhanced("tinydns", "K65", "6"); |
6 |
service_link_enhanced("tinydns", "K65", "0"); |
service_link_enhanced("tinydns", "K65", "0"); |
7 |
service_link_enhanced("tinydns", "K65", "1"); |
service_link_enhanced("tinydns", "K65", "1"); |
10 |
+ for my $event (qw( dhcp-dns )) |
+ for my $event (qw( dhcp-dns )) |
11 |
+ { |
+ { |
12 |
+ # services to launch on event |
+ # services to launch on event |
13 |
+ safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/dnscache"); |
+ safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/dnscache"); |
14 |
+ safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/tinydns"); |
+ safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/tinydns"); |
|
+ safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/dhcpd"); |
|
|
+ safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/dhcp-dns"); |
|
|
+ |
|
|
+ # Template to event |
|
|
+ templates2events("/var/service/tinydns/root/data", $event); |
|
15 |
+ } |
+ } |
16 |
+ |
+ |
17 |
+#creation of dhcp-dns service |
+#creation of dhcp-dns service |
23 |
+ safe_symlink("/var/service/dhcp-dns/", "root/service/dhcp-dns"); |
+ safe_symlink("/var/service/dhcp-dns/", "root/service/dhcp-dns"); |
24 |
diff -Nur e-smith-tinydns-2.4.0/root/etc/e-smith/db/configuration/defaults/dhcp-dns/status e-smith-tinydns-2.4.0.bz2388/root/etc/e-smith/db/configuration/defaults/dhcp-dns/status |
diff -Nur e-smith-tinydns-2.4.0/root/etc/e-smith/db/configuration/defaults/dhcp-dns/status e-smith-tinydns-2.4.0.bz2388/root/etc/e-smith/db/configuration/defaults/dhcp-dns/status |
25 |
--- e-smith-tinydns-2.4.0/root/etc/e-smith/db/configuration/defaults/dhcp-dns/status 1970-01-01 01:00:00.000000000 +0100 |
--- e-smith-tinydns-2.4.0/root/etc/e-smith/db/configuration/defaults/dhcp-dns/status 1970-01-01 01:00:00.000000000 +0100 |
26 |
+++ e-smith-tinydns-2.4.0.bz2388/root/etc/e-smith/db/configuration/defaults/dhcp-dns/status 2015-01-08 13:33:30.870973725 +0100 |
+++ e-smith-tinydns-2.4.0.bz2388/root/etc/e-smith/db/configuration/defaults/dhcp-dns/status 2015-01-16 20:02:12.050969025 +0100 |
27 |
@@ -0,0 +1 @@ |
@@ -0,0 +1 @@ |
28 |
+enabled |
+enabled |
29 |
diff -Nur e-smith-tinydns-2.4.0/root/etc/e-smith/db/configuration/defaults/dhcp-dns/type e-smith-tinydns-2.4.0.bz2388/root/etc/e-smith/db/configuration/defaults/dhcp-dns/type |
diff -Nur e-smith-tinydns-2.4.0/root/etc/e-smith/db/configuration/defaults/dhcp-dns/type e-smith-tinydns-2.4.0.bz2388/root/etc/e-smith/db/configuration/defaults/dhcp-dns/type |
30 |
--- e-smith-tinydns-2.4.0/root/etc/e-smith/db/configuration/defaults/dhcp-dns/type 1970-01-01 01:00:00.000000000 +0100 |
--- e-smith-tinydns-2.4.0/root/etc/e-smith/db/configuration/defaults/dhcp-dns/type 1970-01-01 01:00:00.000000000 +0100 |
31 |
+++ e-smith-tinydns-2.4.0.bz2388/root/etc/e-smith/db/configuration/defaults/dhcp-dns/type 2015-01-08 13:33:30.870973725 +0100 |
+++ e-smith-tinydns-2.4.0.bz2388/root/etc/e-smith/db/configuration/defaults/dhcp-dns/type 2015-01-16 20:02:12.050969025 +0100 |
32 |
@@ -0,0 +1 @@ |
@@ -0,0 +1 @@ |
33 |
+service |
+service |
34 |
diff -Nur e-smith-tinydns-2.4.0/root/etc/e-smith/templates/var/service/tinydns/root/data/65dhcpARecords e-smith-tinydns-2.4.0.bz2388/root/etc/e-smith/templates/var/service/tinydns/root/data/65dhcpARecords |
diff -Nur e-smith-tinydns-2.4.0/root/etc/e-smith/templates/var/service/tinydns/root/data/65dhcpARecords e-smith-tinydns-2.4.0.bz2388/root/etc/e-smith/templates/var/service/tinydns/root/data/65dhcpARecords |
35 |
--- e-smith-tinydns-2.4.0/root/etc/e-smith/templates/var/service/tinydns/root/data/65dhcpARecords 1970-01-01 01:00:00.000000000 +0100 |
--- e-smith-tinydns-2.4.0/root/etc/e-smith/templates/var/service/tinydns/root/data/65dhcpARecords 1970-01-01 01:00:00.000000000 +0100 |
36 |
+++ e-smith-tinydns-2.4.0.bz2388/root/etc/e-smith/templates/var/service/tinydns/root/data/65dhcpARecords 2015-01-09 22:09:02.149175482 +0100 |
+++ e-smith-tinydns-2.4.0.bz2388/root/etc/e-smith/templates/var/service/tinydns/root/data/65dhcpARecords 2015-01-17 19:45:33.892642388 +0100 |
37 |
@@ -0,0 +1,76 @@ |
@@ -0,0 +1,107 @@ |
38 |
+{ |
+{ |
39 |
+ # we need perl-Date-Manip to convert to a unix timestamp |
+ use strict; |
40 |
+ use Date::Manip qw /UnixDate/; |
+ use warnings; |
41 |
+ |
+ use esmith::Logger; |
42 |
|
+ use esmith::ConfigDB; |
43 |
+ # we need perl-Time-TAI64 for timestamp conversion |
+ # we need perl-Time-TAI64 for timestamp conversion |
44 |
+ use Time::TAI64 qw /unixtai64/; |
+ use Time::TAI64 qw /unixtai64/; |
45 |
|
+ # we need perl-Date-Manip to convert to a unix timestamp |
46 |
|
+ use Date::Manip qw /UnixDate/; |
47 |
|
+ use File::Copy; |
48 |
|
+ |
49 |
|
+ my $DB = esmith::ConfigDB->open_ro or die ("cannot open configuration database"); |
50 |
|
+ |
51 |
|
+ #we start a hash for name because we don't want several same names & ip |
52 |
|
+ my %allocated_name = (); |
53 |
|
+ my %allocated_ip_dhcplease = (); |
54 |
+ |
+ |
55 |
+ # copy of dhcpd.leases file to /tmp because working directly on the original |
+ # copy of dhcpd.leases file to /tmp because working directly on the original |
56 |
+ # is not a good idea |
+ # is not a good idea |
57 |
+ use File::Copy; |
+ copy("/var/lib/dhcpd/dhcpd.leases","/tmp/tmpdhcpd.leases") |
58 |
+ copy('/var/lib/dhcpd/dhcpd.leases', '/tmp/dhcpd.leases') |
+ or die ("Error dhcp-dns Service : Unable to copy the /var/lib/dhcpd/dhcpd.leases"); |
59 |
+ or die ("Error dhcp-dns Service : Can't copy the /var/lib/dhcpd/dhcpd.leases"); |
+ |
60 |
|
+ #we create a fonction because we want to write in log |
61 |
|
+ sub log2messages |
62 |
|
+ { |
63 |
|
+ my $message = shift; |
64 |
|
+ tie *FH, 'esmith::Logger'; |
65 |
|
+ print FH "$message"; |
66 |
|
+ close FH; |
67 |
|
+ } |
68 |
|
+ |
69 |
+ |
+ |
70 |
+ #Text::DHCPparse forked because it doesn't allow to retrieve the end of lease |
+ #Text::DHCPparse forked because it doesn't allow to retrieve the end of lease |
71 |
+ #Only the start is found by the leaseparse of DHCPparse.pm s/starts/ends |
+ #Only the start is found by the leaseparse of DHCPparse.pm s/starts/ends |
98 |
+} |
+} |
99 |
+ |
+ |
100 |
+ # now we parse the leases |
+ # now we parse the leases |
101 |
+ $return = leaseparse('/tmp/dhcpd.leases'); |
+ my $return = leaseparse('/tmp/tmpdhcpd.leases'); |
102 |
+ |
+ my ($ip,$time,$mac,$name); |
103 |
+ # variable with local domain value (default is mycompamy.local) |
+ |
104 |
+ my $localdomain = get_local_domainname; |
+ # variable with local domain value (default is mycompamy.local) and retrieve the server name |
105 |
|
+ my $localdomain = $DB->get_value('DomainName') or die ("Unable retrieve the DomainName property"); |
106 |
|
+ my $servername = $DB->get_value('SystemName') or die ("Unable retrieve the SystemName property"); |
107 |
+ |
+ |
108 |
+ $OUT .= "# A records for dhcp hosts in $localdomain\n"; |
+ $OUT .= "# A records for dhcp hosts in $localdomain\n"; |
109 |
+ |
+ |
110 |
+ foreach (keys %$return) { |
+ foreach (keys %$return) { |
111 |
+ ($ip, $time, $mac, $name) = unpack("A17 A21 A19 A30", $return->{$_}); |
+ ($ip, $time, $mac, $name) = unpack("A17 A21 A19 A30", $return->{$_}); |
112 |
+ # when the dhcp lease is over $name is empty .. we want only non empty one |
+ |
113 |
+ if ( $name ne "" ) { |
+ # when the dhcp lease is over $name is empty .. we want only non empty one |
114 |
+ # we skip also ips already allocated |
+ if ( $name ne "" ) |
115 |
+ unless (exists $allocated_ips{$ip}) |
+ { |
116 |
|
+ # we skip also ips & names already allocated |
117 |
|
+ unless (exists $allocated_ip_dhcplease{$ip} || exists $allocated_name{$name}) |
118 |
+ { |
+ { |
119 |
+ # Convert lease end time to the format expected as |
+ # Convert lease end time to the format expected as |
120 |
+ # see: http://cr.yp.to/djbdns/tinydns-data.html |
+ # see: http://cr.yp.to/djbdns/tinydns-data.html |
125 |
+ # Determine TTL |
+ # Determine TTL |
126 |
+ my $ttl = ''; |
+ my $ttl = ''; |
127 |
+ $ttl = 0 unless ($ts <= time); |
+ $ttl = 0 unless ($ts <= time); |
128 |
+ $OUT .= "=$name.$localdomain:$ip:$ttl:$endtai\n"; |
+ $OUT .= "=$name.$localdomain:$ip:$ttl:$endtai\n" unless ($name eq $servername); |
129 |
|
+ log2messages("The hostname of this server ($servername) is already in use with a different IP address in /var/lib/dhcpd/dhcpd.leases") |
130 |
|
+ if ($name eq $servername); |
131 |
+ } |
+ } |
132 |
+ $allocated_ips{$ip} = 1; |
+ |
133 |
|
+ $allocated_ip_dhcplease{$ip} = 1; |
134 |
|
+ $allocated_name{$name} ++; |
135 |
|
+ |
136 |
|
+ log2messages("The hostname \"$name\" has already been assigned an IP address in /var/lib/dhcpd/dhcpd.leases") |
137 |
|
+ if ($allocated_name{$name} >1); |
138 |
+ } |
+ } |
139 |
+ } |
+ } |
140 |
+ # remove the temp file |
+ # remove the temp file |
141 |
+ system ("rm -f /tmp/dhcpd.leases") ==0 |
+ unlink "/tmp/tmpdhcpd.leases" |
142 |
+ or die ("Error dhcp-dns Service : Can't rm the /tmp/dhcpd.leases"); |
+ or log2messages("Error dhcp-dns Service : Unable to remove the /tmp/tmpdhcpd.leases"); |
143 |
+} |
+} |
144 |
|
+ |
145 |
diff -Nur e-smith-tinydns-2.4.0/root/var/service/dhcp-dns/dhcp-dns e-smith-tinydns-2.4.0.bz2388/root/var/service/dhcp-dns/dhcp-dns |
diff -Nur e-smith-tinydns-2.4.0/root/var/service/dhcp-dns/dhcp-dns e-smith-tinydns-2.4.0.bz2388/root/var/service/dhcp-dns/dhcp-dns |
146 |
--- e-smith-tinydns-2.4.0/root/var/service/dhcp-dns/dhcp-dns 1970-01-01 01:00:00.000000000 +0100 |
--- e-smith-tinydns-2.4.0/root/var/service/dhcp-dns/dhcp-dns 1970-01-01 01:00:00.000000000 +0100 |
147 |
+++ e-smith-tinydns-2.4.0.bz2388/root/var/service/dhcp-dns/dhcp-dns 2015-01-09 22:22:32.389241240 +0100 |
+++ e-smith-tinydns-2.4.0.bz2388/root/var/service/dhcp-dns/dhcp-dns 2015-01-17 18:06:32.318810671 +0100 |
148 |
@@ -0,0 +1,38 @@ |
@@ -0,0 +1,45 @@ |
149 |
+#!/usr/bin/perl |
+#!/usr/bin/perl |
150 |
|
+use strict; |
151 |
|
+use warnings; |
152 |
+ |
+ |
153 |
+my $lease_file = "/var/lib/dhcpd/dhcpd.leases"; |
+my $lease_file = "/var/lib/dhcpd/dhcpd.leases"; |
154 |
+ |
+ |
158 |
+# seconds to wait |
+# seconds to wait |
159 |
+my $update_freq = 30; |
+my $update_freq = 30; |
160 |
+ |
+ |
161 |
|
+#we create a function because we want to write in log |
162 |
|
+sub log2messages |
163 |
|
+ { |
164 |
|
+ my $message = shift; |
165 |
|
+ tie *FH, 'esmith::Logger'; |
166 |
|
+ print FH "$message"; |
167 |
|
+ close FH; |
168 |
|
+ } |
169 |
|
+ |
170 |
+########################################################################### |
+########################################################################### |
171 |
+# Main Loop |
+# Main Loop |
172 |
+while (1) { |
+while (1) { |
179 |
+ if ($stats[9] > $modtime) { |
+ if ($stats[9] > $modtime) { |
180 |
+ |
+ |
181 |
+ $modtime = $stats[9]; |
+ $modtime = $stats[9]; |
|
+ system ("expand-template /var/service/tinydns/root/data") ==0 |
|
|
+ or warn ("Error service dhcp-dns : can't do expand-template /var/service/tinydns/root/data"); |
|
|
+ |
|
182 |
+ system ("/usr/bin/sv 1 /service/tinydns") ==0 |
+ system ("/usr/bin/sv 1 /service/tinydns") ==0 |
183 |
+ or warn ("Error service dhcp-dns : can't do sv 1 /service/tinydns"); |
+ or log2messages('Error service dhcp-dns : Unable to restart /service/tinydns'); |
184 |
+ |
+ |
185 |
+ system ("/usr/bin/sv 1 /service/dnscache") ==0 |
+ system ("/usr/bin/sv 1 /service/dnscache") ==0 |
186 |
+ or warn ("Error service dhcp-dns : can't do sv 1 /service/dnscache"); |
+ or log2messages('Error service dhcp-dns : Unable to do restart /service/dnscache'); |
|
+ |
|
187 |
+ } |
+ } |
188 |
+ |
+ |
189 |
+ # wait till next check time |
+ # wait till next check time |
193 |
+########################################################################### |
+########################################################################### |
194 |
diff -Nur e-smith-tinydns-2.4.0/root/var/service/dhcp-dns/run e-smith-tinydns-2.4.0.bz2388/root/var/service/dhcp-dns/run |
diff -Nur e-smith-tinydns-2.4.0/root/var/service/dhcp-dns/run e-smith-tinydns-2.4.0.bz2388/root/var/service/dhcp-dns/run |
195 |
--- e-smith-tinydns-2.4.0/root/var/service/dhcp-dns/run 1970-01-01 01:00:00.000000000 +0100 |
--- e-smith-tinydns-2.4.0/root/var/service/dhcp-dns/run 1970-01-01 01:00:00.000000000 +0100 |
196 |
+++ e-smith-tinydns-2.4.0.bz2388/root/var/service/dhcp-dns/run 2015-01-08 13:33:30.871973834 +0100 |
+++ e-smith-tinydns-2.4.0.bz2388/root/var/service/dhcp-dns/run 2015-01-16 20:02:12.055969339 +0100 |
197 |
@@ -0,0 +1,4 @@ |
@@ -0,0 +1,4 @@ |
198 |
+#!/bin/sh |
+#!/bin/sh |
199 |
+ |
+ |