* Sat Mar 01 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-6.sme

- move to full systemd units [SME: 12878]
This commit is contained in:
Jean-Philippe Pialasse 2025-03-04 22:51:37 -05:00
parent 0caf31efad
commit ece8bff7f3
24 changed files with 120 additions and 119 deletions

View File

@ -2,13 +2,15 @@
use esmith::Build::CreateLinks qw(:all);
foreach (qw(root/servers/@ config))
{
templates2events("/var/service/dnscache.forwarder/$_",
templates2events("/var/service/dnscache.forwarder/root/servers/@",
qw(bootstrap-console-save console-save dns-update smeserver-dnscache-update));
}
templates2events('/var/service/dnscache/root/servers/@',
qw(bootstrap-console-save console-save dns-update smeserver-dnscache-update));
templates2events("/usr/lib/systemd/system/dnscache.forwarder.service.d/51koozali.conf",
qw(bootstrap-console-save console-save dns-update smeserver-dnscache-update));
templates2events("/usr/lib/systemd/system/dnscache.service.d/51koozali.conf",
qw(bootstrap-console-save console-save dns-update smeserver-dnscache-update));
event_link("systemd-reload", qw(console-save dns-update), "89")
foreach my $event (qw(
console-save
@ -41,6 +43,9 @@ event_link("initialize-default-databases", "domain-modify", "00");
#--------------------------------------------------
$event = "smeserver-dnscache-update";
templates2events("/etc/systemd/system-preset/49-koozali.preset", $event);
templates2events("/usr/lib/systemd/system/dnscache.forwarder.service.d/51koozali.conf", $event);
templates2events("/usr/lib/systemd/system/dnscache.service.d/51koozali.conf", $event);
templates2events("/etc/rsyslog.conf", $event);
safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/rsyslog");
event_link("systemd-reload", $event, "89");

View File

@ -0,0 +1,6 @@
#dnscache
:programname, isequal, "dnscache" /var/log/dnscache/dnscache.log
& stop
:programname, isequal, "dnscache.forwarder" /var/log/dnscache.forwarder/dnscache.forwarder.log
& stop

View File

@ -0,0 +1,10 @@
[Service]
{
my $datalimit = $dnscache{'DataLimit'} || "12000000";
my $c = $dnscache{'CacheSize'} || 10000000;
my $forwarder = (defined $dnscache{'Forwarder'} && $dnscache{'Forwarder'}) ? "FORWARDONLY=1" : "";
$OUT = "LimitDATA=$datalimit\n";
$OUT .= 'Environment=\n";
$OUT .= 'Environment="DATALIMIT='.$datalimit.'" "IP=127.0.0.2" IPSEND=0.0.0.0 '.$forwarder.' CACHESIZE='.$c.' GID=410 UID=410 "ROOT=/var/service/dnscache.forwarder/root"';
}

View File

@ -0,0 +1,9 @@
i[Service]
{
my $datalimit = $dnscache{'DataLimit'} || "3000000";
my $localip = $config->get('LocalIP');
my $ListenIP= $dnscache->prop('ListenIP') || $localip->value || "127.0.0.3";
$OUT = "LimitDATA=$datalimit\n";
$OUT .= 'Environment="DATALIMIT='.$datalimit.'" "IP='.$ListenIP.'" IPSEND=0.0.0.0 GID=410 UID=410 "ROOT=/var/service/dnscache/root"';
}

View File

@ -1,4 +0,0 @@
{
my $c = $dnscache{'CacheSize'} || 10000000;
"export CACHESIZE=$c"
}

View File

@ -1,4 +0,0 @@
{
my $datalimit = $dnscache{'DataLimit'} || 12000000;
"DATALIMIT=$datalimit";
}

View File

@ -1,4 +0,0 @@
{
(defined $dnscache{'Forwarder'} && $dnscache{'Forwarder'}) ?
"export FORWARDONLY=1" : "";
}

View File

@ -1 +0,0 @@
export IP=127.0.0.2

View File

@ -1 +0,0 @@
export IPSEND=0.0.0.0

View File

@ -1 +0,0 @@
export ROOT=/var/service/dnscache.forwarder/root

View File

@ -0,0 +1,16 @@
/var/log/dnscache.forwarder/dnscache.forwarder.log
/var/log/dnscache/dnscache.log{
weekly
rotate 4
missingok
notifempty
compress
delaycompress
sharedscripts
su root root
create 600 root root
postrotate
/usr/bin/systemctl try-restart dnscache.service dnscache.forwarder.service >/dev/null 2>&1 || true
endscript
}

View File

@ -38,7 +38,7 @@ unless (-f "/var/service/dnscache/seed")
or warn("Could not create seed file");
}
open(STDIN, "<./seed") or warn "Failed to redirect input from seed file: $!";
open(STDIN, "</var/service/dnscache/seed") or warn "Failed to redirect input from seed file: $!";
open(STDERR, ">&STDOUT") or warn "Failed to redirect stderr to stdout: $!";;
my $config = esmith::ConfigDB->open or die "Could not open config db.";
@ -71,7 +71,7 @@ $ENV{FORWARDONLY} = '1';
$ENV{IP} = $dnscache->prop('ListenIP') || $localip->value;
$ENV{IPSEND} = $dnscache->prop('SendIP') || '0.0.0.0';
$ENV{CACHESIZE} = 200000;
$ENV{ROOT} = '/service/dnscache/root';
$ENV{ROOT} = '/var/service/dnscache/root';
my $domains = esmith::DomainsDB->open or die "Could not open Domains db.";
my $nets = esmith::NetworksDB->open or die "Could not open Networks db.";
@ -119,18 +119,18 @@ delegate_domains_2DNS(
$domains->get_all_by_prop('type', 'domain-remote')
));
my $datalimit = $dnscache->prop('DataLimit') || 3000000;
# Ensure that forwarder instance is started
system("sv", "u", "/service/dnscache.forwarder");
# http://marc.theaimsgroup.com/?l=djbdns&m=104812086607532&w=2
$SIG{'PIPE'} = 'IGNORE';
exec("envuidgid", "dnscache", "softlimit", "-o250", "-d", "$datalimit",
"/usr/local/bin/dnscache")
or die "failed to execute envuidgid/softlimit/dnscache: $!";
# NOTREACHED
exit (1);
#my $datalimit = $dnscache->prop('DataLimit') || 3000000;
#
## Ensure that forwarder instance is started
#system("sv", "u", "/service/dnscache.forwarder");
/usr/bin/systemctl restart dnscache.forwarder
#
## http://marc.theaimsgroup.com/?l=djbdns&m=104812086607532&w=2
#$SIG{'PIPE'} = 'IGNORE';
#exec("envuidgid", "dnscache", "softlimit", "-o250", "-d", "$datalimit",
# "/usr/local/bin/dnscache")
# or die "failed to execute envuidgid/softlimit/dnscache: $!";
exit (0);
sub allow_networks_2access_cache
{

View File

@ -1,12 +1,9 @@
#! /bin/sh
exec 2>&1
. ./config
cd /var/service/dnscache.forwarder/
# Ensure that dnscache has source of randomness to initialise its source
# port RNG
test -f ./seed || /bin/dd if=/dev/urandom bs=128 count=1 of=seed
exec<./seed
exit 0
# http://marc.theaimsgroup.com/?l=djbdns&m=104812086607532&w=2
trap "" SIGPIPE
exec envuidgid dnscache softlimit -o250 -d "$DATALIMIT" /usr/local/bin/dnscache

View File

@ -1 +0,0 @@
/var/service/dnscache

View File

@ -1 +0,0 @@
/var/service/dnscache.forwarder

View File

@ -1,15 +1,24 @@
[Unit]
Description=dnscache.forwarder,
Description=dnscache.forwarder, An iterative DNS forwarder resolver daemon
Documentation=man:dnscache(8)
After=network.target
Requires=runit.service
After=networking.service
Requires=network.target
[Service]
Type=oneshot
Type=simple
PermissionsStartOnly=true
LimitDATA=12000000
LimitNOFILE=250
WorkingDirectory=/var/service/dnscache.forwarder/root
Environment="DATALIMIT=12000000" "IP=127.0.0.2" FORWARDONLY=1 IPSEND=0.0.0.0 CACHESIZE=10000000 GID=410 UID=410 "ROOT=/var/service/dnscache.forwarder/root"
ExecStartPre=/sbin/e-smith/service-status dnscache.forwarder
ExecStart=/usr/bin/sv u /service/dnscache.forwarder
ExecStop=/usr/bin/sv stop /service/dnscache.forwarder
ExecReload=/usr/bin/sv t /service/dnscache.forwarder
RemainAfterExit=yes
ExecStartPre=/sbin/e-smith/systemd/dnscache.forwarder-pre
ExecStart=/usr/local/bin/dnscache
Restart=always
RestartSec=20s
SyslogIdentifier=dnscache.forwarder
[Install]
WantedBy=sme-server.target

View File

@ -1,15 +1,26 @@
[Unit]
Description=dnscache,
Description=dnscache, An iterative DNS resolver daemon
Documentation=man:dnscache(8)
After=network.target
Requires=runit.service
After=networking.service
Requires=network.target
Wants=dnscache.forwarder.service
#BindsTo= > Requires= > Wants= > Requisite=
[Service]
Type=oneshot
Type=simple
PermissionsStartOnly=true
LimitDATA=3000000
LimitNOFILE=250
WorkingDirectory=/var/service/dnscache/root
Environment="DATALIMIT=3000000" "IP=192.168.233.1" FORWARDONLY=1 IPSEND=0.0.0.0 CACHESIZE=200000 GID=410 UID=410 "ROOT=/var/service/dnscache/root"
ExecStartPre=/sbin/e-smith/service-status dnscache
ExecStart=/usr/bin/sv u /service/dnscache
ExecStop=/usr/bin/sv stop /service/dnscache
ExecReload=/usr/bin/sv t /service/dnscache
RemainAfterExit=yes
ExecStartPre=/sbin/e-smith/systemd/dnscache-pre
ExecStart=/usr/local/bin/dnscache
Restart=always
RestartSec=20s
SyslogIdentifier=dnscache
[Install]
WantedBy=sme-server.target

View File

@ -1 +0,0 @@
/var/service/dnscache/root

View File

@ -1,28 +0,0 @@
#!/bin/sh
#----------------------------------------------------------------------
# copyright (C) 2005 Mitel Networks Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Technical support for this program is available from Mitel Networks
# Please visit our web site www.mitel.com/sme/ for details.
#----------------------------------------------------------------------
exec \
/usr/bin/setuidgid dnslog \
/usr/bin/multilog t s5000000 \
/var/log/dnscache.forwarder

View File

@ -1 +0,0 @@
/var/service/dnscache/root

View File

@ -1,28 +0,0 @@
#!/bin/sh
#----------------------------------------------------------------------
# copyright (C) 1999-2003 Mitel Networks Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Technical support for this program is available from Mitel Networks
# Please visit our web site www.mitel.com/sme/ for details.
#----------------------------------------------------------------------
exec \
/usr/bin/setuidgid dnslog \
/usr/bin/multilog t s5000000 \
/var/log/dnscache

View File

@ -4,7 +4,7 @@ Summary: smeserver module to configure dnscache
%define name smeserver-dnscache
Name: %{name}
%define version 11.0.0
%define release 5
%define release 6
Version: %{version}
Release: %{release}%{?dist}
License: GPL
@ -24,6 +24,9 @@ smeserver server enhancement to configure and run dnscache as a
caching nameserver
%changelog
* Sat Mar 01 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-6.sme
- move to full systemd units [SME: 12878]
* Thu Apr 04 2024 Brian Read <brianr@koozali.org> 11.0.0-5.sme
- Update createlinks to create smeserver-package-update event[SME: 12579]
@ -506,6 +509,19 @@ perl createlinks
/sbin/e-smith/create-system-user dnslog 411 \
"DNS log user" /var/log /bin/false
if [ $1 -gt 1 ] ; then
if [ -e /var/service/dnscache/run ] ; then
/usr/bin/sv d dnscache
/usr/bin/sv d dnscache/log
fi
if [ -e /var/service/dnscache.forwarder/run ] ; then
/usr/bin/sv d dnscache.forwarder
/usr/bin/sv d dnscache.forwarder/log
fi
fi
exit 0
%post
# Remove any left over env/FORWARDONLY file
rm -f /var/service/dnscache/env/FORWARDONLY
@ -515,14 +531,11 @@ rm -rf $RPM_BUILD_ROOT
(cd root ; find . -depth -print | cpio -dump $RPM_BUILD_ROOT)
/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \
--dir /var/service/dnscache 'attr(0755,root,root)' \
--dir /var/service/dnscache/log 'attr(0755,root,root)' \
--file /var/service/dnscache/run 'attr(0750,root,root)' \
--file /var/service/dnscache/dnscache-log.pl 'attr(0750,root,root)' \
--file /var/service/dnscache/log/run 'attr(0750,root,root)' \
--dir /var/log/dnscache 'attr(02755,dnslog,dnslog)' \
--dir /var/log/dnscache.forwarder 'attr(02755,dnslog,dnslog)' \
--file /var/service/dnscache.forwarder/run 'attr(0750,root,root)' \
--file /var/service/dnscache.forwarder/log/run 'attr(0750,root,root)' \
--file /sbin/e-smith/systemd/dnscache-pre 'attr(0750,root,root)' \
--file /sbin/e-smith/systemd/dnscache.forwarder-pre 'attr(0750,root,root)' \
> %{name}-%{version}-%{release}-filelist
echo "%doc COPYING" >> %{name}-%{version}-%{release}-filelist