[fcron] Migrate to systemd.

Jon Ciesla limb at fedoraproject.org
Thu May 10 16:49:03 UTC 2012


commit 1161575bb97db0aba3a933ad5af9833c61ce018e
Author: Jon Ciesla <limburgher at gmail.com>
Date:   Thu May 10 11:48:41 2012 -0500

    Migrate to systemd.

 fcron.service              |   10 +++++
 fcron.spec                 |   81 ++++++++++++++++++++++++-------------------
 fcron_watch_config.service |   10 +++++
 3 files changed, 65 insertions(+), 36 deletions(-)
---
diff --git a/fcron.service b/fcron.service
new file mode 100644
index 0000000..9cf9482
--- /dev/null
+++ b/fcron.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Fcron System Scheduler
+
+[Service]
+Type=forking
+PIDFile=/run/fcron.pid
+ExecStart=/usr/sbin/fcron -b
+
+[Install]
+WantedBy=multi-user.target
diff --git a/fcron.spec b/fcron.spec
index 143e496..e059623 100644
--- a/fcron.spec
+++ b/fcron.spec
@@ -1,6 +1,6 @@
 Name:		fcron
 Version:	3.0.6
-Release:	3%{?dist}
+Release:	4%{?dist}
 Summary:	A task scheduler
 Summary(fr):	Un ordonnanceur de tâches
 Summary(it):	Uno schedulatore di processi
@@ -12,9 +12,10 @@ Source0:	http://fcron.free.fr/archives/%{name}-%{version}.src.tar.gz
 Source1:	fcron.README
 Source2:	fcron.LISEZMOI
 Source3:	fcron_watch_config
-Source4:	fcron_watch_config.init
+Source4:	fcron_watch_config.service
 Source5:	daemon_fcron_watch_config
 Source6:	fcron_config_modified.c
+Source7:	fcron.service
 Patch0:		fcron-3.0.6-dist_install.patch
 Patch1:		fcron-3.0.2-accept_readable_fcron.conf.patch
 BuildRoot: 	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -29,9 +30,11 @@ BuildRequires:	libselinux-devel
 BuildRequires:	/usr/sbin/sendmail
 BuildRequires:	vim-minimal
 
-Requires(post):		chkconfig
-Requires(preun):	chkconfig, initscripts
-Requires(postun):	initscripts
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+# For triggerun
+Requires(post): systemd-sysv
 
 %description
 Fcron is a scheduler. It aims at replacing Vixie Cron, so it implements most
@@ -107,22 +110,10 @@ cp -a doc/fr/HTML doc/fr/HTML-fr
 
 make install-staged DESTDIR=%{buildroot}
 
-%{__install} -d %{buildroot}%{_initrddir}
-# don't start in the default case, and correct paths
-%{__sed} \
- -e 's|2345|-|' \
- -e 's|2 3 4 5||' \
- -e 's|SBIN=@@DESTSBIN@|SBIN=%{_sbindir}|' \
- -e 's|/var|%{_localstatedir}|' script/sysVinit-launcher > %{buildroot}%{_initrddir}/fcron
+mkdir -p %{buildroot}%{_unitdir}
 
-%{__sed} \
- -e 's|/usr/sbin|%{_sbindir}|' \
- -e 's|/var|%{_localstatedir}|' %{SOURCE4} > %{buildroot}%{_initrddir}/fcron_watch_config
-
-%{__chmod} 0755 %{buildroot}%{_initrddir}/fcron*
-
-touch -c -r %{SOURCE4} %{buildroot}%{_initrddir}/fcron_watch_config
-touch -c -r script/sysVinit-launcher %{buildroot}%{_initrddir}/fcron
+install -m644 %{SOURCE4} %{buildroot}%{_unitdir}/fcron_watch_config.service
+install -m644 %{SOURCE7} %{buildroot}%{_unitdir}/fcron.service
 
 %{__sed} -e 's|/usr/bin|%{_bindir}|' \
  -e 's|/var|%{_localstatedir}|' \
@@ -176,27 +167,42 @@ useradd -r -g fcron -d  %{_localstatedir}/spool/fcron -s /sbin/nologin \
 exit 0
 
 %post
-/sbin/chkconfig --add %{name}
-/sbin/chkconfig --add %{name}_watch_config
+if [ $1 -eq 1 ] ; then 
+    # Initial installation 
+    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
 
 %postun
-if [ "$1" -ge "1" ] ; then
-    /sbin/service %{name} condrestart >/dev/null 2>&1 || :
-fi
-if [ "$1" -ge "1" ] ; then
-    /sbin/service %{name}_watch_config condrestart >/dev/null 2>&1 || :
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+    # Package upgrade, not uninstall
+    /bin/systemctl try-restart fcron.service >/dev/null 2>&1 || :
+    /bin/systemctl try-restart fcron_watch_config.service >/dev/null 2>&1 || :
 fi
 
 %preun
-if [ "$1" = "0" ]
-then
-  /sbin/service %{name} stop >/dev/null 2>&1
-  /sbin/chkconfig --del %{name}
-
-  /sbin/service %{name}_watch_config stop >/dev/null 2>&1
-  /sbin/chkconfig --del %{name}_watch_config
+if [ $1 -eq 0 ] ; then
+    # Package removal, not upgrade
+    /bin/systemctl --no-reload disable fcron.service > /dev/null 2>&1 || :
+    /bin/systemctl stop fcron.service > /dev/null 2>&1 || :
+    /bin/systemctl --no-reload disable fcron_watch_config.service > /dev/null 2>&1 || :
+    /bin/systemctl stop fcron_watch_config.service > /dev/null 2>&1 || :
 fi
 
+%triggerun -- fcron < 3.0.6-4
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply fcron
+# and systemd-sysv-convert --apply fcron_watch_config
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save fcron >/dev/null 2>&1 ||:
+/usr/bin/systemd-sysv-convert --save fcron_watch_config >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del fcron >/dev/null 2>&1 || :
+/bin/systemctl try-restart fcron.service >/dev/null 2>&1 || :
+/sbin/chkconfig --del fcron_watch_config >/dev/null 2>&1 || :
+/bin/systemctl try-restart fcron_watch_config.service >/dev/null 2>&1 || :
+
 %clean
 %{__rm} -rf %{buildroot}
 
@@ -204,8 +210,8 @@ fi
 %defattr(-,root,root,-)
 %doc doc/en/HTML/ doc/fr/HTML-fr/ doc/en/txt/*
 %doc README.Package LISEZMOI.Package
-%{_initrddir}/fcron
-%{_initrddir}/fcron_watch_config
+%{_unitdir}/fcron.service
+%{_unitdir}/fcron_watch_config.service
 %config(noreplace) %{_sysconfdir}/fcron.conf
 %config(noreplace) %{_sysconfdir}/fcron.allow
 %config(noreplace) %{_sysconfdir}/fcron.deny
@@ -231,6 +237,9 @@ fi
 #%dir %{_sysconfdir}/cron.d
 
 %changelog
+* Thu May 10 2012 Jon Ciesla <limburgher at gmail.com> - 3.0.6-4
+- Migrate to systemd, BZ 767343.
+
 * Fri Jan 13 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 3.0.6-3
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
 
diff --git a/fcron_watch_config.service b/fcron_watch_config.service
new file mode 100644
index 0000000..b10d16b
--- /dev/null
+++ b/fcron_watch_config.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Fcron Configuration File Watcher 
+
+[Service]
+Type=forking
+PIDFile=/run/fcron_watch_config.pid
+ExecStart=/usr/sbin/daemon_fcron_watch_config
+
+[Install]
+WantedBy=multi-user.target


More information about the scm-commits mailing list