From 537dbcf29572ce2f66c97c861ac4990fdeb67a31 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Pialasse Date: Tue, 25 Feb 2025 23:08:48 -0500 Subject: [PATCH] * Tue Feb 25 2025 Jean-Philippe Pialasse 11.0.0-7.sme - move to full systemd unit [SME: 12877] --- contriborbase | 1 - createlinks | 19 +++++++------- .../templates/etc/rsyslog.conf/32tinydns | 3 +++ .../50koozali.conf/20service | 7 +++++ .../var/service/tinydns/env/DATALIMIT | 4 --- .../templates/var/service/tinydns/env/IP | 3 --- root/etc/logrotate.d/tinydns | 15 +++++++++++ .../e-smith/systemd/tinydns-control1} | 0 .../e-smith/systemd/tinydns-control2} | 0 root/service/tinydns | 1 - root/usr/lib/systemd/system/tinydns.service | 26 ++++++++++++++----- .../system/tinydns.service.d/.gitignore | 0 smeserver-tinydns.spec | 19 ++++++++------ 13 files changed, 65 insertions(+), 33 deletions(-) delete mode 100644 contriborbase create mode 100644 root/etc/e-smith/templates/etc/rsyslog.conf/32tinydns create mode 100644 root/etc/e-smith/templates/usr/lib/systemd/system/tinydns.service.d/50koozali.conf/20service delete mode 100644 root/etc/e-smith/templates/var/service/tinydns/env/DATALIMIT delete mode 100644 root/etc/e-smith/templates/var/service/tinydns/env/IP create mode 100644 root/etc/logrotate.d/tinydns rename root/{var/service/tinydns/control/1 => sbin/e-smith/systemd/tinydns-control1} (100%) rename root/{var/service/tinydns/control/2 => sbin/e-smith/systemd/tinydns-control2} (100%) delete mode 120000 root/service/tinydns create mode 100644 root/usr/lib/systemd/system/tinydns.service.d/.gitignore diff --git a/contriborbase b/contriborbase deleted file mode 100644 index ef36a67..0000000 --- a/contriborbase +++ /dev/null @@ -1 +0,0 @@ -sme10 diff --git a/createlinks b/createlinks index bbfab15..2107d90 100644 --- a/createlinks +++ b/createlinks @@ -7,23 +7,21 @@ use esmith::Build::CreateLinks qw(:all); #------------------------------------------------------------------- # actions for bootstrap-console-save event, smeserver-tinydns-update : #------------------------------------------------------------------- -foreach (qw( - env/IP - env/DATALIMIT - root/data - )) -{ - templates2events("/var/service/tinydns/$_", qw( +templates2events("/var/service/tinydns/root/data", qw( bootstrap-console-save smeserver-tinydns-update )); -} +templates2events("/usr/lib/systemd/system/tinydns.service.d/50koozali.conf", qw( + bootstrap-console-save + smeserver-tinydns-update + )); + #-------------------------------------------------- # actions for ip-change event #-------------------------------------------------- my $event = "ip-change"; -safe_symlink("sigusr2", "root/etc/e-smith/events/$event/services2adjust/tinydns"); +safe_symlink("reload", "root/etc/e-smith/events/$event/services2adjust/tinydns"); #-------------------------------------------------- # actions for smeserver-tinydns-update event @@ -31,5 +29,8 @@ safe_symlink("sigusr2", "root/etc/e-smith/events/$event/services2adjust/tinydns" $event = "smeserver-tinydns-update"; safe_symlink("try-restart", "root/etc/e-smith/events/$event/services2adjust/tinydns"); templates2events("/etc/systemd/system-preset/49-koozali.preset", $event); +templates2events("/usr/lib/systemd/system/tinydns.service.d/50koozali.conf", $event); +templates2events("/etc/rsyslog.conf", $event); +safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/rsyslog"); event_link("systemd-reload", $event, "89"); diff --git a/root/etc/e-smith/templates/etc/rsyslog.conf/32tinydns b/root/etc/e-smith/templates/etc/rsyslog.conf/32tinydns new file mode 100644 index 0000000..c44bb7c --- /dev/null +++ b/root/etc/e-smith/templates/etc/rsyslog.conf/32tinydns @@ -0,0 +1,3 @@ +#tinydns +:programname, isequal, "tinydns" /var/log/tinydns/tinydns.log +& stop diff --git a/root/etc/e-smith/templates/usr/lib/systemd/system/tinydns.service.d/50koozali.conf/20service b/root/etc/e-smith/templates/usr/lib/systemd/system/tinydns.service.d/50koozali.conf/20service new file mode 100644 index 0000000..0a53ca7 --- /dev/null +++ b/root/etc/e-smith/templates/usr/lib/systemd/system/tinydns.service.d/50koozali.conf/20service @@ -0,0 +1,7 @@ +[Service] +{ + my $datalimit = $tinydns{'DataLimit'} || "3000000"; + my $ListenIP= $tinydns{'ListenIP'} || "127.0.0.1"; + $OUT = "LimitDATA=$datalimit\n"; + $OUT .= 'Environment="DATALIMIT='.$datalimit.'" "IP='.$ListenIP.'" GID=53 UID=53 "ROOT=/var/service/tinydns/root"'; +} diff --git a/root/etc/e-smith/templates/var/service/tinydns/env/DATALIMIT b/root/etc/e-smith/templates/var/service/tinydns/env/DATALIMIT deleted file mode 100644 index 832919b..0000000 --- a/root/etc/e-smith/templates/var/service/tinydns/env/DATALIMIT +++ /dev/null @@ -1,4 +0,0 @@ -{ - my $datalimit = $tinydns{'DataLimit'} || "300000"; - "$datalimit"; -} diff --git a/root/etc/e-smith/templates/var/service/tinydns/env/IP b/root/etc/e-smith/templates/var/service/tinydns/env/IP deleted file mode 100644 index a96eea0..0000000 --- a/root/etc/e-smith/templates/var/service/tinydns/env/IP +++ /dev/null @@ -1,3 +0,0 @@ -{ - $OUT = $tinydns{'ListenIP'} || "127.0.0.1"; -} diff --git a/root/etc/logrotate.d/tinydns b/root/etc/logrotate.d/tinydns new file mode 100644 index 0000000..dab6930 --- /dev/null +++ b/root/etc/logrotate.d/tinydns @@ -0,0 +1,15 @@ +/var/log/tinydns/tinydns.log{ + weekly + rotate 4 + missingok + notifempty + compress + delaycompress + sharedscripts + su root root + create 600 root root + postrotate + /usr/bin/systemctl try-restart tinydns.service >/dev/null 2>&1 || true + endscript +} + diff --git a/root/var/service/tinydns/control/1 b/root/sbin/e-smith/systemd/tinydns-control1 similarity index 100% rename from root/var/service/tinydns/control/1 rename to root/sbin/e-smith/systemd/tinydns-control1 diff --git a/root/var/service/tinydns/control/2 b/root/sbin/e-smith/systemd/tinydns-control2 similarity index 100% rename from root/var/service/tinydns/control/2 rename to root/sbin/e-smith/systemd/tinydns-control2 diff --git a/root/service/tinydns b/root/service/tinydns deleted file mode 120000 index 76d9f31..0000000 --- a/root/service/tinydns +++ /dev/null @@ -1 +0,0 @@ -/var/service/tinydns \ No newline at end of file diff --git a/root/usr/lib/systemd/system/tinydns.service b/root/usr/lib/systemd/system/tinydns.service index c80b486..4530404 100644 --- a/root/usr/lib/systemd/system/tinydns.service +++ b/root/usr/lib/systemd/system/tinydns.service @@ -1,15 +1,27 @@ [Unit] -Description=tinydns, +Description=tinydns, A DNS server daemon +Documentation=man:tinydns(8) After=network.target -Requires=runit.service +After=networking.service +Requires=network.target [Service] -Type=oneshot ExecStartPre=/sbin/e-smith/service-status tinydns -ExecStart=/usr/bin/sv u /service/tinydns -ExecStop=/usr/bin/sv stop /service/tinydns -ExecReload=/usr/bin/sv t /service/tinydns -RemainAfterExit=yes +Type=simple +PermissionsStartOnly=true +LimitDATA=3000000 +WorkingDirectory=/var/service/tinydns/root +Environment="DATALIMIT=3000000" "IP=127.0.0.1" GID=53 UID=53 "ROOT=/var/service/tinydns/root" +ExecStartPre=/sbin/e-smith/systemd/tinydns-control1 +ExecStartPre=/sbin/e-smith/systemd/tinydns-control2 +ExecStart=/usr/local/bin/tinydns +ExecReload=/sbin/e-smith/systemd/tinydns-control1 +ExecReload=/sbin/e-smith/systemd/tinydns-control2 +#ExecReload=/bin/kill -CONT $MAINPID + +Restart=always +RestartSec=20s +SyslogIdentifier=tinydns [Install] WantedBy=sme-server.target diff --git a/root/usr/lib/systemd/system/tinydns.service.d/.gitignore b/root/usr/lib/systemd/system/tinydns.service.d/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/smeserver-tinydns.spec b/smeserver-tinydns.spec index 335c500..890950f 100644 --- a/smeserver-tinydns.spec +++ b/smeserver-tinydns.spec @@ -4,7 +4,7 @@ Summary: smeserver module to configure tinydns %define name smeserver-tinydns Name: %{name} %define version 11.0.0 -%define release 6 +%define release 7 Version: %{version} Release: %{release}%{?dist} License: GPL @@ -28,6 +28,9 @@ Provides: e-smith-tinydns AutoReqProv: no %changelog +* Tue Feb 25 2025 Jean-Philippe Pialasse 11.0.0-7.sme +- move to full systemd unit [SME: 12877] + * Sun Jan 26 2025 Jean-Philippe Pialasse 11.0.0-6.sme - requires daemontools bins [SME: 12566] @@ -428,16 +431,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/tinydns 'attr(0755,root,root)' \ - --dir /var/service/tinydns/log 'attr(0755,root,root)' \ - --file /var/service/tinydns/run 'attr(0750,root,root)' \ --file /var/service/tinydns/tinydns-log.pl 'attr(0750,root,root)' \ --file /var/service/tinydns/tinydns-readstats 'attr(0750,root,root)' \ - --file /var/service/tinydns/control/1 'attr(0750,root,root)' \ - --file /var/service/tinydns/control/2 'attr(0750,root,root)' \ - --file /var/service/tinydns/log/run 'attr(0750,root,root)' \ + --file /sbin/e-smith/systemd/tinydns-control1 'attr(0750,root,root)' \ + --file /sbin/e-smith/systemd/tinydns-control2 'attr(0750,root,root)' \ --dir /var/log/tinydns 'attr(02755,dnslog,dnslog)' \ - --file /var/service/dhcp-dns/dhcp-dns 'attr(0750,root,root)' \ - --file /var/service/dhcp-dns/run 'attr(0750,root,root)' \ > %{name}-%{version}-%{release}-filelist echo "%doc COPYING" >> %{name}-%{version}-%{release}-filelist @@ -445,6 +443,11 @@ echo "%doc COPYING" >> %{name}-%{version}-%{release}-filelist rm -rf $RPM_BUILD_ROOT %pre +if [ $1 -gt 1 ] ; then + if [ -e /var/service/tinydns/run ] ; then + /usr/bin/sv d tinydns + /usr/bin/sv d tinydns/log +fi /sbin/e-smith/create-system-user dns 53 "Name server" /var/service/tinydns /bin/false /sbin/e-smith/create-system-user dnslog 411 "DNS log user" /var/log /bin/false exit 0