[inn] Migrating from cron to systemd timer

Jochen Schmitt s4504kr at fedoraproject.org
Thu Jan 17 07:51:41 UTC 2013


commit 4e80434b2c5560fb0a261f6e1c12adde539007cc
Author: Jochen Schmitt <Jochen at herr-schmitt.de>
Date:   Wed Jan 16 22:29:38 2013 +0100

    Migrating from cron to systemd timer

 inn-cron-expire       |    3 ---
 inn-cron-nntpsend     |    3 ---
 inn-cron-rnews        |    3 ---
 inn.spec              |   47 ++++++++++++++++++++++++++++++++++-------------
 innd-expire.service   |   13 +++++++++++++
 innd-expire.timer     |   11 +++++++++++
 innd-hourly.timer     |   16 ++++++++++++++++
 innd-nntpsend.service |   13 +++++++++++++
 innd-nntpsend.timer   |   11 +++++++++++
 innd-rnews.service    |   13 +++++++++++++
 innd-rnews.timer      |   11 +++++++++++
 11 files changed, 122 insertions(+), 22 deletions(-)
---
diff --git a/inn.spec b/inn.spec
index 13f138f..76f38f1 100644
--- a/inn.spec
+++ b/inn.spec
@@ -1,18 +1,21 @@
 Summary: The InterNetNews system, an Usenet news server
 Name: inn
 Version: 2.5.3
-Release: 4%{?dist}
+Release: 5%{?dist}
 #see LICENSE file for details
 License: GPLv2+ and BSD and MIT and Public Domain
 Group: System Environment/Daemons
 URL: https://www.isc.org/software/INN/
 Source0: ftp://ftp.isc.org/isc/inn/inn-%{version}.tar.gz
 Source2: inn-default-distributions
-Source4: inn-cron-expire
-Source5: inn-cron-rnews
-Source7: inn-cron-nntpsend
 Source10: inn-faq.tar.gz
 Source20: innd.service
+Source21: innd-expire.service
+Source22: innd-expire.timer
+Source23: innd-nntpsend.service
+Source24: innd-nntpsend.timer
+Source25: innd-rnews.service
+Source26: innd-rnews.timer
 Patch1:  inn-2.4.3.rh.patch
 Patch4: inn-2.5.1.pie.patch
 Patch6: inn-2.5.2.posix.patch
@@ -165,14 +168,17 @@ chmod 644 $RPM_BUILD_ROOT%{_sharedstatedir}/news/subscriptions
 
 install -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_sharedstatedir}/news/distributions
 
-mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/cron.{hourly,daily}
-install %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/cron.daily/inn-cron-expire
-install %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}/cron.hourly/inn-cron-rnews
-install %{SOURCE7} $RPM_BUILD_ROOT%{_sysconfdir}/cron.hourly/inn-cron-nntpsend
-
 mkdir -p $RPM_BUILD_ROOT%{_unitdir}
 install -p -m 0644 %{SOURCE20} $RPM_BUILD_ROOT%{_unitdir}
 
+install -p -m 0644 %{SOURCE21} $RPM_BUILD_ROOT%{_unitdir}
+install -p -m 0644 %{SOURCE22} $RPM_BUILD_ROOT%{_unitdir}
+
+install -p -m 0644 %{SOURCE23} $RPM_BUILD_ROOT%{_unitdir}
+install -p -m 0644 %{SOURCE24} $RPM_BUILD_ROOT%{_unitdir}
+
+install -p -m 0644 %{SOURCE25} $RPM_BUILD_ROOT%{_unitdir}
+install -p -m 0644 %{SOURCE26} $RPM_BUILD_ROOT%{_unitdir}
 
 tar xf %{SOURCE10}
 mv inn.html FAQ.html
@@ -221,6 +227,9 @@ touch /var/log/news/news.err
 chown -R news:news /var/log/news*
 
 %systemd_post innd.service
+%systemd_post innd-expire.service
+%systemd_post innd-nntpsend.service
+%systemd_post innd-rnews.service
 
 %post libs -p /sbin/ldconfig
 
@@ -274,6 +283,9 @@ fi
 
 %preun
 %systemd_preun innd.service
+%systemd_preun innd-expire.service
+%systemd_preun innd-nntpsend.service
+%systemd_preun innd-rnews.service
 if [ $1 = 0 ]; then
     if [ -f /var/lib/news/history.dir ]; then
        rm -f /var/lib/news/history.*
@@ -282,6 +294,9 @@ fi
 
 %postun
 %systemd_postun_with_restart innd.service
+%systemd_postun_with_restart innd-expire.service
+%systemd_postun_with_restart innd-nntpsend.serivce
+%systemd_postun_with_restart innd-rnews.service
 
 %postun libs -p /sbin/ldconfig
 
@@ -289,11 +304,14 @@ fi
 %defattr(0755,news,news,-)
 %{_bindir}/rnews
 %defattr(0755,root,root,-)
-# /etc config files plus cron config
-%{_sysconfdir}/cron.hourly/inn-cron-rnews
-%{_sysconfdir}/cron.hourly/inn-cron-nntpsend
-%{_sysconfdir}/cron.daily/inn-cron-expire
+# /etc config files plus config
 %{_unitdir}/innd.service
+%{_unitdir}/innd-expire.service
+%{_unitdir}/innd-expire.timer
+%{_unitdir}/innd-nntpsend.service
+%{_unitdir}/innd-nntpsend.timer
+%{_unitdir}/innd-rnews.service
+%{_unitdir}/innd-rnews.timer
 %defattr(-,news,news,-)
 # tmpfile.d files
 %config(noreplace) %attr(-,root,root) %{_sysconfdir}/tmpfiles.d/inn.conf
@@ -524,6 +542,9 @@ fi
 %{_mandir}/man1/inews*
 
 %changelog
+* Wed Jan 16 2013 Jochen Schmitt <Jochen herr-schmitt de> - 2.5.3-5
+- Migrating from cron to systemd timer
+
 * Fri Oct  5 2012 Jochen Schmitt <Jochen herr-schmitt de> - 2.5.3-4
 - Introduction of systemd rpm macros
 
diff --git a/innd-expire.service b/innd-expire.service
new file mode 100644
index 0000000..8aa9cbd
--- /dev/null
+++ b/innd-expire.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Inetnet News Daemon Expiring
+After=syslog.target network.target innd.service
+ConditionPathExists=/etc/news/inn.conf
+
+[Service]
+User=news
+PermissionsStartOnly=true
+Type=oneshot
+ExecStart=/usr/libexec/news/news.daily delayrm
+
+[Install]
+WantedBy=multi-user.target
\ No newline at end of file
diff --git a/innd-expire.timer b/innd-expire.timer
new file mode 100644
index 0000000..f04aabb
--- /dev/null
+++ b/innd-expire.timer
@@ -0,0 +1,11 @@
+[Unit]
+Description=Inetnet News Daemon Exp
+After=syslog.target network.target innd.service
+ConditionPathExists=/etc/news/inn.conf
+
+[Timer]
+OnUnitActSec=1d
+Unit=innd-expire.service
+
+[Install]
+WantedBy=multi-user.target
\ No newline at end of file
diff --git a/innd-hourly.timer b/innd-hourly.timer
new file mode 100644
index 0000000..59183f3
--- /dev/null
+++ b/innd-hourly.timer
@@ -0,0 +1,16 @@
+[Unit]
+Description=Inetnet News Daemon
+After=syslog.target network.target
+ConditionPathExists=/etc/news/inn.conf
+
+[Service]
+User=news
+PermissionsStartOnly=true
+PIDFile=/run/news/innd.pid
+Type=forking
+ExecStart=/usr/libexec/news/rc.news
+ExecStop=/bin/su -m  news -c '/usr/libexec/news/rc.news stop'
+KillMode=control-group
+
+[Install]
+WantedBy=multi-user.target
\ No newline at end of file
diff --git a/innd-nntpsend.service b/innd-nntpsend.service
new file mode 100644
index 0000000..0b8973f
--- /dev/null
+++ b/innd-nntpsend.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Inetnet News Daemon Sending News
+After=syslog.target network.target innd.service
+ConditionPathExists=/etc/news/inn.conf
+
+[Service]
+User=news
+PermissionsStartOnly=true
+Type=oneshot
+ExecStart=/usr/libexec/news/nntpsend
+
+[Install]
+WantedBy=multi-user.target
\ No newline at end of file
diff --git a/innd-nntpsend.timer b/innd-nntpsend.timer
new file mode 100644
index 0000000..ba6f686
--- /dev/null
+++ b/innd-nntpsend.timer
@@ -0,0 +1,11 @@
+[Unit]
+Description=Inetnet News Daemon NNTP Send
+After=syslog.target network.target innd.service
+ConditionPathExists=/etc/news/inn.conf
+
+[Timer]
+OnUnitActSec=1h
+Unit=innd-nntp.service
+
+[Install]
+WantedBy=multi-user.target
\ No newline at end of file
diff --git a/innd-rnews.service b/innd-rnews.service
new file mode 100644
index 0000000..4889337
--- /dev/null
+++ b/innd-rnews.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Inetnet News Daemon Receiving News
+After=syslog.target network.target innd.service
+ConditionPathExists=/etc/news/inn.conf
+
+[Service]
+User=news
+PermissionsStartOnly=true
+Type=oneshot
+ExecStart=/usr/libexec/news/rnews -U
+
+[Install]
+WantedBy=multi-user.target
\ No newline at end of file
diff --git a/innd-rnews.timer b/innd-rnews.timer
new file mode 100644
index 0000000..7aff983
--- /dev/null
+++ b/innd-rnews.timer
@@ -0,0 +1,11 @@
+[Unit]
+Description=Inetnet News Daemon Receiving News
+After=syslog.target network.target innd.service
+ConditionPathExists=/etc/news/inn.conf
+
+[Timer]
+OnUnitActSec=1h
+Unit=innd-rnews.service
+
+[Install]
+WantedBy=multi-user.target
\ No newline at end of file


More information about the scm-commits mailing list