/[smeserver]/rpms/e-smith-tinydns/sme9/e-smith-tinydns-2.4.0_add_hostname_following_dhcpdleases_hostname.patch
ViewVC logotype

Diff of /rpms/e-smith-tinydns/sme9/e-smith-tinydns-2.4.0_add_hostname_following_dhcpdleases_hostname.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

Revision 1.2 by stephdl, Tue Jun 17 23:11:11 2014 UTC Revision 1.3 by stephdl, Fri Jan 9 23:33:20 2015 UTC
# Line 1  Line 1 
1  diff -Nur e-smith-tinydns-2.4.0.old/createlinks e-smith-tinydns-2.4.0/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.old/createlinks       2014-06-17 23:46:27.046462016 +0200  --- e-smith-tinydns-2.4.0/createlinks   2006-03-14 23:01:42.000000000 +0100
3  +++ e-smith-tinydns-2.4.0/createlinks   2014-06-17 23:47:00.027649759 +0200  +++ e-smith-tinydns-2.4.0.bz2388/createlinks    2015-01-09 22:18:42.489639249 +0100
4  @@ -26,3 +26,27 @@  @@ -26,3 +26,24 @@
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");
# Line 15  diff -Nur e-smith-tinydns-2.4.0.old/crea Line 15  diff -Nur e-smith-tinydns-2.4.0.old/crea
15  +        safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/dhcpd");  +        safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/dhcpd");
16  +        safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/dhcp-dns");  +        safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/dhcp-dns");
17  +          +        
 +        # actions to perform  
 +        safe_symlink("../actions/dnscache-change", "root/etc/e-smith/events/$event/S20dnscache-change");  
 +  
18  +        # Template to event  +        # Template to event
19  +        templates2events("/var/service/tinydns/root/data", $event);  +        templates2events("/var/service/tinydns/root/data", $event);
20  +        }  +        }
# Line 29  diff -Nur e-smith-tinydns-2.4.0.old/crea Line 26  diff -Nur e-smith-tinydns-2.4.0.old/crea
26  +    service_link_enhanced("dhcp-dns", "K65", "0");  +    service_link_enhanced("dhcp-dns", "K65", "0");
27  +    service_link_enhanced("dhcp-dns", "K65", "1");  +    service_link_enhanced("dhcp-dns", "K65", "1");
28  +    safe_symlink("/var/service/dhcp-dns/", "root/service/dhcp-dns");  +    safe_symlink("/var/service/dhcp-dns/", "root/service/dhcp-dns");
29  diff -Nur e-smith-tinydns-2.4.0.old/root/etc/e-smith/db/configuration/defaults/dhcp-dns/status e-smith-tinydns-2.4.0/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
30  --- e-smith-tinydns-2.4.0.old/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
31  +++ e-smith-tinydns-2.4.0/root/etc/e-smith/db/configuration/defaults/dhcp-dns/status    2014-06-17 23:47:00.028649886 +0200  +++ 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
32  @@ -0,0 +1 @@  @@ -0,0 +1 @@
33  +enabled  +enabled
34  diff -Nur e-smith-tinydns-2.4.0.old/root/etc/e-smith/db/configuration/defaults/dhcp-dns/type e-smith-tinydns-2.4.0/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
35  --- e-smith-tinydns-2.4.0.old/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
36  +++ e-smith-tinydns-2.4.0/root/etc/e-smith/db/configuration/defaults/dhcp-dns/type      2014-06-17 23:47:00.029650013 +0200  +++ 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
37  @@ -0,0 +1 @@  @@ -0,0 +1 @@
38  +service  +service
39  diff -Nur e-smith-tinydns-2.4.0.old/root/etc/e-smith/events/actions/dnscache-change e-smith-tinydns-2.4.0/root/etc/e-smith/events/actions/dnscache-change  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
40  --- e-smith-tinydns-2.4.0.old/root/etc/e-smith/events/actions/dnscache-change   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
41  +++ e-smith-tinydns-2.4.0/root/etc/e-smith/events/actions/dnscache-change       2014-06-17 23:47:00.030650140 +0200  +++ 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
42  @@ -0,0 +1,3 @@  @@ -0,0 +1,76 @@
 +#!/bin/sh  
 +  
 +/usr/bin/sv 1 /service/tinydns  
 diff -Nur e-smith-tinydns-2.4.0.old/root/etc/e-smith/templates/var/service/tinydns/root/data/65dhcpARecords e-smith-tinydns-2.4.0/root/etc/e-smith/templates/var/service/tinydns/root/data/65dhcpARecords  
 --- e-smith-tinydns-2.4.0.old/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       2014-06-17 23:52:49.434051111 +0200  
 @@ -0,0 +1,48 @@  
43  +{  +{
 +    # we need perl-Text-DHCPparse rpm from Dag's repo  
 +    use Text::DHCPparse;  
 +  
44  +    # we need perl-Date-Manip to convert to a unix timestamp  +    # we need perl-Date-Manip to convert to a unix timestamp
45  +    use Date::Manip qw /UnixDate/;  +    use Date::Manip qw /UnixDate/;
46  +    +  
# Line 63  diff -Nur e-smith-tinydns-2.4.0.old/root Line 50  diff -Nur e-smith-tinydns-2.4.0.old/root
50  +    # 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
51  +    # is not a good idea  +    # is not a good idea
52  +    use File::Copy;  +    use File::Copy;
53  +    copy('/var/lib/dhcpd/dhcpd.leases', '/tmp/dhcpd.leases');        +    copy('/var/lib/dhcpd/dhcpd.leases', '/tmp/dhcpd.leases')
54  +      +        or die ("Error dhcp-dns Service : Can't copy the /var/lib/dhcpd/dhcpd.leases");
55    +
56    +   #Text::DHCPparse forked because it doesn't allow to retrieve the end of lease
57    +   #Only the start is found by the leaseparse of DHCPparse.pm s/starts/ends
58    +   sub leaseparse {
59    +   my $logfile = shift;
60    +   my ( %list, $ip );
61    +   open FILE, $logfile or die;
62    +
63    +   while (<FILE>) {
64    +      next if /^#|^$/;
65    +      if (/^lease (\d+\.\d+\.\d+\.\d+)/) {
66    +         $ip = $1;
67    +         $list{$ip} = sprintf("%-17s", $ip);
68    +      }
69    +      /^\s*hardware ethernet (.*);/ && ($list{$ip} .= sprintf("%-19s", $1));
70    +      /^\s*ends \d (.*);/ && ($list{$ip} .= sprintf("%-21s", $1));
71    +      /^\s*(abandoned).*/ && ($list{$ip} .= sprintf("%-19s", $1));
72    +      /^\s*client-hostname "(.*)";/ && ($list{$ip} .= sprintf("%-17s", $1));
73    +   }
74    +
75    +   close FILE;
76    +
77    +   # make all entries 74 characters long to format properly
78    +   foreach (keys %list) {
79    +      #$list{$_} = sprintf("%-74s", $list{$_}) if (length$list{$_} < 76);
80    +      $list{$_} = sprintf("%-74.74s", $list{$_});
81    +   }
82    +
83    +   return \%list;
84    +}
85    +
86  +    # now we parse the leases  +    # now we parse the leases
87  +    $return = leaseparse('/tmp/dhcpd.leases');  +    $return = leaseparse('/tmp/dhcpd.leases');
88  +    +  
# Line 75  diff -Nur e-smith-tinydns-2.4.0.old/root Line 93  diff -Nur e-smith-tinydns-2.4.0.old/root
93  +  +
94  +    foreach (keys %$return) {  +    foreach (keys %$return) {
95  +        ($ip, $time, $mac, $name) = unpack("A17 A21 A19 A30", $return->{$_});  +        ($ip, $time, $mac, $name) = unpack("A17 A21 A19 A30", $return->{$_});
96  +  +         # when the dhcp lease is over $name is empty .. we want only non empty one
 +        # when the dhcp lease is over $name is empty .. we want only non empty one  
97  +         if ( $name ne "" ) {  +         if ( $name ne "" ) {
98  +            # we skip also ips already allocated  +            # we skip also ips already allocated
99  +            unless (exists $allocated_ips{$ip})  +            unless (exists $allocated_ips{$ip})
# Line 96  diff -Nur e-smith-tinydns-2.4.0.old/root Line 113  diff -Nur e-smith-tinydns-2.4.0.old/root
113  +        }  +        }
114  +    }  +    }
115  +    # remove the temp file  +    # remove the temp file
116  +    system "rm -f /tmp/dhcpd.leases";  +    system ("rm -f /tmp/dhcpd.leases") ==0
117    +       or die ("Error dhcp-dns Service : Can't rm the /tmp/dhcpd.leases");
118  +}  +}
119  diff -Nur e-smith-tinydns-2.4.0.old/root/var/service/dhcp-dns/dhcp-dns e-smith-tinydns-2.4.0/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
120  --- e-smith-tinydns-2.4.0.old/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
121  +++ e-smith-tinydns-2.4.0/root/var/service/dhcp-dns/dhcp-dns    2014-06-17 23:47:00.031650267 +0200  +++ e-smith-tinydns-2.4.0.bz2388/root/var/service/dhcp-dns/dhcp-dns     2015-01-09 22:22:32.389241240 +0100
122  @@ -0,0 +1,33 @@  @@ -0,0 +1,38 @@
123  +#!/usr/bin/perl  +#!/usr/bin/perl
124  +  +
125  +my $lease_file = "/var/lib/dhcpd/dhcpd.leases";  +my $lease_file = "/var/lib/dhcpd/dhcpd.leases";
# Line 110  diff -Nur e-smith-tinydns-2.4.0.old/root Line 128  diff -Nur e-smith-tinydns-2.4.0.old/root
128  +my $modtime = 0;  +my $modtime = 0;
129  +  +
130  +# seconds to wait  +# seconds to wait
131  +my $update_freq = 15;  +my $update_freq = 30;
132  +  +
133  +###########################################################################  +###########################################################################
134  +# Main Loop  +# Main Loop
# Line 124  diff -Nur e-smith-tinydns-2.4.0.old/root Line 142  diff -Nur e-smith-tinydns-2.4.0.old/root
142  +  if ($stats[9] > $modtime) {  +  if ($stats[9] > $modtime) {
143  +    +  
144  +       $modtime = $stats[9];  +       $modtime = $stats[9];
145    +        system ("expand-template /var/service/tinydns/root/data") ==0
146    +            or warn ("Error service dhcp-dns : can't do expand-template /var/service/tinydns/root/data");
147    +
148    +        system ("/usr/bin/sv 1 /service/tinydns") ==0
149    +            or warn ("Error service dhcp-dns : can't do sv 1 /service/tinydns");
150    +
151    +        system ("/usr/bin/sv 1 /service/dnscache") ==0
152    +            or warn ("Error service dhcp-dns : can't do sv 1 /service/dnscache");
153  +  +
 +        system ("/usr/bin/sv 1 /service/tinydns");  
154  +  }  +  }
155  +  +
156  +  # wait till next check time  +  # wait till next check time
# Line 133  diff -Nur e-smith-tinydns-2.4.0.old/root Line 158  diff -Nur e-smith-tinydns-2.4.0.old/root
158  +  +
159  +} # end main  +} # end main
160  +###########################################################################  +###########################################################################
161  +  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
162  +  --- e-smith-tinydns-2.4.0/root/var/service/dhcp-dns/run 1970-01-01 01:00:00.000000000 +0100
163  diff -Nur e-smith-tinydns-2.4.0.old/root/var/service/dhcp-dns/run 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  2015-01-08 13:33:30.871973834 +0100
 --- e-smith-tinydns-2.4.0.old/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 2014-06-17 23:47:00.032650394 +0200  
164  @@ -0,0 +1,4 @@  @@ -0,0 +1,4 @@
165  +#!/bin/sh  +#!/bin/sh
166  +  +


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed