1 |
diff -Nur --no-dereference smeserver-dhcp-dns-1.2.0.old/createlinks smeserver-dhcp-dns-1.2.0/createlinks |
2 |
--- smeserver-dhcp-dns-1.2.0.old/createlinks 2015-07-30 11:01:23.000000000 -0400 |
3 |
+++ smeserver-dhcp-dns-1.2.0/createlinks 2021-03-30 22:40:49.542000000 -0400 |
4 |
@@ -4,17 +4,22 @@ |
5 |
|
6 |
|
7 |
#link to services2adjust and templates2expand for dhcp-dns event |
8 |
-for my $event (qw( dhcp-dns )) |
9 |
+for my $event (qw( dhcp-dns smeserver-dhcp-dns-update)) |
10 |
{ |
11 |
# services to launch on event |
12 |
safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/dnscache"); |
13 |
safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/tinydns"); |
14 |
+ safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/dhcp-dns"); |
15 |
} |
16 |
+ |
17 |
+my $event = "smeserver-dhcp-dns-update"; |
18 |
+event_link("systemd-reload", $event, "89"); |
19 |
+event_link("systemd-default", $event, "88"); |
20 |
|
21 |
#creation of dhcp-dns service |
22 |
- safe_symlink("daemontools", "root/etc/rc.d/init.d/dhcp-dns"); |
23 |
- service_link_enhanced("dhcp-dns", "S85", "7"); |
24 |
- service_link_enhanced("dhcp-dns", "K65", "6"); |
25 |
- service_link_enhanced("dhcp-dns", "K65", "0"); |
26 |
- service_link_enhanced("dhcp-dns", "K65", "1"); |
27 |
- safe_symlink("/var/service/dhcp-dns/", "root/service/dhcp-dns"); |
28 |
+# safe_symlink("daemontools", "root/etc/rc.d/init.d/dhcp-dns"); |
29 |
+# service_link_enhanced("dhcp-dns", "S85", "7"); |
30 |
+# service_link_enhanced("dhcp-dns", "K65", "6"); |
31 |
+# service_link_enhanced("dhcp-dns", "K65", "0"); |
32 |
+# service_link_enhanced("dhcp-dns", "K65", "1"); |
33 |
+# safe_symlink("/var/service/dhcp-dns/", "root/service/dhcp-dns"); |
34 |
diff -Nur --no-dereference smeserver-dhcp-dns-1.2.0.old/root/sbin/e-smith/systemd/dhcp-dns smeserver-dhcp-dns-1.2.0/root/sbin/e-smith/systemd/dhcp-dns |
35 |
--- smeserver-dhcp-dns-1.2.0.old/root/sbin/e-smith/systemd/dhcp-dns 1969-12-31 19:00:00.000000000 -0500 |
36 |
+++ smeserver-dhcp-dns-1.2.0/root/sbin/e-smith/systemd/dhcp-dns 2015-07-30 11:01:23.000000000 -0400 |
37 |
@@ -0,0 +1,49 @@ |
38 |
+#!/usr/bin/perl |
39 |
+use strict; |
40 |
+use warnings; |
41 |
+use esmith::ConfigDB; |
42 |
+ |
43 |
+my $DB = esmith::ConfigDB->open_ro or die ("Unable to open configuration database"); |
44 |
+my $dhcpdns = $DB->get_prop('dhcp-dns','status') || 'disabled'; |
45 |
+ |
46 |
+my $lease_file = "/var/lib/dhcpd/dhcpd.leases"; |
47 |
+ |
48 |
+# last modified time |
49 |
+my $modtime = 0; |
50 |
+ |
51 |
+# seconds to wait |
52 |
+my $update_freq = 30; |
53 |
+ |
54 |
+#we want to write in log |
55 |
+sub log2messages |
56 |
+ { |
57 |
+ my $message = shift; |
58 |
+ tie *FH, 'esmith::Logger'; |
59 |
+ print FH "$message"; |
60 |
+ close FH; |
61 |
+ } |
62 |
+ |
63 |
+########################################################################### |
64 |
+# Main Loop |
65 |
+while ($dhcpdns eq 'enabled') { |
66 |
+ |
67 |
+ # check the file's last updated time, if it's been changed, update |
68 |
+ # the DNS and save the modified time. This will ALWAYS run once - on |
69 |
+ # startup, since $modtime starts at zero. |
70 |
+ |
71 |
+ my @stats = stat ($lease_file); |
72 |
+ if ($stats[9] > $modtime) { |
73 |
+ |
74 |
+ $modtime = $stats[9]; |
75 |
+ system ("/usr/bin/sv 1 /service/tinydns") ==0 |
76 |
+ or log2messages('Error service dhcp-dns : Unable to restart /service/tinydns'); |
77 |
+ |
78 |
+ system ("/usr/bin/sv 1 /service/dnscache") ==0 |
79 |
+ or log2messages('Error service dhcp-dns : Unable to do restart /service/dnscache'); |
80 |
+ } |
81 |
+ |
82 |
+ # wait till next check time |
83 |
+ sleep $update_freq; |
84 |
+ |
85 |
+} # end main |
86 |
+########################################################################### |
87 |
diff -Nur --no-dereference smeserver-dhcp-dns-1.2.0.old/root/usr/lib/systemd/system/dhcp-dns.service smeserver-dhcp-dns-1.2.0/root/usr/lib/systemd/system/dhcp-dns.service |
88 |
--- smeserver-dhcp-dns-1.2.0.old/root/usr/lib/systemd/system/dhcp-dns.service 1969-12-31 19:00:00.000000000 -0500 |
89 |
+++ smeserver-dhcp-dns-1.2.0/root/usr/lib/systemd/system/dhcp-dns.service 2021-03-30 22:48:48.599000000 -0400 |
90 |
@@ -0,0 +1,11 @@ |
91 |
+[Unit] |
92 |
+Description=DHCP leases to DNS |
93 |
+After=tinydns.service dhcpd.service |
94 |
+ |
95 |
+[Service] |
96 |
+ExecStartPre=/sbin/e-smith/service-status dhcp-dns |
97 |
+ExecStart=/usr/bin/perl /sbin/e-smith/systemd/dhcp-dns |
98 |
+RemainAfterExit=yes |
99 |
+ |
100 |
+[Install] |
101 |
+WantedBy=sme-server.target |
102 |
diff -Nur --no-dereference smeserver-dhcp-dns-1.2.0.old/root/var/service/dhcp-dns/dhcp-dns smeserver-dhcp-dns-1.2.0/root/var/service/dhcp-dns/dhcp-dns |
103 |
--- smeserver-dhcp-dns-1.2.0.old/root/var/service/dhcp-dns/dhcp-dns 2015-07-30 11:01:23.000000000 -0400 |
104 |
+++ smeserver-dhcp-dns-1.2.0/root/var/service/dhcp-dns/dhcp-dns 1969-12-31 19:00:00.000000000 -0500 |
105 |
@@ -1,49 +0,0 @@ |
106 |
-#!/usr/bin/perl |
107 |
-use strict; |
108 |
-use warnings; |
109 |
-use esmith::ConfigDB; |
110 |
- |
111 |
-my $DB = esmith::ConfigDB->open_ro or die ("Unable to open configuration database"); |
112 |
-my $dhcpdns = $DB->get_prop('dhcp-dns','status') || 'disabled'; |
113 |
- |
114 |
-my $lease_file = "/var/lib/dhcpd/dhcpd.leases"; |
115 |
- |
116 |
-# last modified time |
117 |
-my $modtime = 0; |
118 |
- |
119 |
-# seconds to wait |
120 |
-my $update_freq = 30; |
121 |
- |
122 |
-#we want to write in log |
123 |
-sub log2messages |
124 |
- { |
125 |
- my $message = shift; |
126 |
- tie *FH, 'esmith::Logger'; |
127 |
- print FH "$message"; |
128 |
- close FH; |
129 |
- } |
130 |
- |
131 |
-########################################################################### |
132 |
-# Main Loop |
133 |
-while ($dhcpdns eq 'enabled') { |
134 |
- |
135 |
- # check the file's last updated time, if it's been changed, update |
136 |
- # the DNS and save the modified time. This will ALWAYS run once - on |
137 |
- # startup, since $modtime starts at zero. |
138 |
- |
139 |
- my @stats = stat ($lease_file); |
140 |
- if ($stats[9] > $modtime) { |
141 |
- |
142 |
- $modtime = $stats[9]; |
143 |
- system ("/usr/bin/sv 1 /service/tinydns") ==0 |
144 |
- or log2messages('Error service dhcp-dns : Unable to restart /service/tinydns'); |
145 |
- |
146 |
- system ("/usr/bin/sv 1 /service/dnscache") ==0 |
147 |
- or log2messages('Error service dhcp-dns : Unable to do restart /service/dnscache'); |
148 |
- } |
149 |
- |
150 |
- # wait till next check time |
151 |
- sleep $update_freq; |
152 |
- |
153 |
-} # end main |
154 |
-########################################################################### |