diff -Nur --no-dereference smeserver-dhcp-dns-1.2.0.old/createlinks smeserver-dhcp-dns-1.2.0/createlinks --- smeserver-dhcp-dns-1.2.0.old/createlinks 2015-07-30 11:01:23.000000000 -0400 +++ smeserver-dhcp-dns-1.2.0/createlinks 2021-03-30 22:40:49.542000000 -0400 @@ -4,17 +4,22 @@ #link to services2adjust and templates2expand for dhcp-dns event -for my $event (qw( dhcp-dns )) +for my $event (qw( dhcp-dns smeserver-dhcp-dns-update)) { # services to launch on event safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/dnscache"); safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/tinydns"); + safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/dhcp-dns"); } + +my $event = "smeserver-dhcp-dns-update"; +event_link("systemd-reload", $event, "89"); +event_link("systemd-default", $event, "88"); #creation of dhcp-dns service - safe_symlink("daemontools", "root/etc/rc.d/init.d/dhcp-dns"); - service_link_enhanced("dhcp-dns", "S85", "7"); - service_link_enhanced("dhcp-dns", "K65", "6"); - service_link_enhanced("dhcp-dns", "K65", "0"); - service_link_enhanced("dhcp-dns", "K65", "1"); - safe_symlink("/var/service/dhcp-dns/", "root/service/dhcp-dns"); +# safe_symlink("daemontools", "root/etc/rc.d/init.d/dhcp-dns"); +# service_link_enhanced("dhcp-dns", "S85", "7"); +# service_link_enhanced("dhcp-dns", "K65", "6"); +# service_link_enhanced("dhcp-dns", "K65", "0"); +# service_link_enhanced("dhcp-dns", "K65", "1"); +# safe_symlink("/var/service/dhcp-dns/", "root/service/dhcp-dns"); 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 --- smeserver-dhcp-dns-1.2.0.old/root/sbin/e-smith/systemd/dhcp-dns 1969-12-31 19:00:00.000000000 -0500 +++ smeserver-dhcp-dns-1.2.0/root/sbin/e-smith/systemd/dhcp-dns 2015-07-30 11:01:23.000000000 -0400 @@ -0,0 +1,49 @@ +#!/usr/bin/perl +use strict; +use warnings; +use esmith::ConfigDB; + +my $DB = esmith::ConfigDB->open_ro or die ("Unable to open configuration database"); +my $dhcpdns = $DB->get_prop('dhcp-dns','status') || 'disabled'; + +my $lease_file = "/var/lib/dhcpd/dhcpd.leases"; + +# last modified time +my $modtime = 0; + +# seconds to wait +my $update_freq = 30; + +#we want to write in log +sub log2messages + { + my $message = shift; + tie *FH, 'esmith::Logger'; + print FH "$message"; + close FH; + } + +########################################################################### +# Main Loop +while ($dhcpdns eq 'enabled') { + + # check the file's last updated time, if it's been changed, update + # the DNS and save the modified time. This will ALWAYS run once - on + # startup, since $modtime starts at zero. + + my @stats = stat ($lease_file); + if ($stats[9] > $modtime) { + + $modtime = $stats[9]; + system ("/usr/bin/sv 1 /service/tinydns") ==0 + or log2messages('Error service dhcp-dns : Unable to restart /service/tinydns'); + + system ("/usr/bin/sv 1 /service/dnscache") ==0 + or log2messages('Error service dhcp-dns : Unable to do restart /service/dnscache'); + } + + # wait till next check time + sleep $update_freq; + +} # end main +########################################################################### 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 --- smeserver-dhcp-dns-1.2.0.old/root/usr/lib/systemd/system/dhcp-dns.service 1969-12-31 19:00:00.000000000 -0500 +++ smeserver-dhcp-dns-1.2.0/root/usr/lib/systemd/system/dhcp-dns.service 2021-03-30 22:48:48.599000000 -0400 @@ -0,0 +1,11 @@ +[Unit] +Description=DHCP leases to DNS +After=tinydns.service dhcpd.service + +[Service] +ExecStartPre=/sbin/e-smith/service-status dhcp-dns +ExecStart=/usr/bin/perl /sbin/e-smith/systemd/dhcp-dns +RemainAfterExit=yes + +[Install] +WantedBy=sme-server.target 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 --- smeserver-dhcp-dns-1.2.0.old/root/var/service/dhcp-dns/dhcp-dns 2015-07-30 11:01:23.000000000 -0400 +++ smeserver-dhcp-dns-1.2.0/root/var/service/dhcp-dns/dhcp-dns 1969-12-31 19:00:00.000000000 -0500 @@ -1,49 +0,0 @@ -#!/usr/bin/perl -use strict; -use warnings; -use esmith::ConfigDB; - -my $DB = esmith::ConfigDB->open_ro or die ("Unable to open configuration database"); -my $dhcpdns = $DB->get_prop('dhcp-dns','status') || 'disabled'; - -my $lease_file = "/var/lib/dhcpd/dhcpd.leases"; - -# last modified time -my $modtime = 0; - -# seconds to wait -my $update_freq = 30; - -#we want to write in log -sub log2messages - { - my $message = shift; - tie *FH, 'esmith::Logger'; - print FH "$message"; - close FH; - } - -########################################################################### -# Main Loop -while ($dhcpdns eq 'enabled') { - - # check the file's last updated time, if it's been changed, update - # the DNS and save the modified time. This will ALWAYS run once - on - # startup, since $modtime starts at zero. - - my @stats = stat ($lease_file); - if ($stats[9] > $modtime) { - - $modtime = $stats[9]; - system ("/usr/bin/sv 1 /service/tinydns") ==0 - or log2messages('Error service dhcp-dns : Unable to restart /service/tinydns'); - - system ("/usr/bin/sv 1 /service/dnscache") ==0 - or log2messages('Error service dhcp-dns : Unable to do restart /service/dnscache'); - } - - # wait till next check time - sleep $update_freq; - -} # end main -###########################################################################