[fsniper] * systemd support (#767772) * fix the upstream URL. The source0 URL stays the same until upstream

Jakub Hrozek jhrozek at fedoraproject.org
Mon Jan 2 16:51:51 UTC 2012


commit 50da0ef2fdb11dbe4041aa56802e0d8149b43a63
Author: Jakub Hrozek <jhrozek at redhat.com>
Date:   Mon Jan 2 17:51:24 2012 +0100

    * systemd support (#767772)
    * fix the upstream URL. The source0 URL stays the same until upstream
      releases a new version

 fsniper.initscript |   99 ----------------------------------------------------
 fsniper.service    |   10 +++++
 fsniper.spec       |   57 +++++++++++++++++++++--------
 3 files changed, 51 insertions(+), 115 deletions(-)
---
diff --git a/fsniper.service b/fsniper.service
new file mode 100644
index 0000000..f06aaaa
--- /dev/null
+++ b/fsniper.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Fsniper New Files in Directory Monitor And Script Runner 
+
+[Service]
+User=fsniper
+Type=forking
+ExecStart=/usr/bin/fsniper --daemon /etc/fsniper.conf
+
+[Install]
+WantedBy=multi-user.target
diff --git a/fsniper.spec b/fsniper.spec
index af11d06..365424d 100644
--- a/fsniper.spec
+++ b/fsniper.spec
@@ -1,13 +1,13 @@
 Name:           fsniper
 Version:        1.3.1
-Release:        6%{?dist}
+Release:        7%{?dist}
 Summary:        A tool that monitors directories for new files and invokes scripts on them
 
 Group:          Applications/File
 License:        GPLv3+
-URL:            http://projects.l3ib.org/trac/fsniper
+URL:            https://github.com/l3ib/fsniper
 Source0:        http://projects.l3ib.org/fsniper/files/fsniper-%{version}.tar.gz
-Source1:        fsniper.initscript
+Source1:        fsniper.service
 Source2:        fsniper.conf
 Source3:        fsniper.sysconfig
 
@@ -18,13 +18,14 @@ BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires:  file-devel
 BuildRequires:  pcre-devel
+BuildRequires:  systemd-units
 
-Requires(preun):  initscripts chkconfig
-Requires(post):   chkconfig
-Requires(postun): initscripts
+Requires(post):   systemd-units systemd-sysv
+Requires(preun):  systemd-units
+Requires(postun): systemd-units
 Requires(pre):    /usr/sbin/useradd /usr/sbin/groupadd
 
-%define servicename fsniper
+%define servicename fsniper.service
 %define fsdir       %{_localstatedir}/lib/%{name}
 
 %description
@@ -48,14 +49,14 @@ make %{?_smp_mflags}
 
 %install
 rm -rf $RPM_BUILD_ROOT
-mkdir -p $RPM_BUILD_ROOT%{_initrddir}
+mkdir -p $RPM_BUILD_ROOT%{_unitdir}
 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}
 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
 mkdir -p $RPM_BUILD_ROOT%{fsdir}
 
 make install DESTDIR=$RPM_BUILD_ROOT
 
-install -pm 0755 %{SOURCE1} $RPM_BUILD_ROOT%{_initrddir}/fsniper
+install -pm 0755 %{SOURCE1} $RPM_BUILD_ROOT%{_unitdir}/%{servicename}
 install -pm 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/fsniper.conf
 install -pm 0644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/fsniper
 install -pm 0644 doc/doc.txt $RPM_BUILD_ROOT%{docdir}
@@ -67,7 +68,7 @@ rm -rf $RPM_BUILD_ROOT
 %files
 %defattr(-,root,root,-)
 %{_bindir}/fsniper
-%{_initrddir}/%{name}
+%{_unitdir}/%{servicename}
 %attr(-,%{name},%{name}) %dir %{fsdir}/
 %config(noreplace) %{_sysconfdir}/fsniper.conf
 %config(noreplace) %{_sysconfdir}/sysconfig/fsniper
@@ -84,20 +85,44 @@ if [ $1 = 1 ]; then
 fi
 
 %post
-/sbin/chkconfig --add %{servicename}
+if [ $1 -eq 1 ] ; then 
+    # Initial installation 
+    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
 
 %preun
-if [ $1 = 0 ]; then
-    /sbin/service %{servicename} stop >/dev/null 2>&1
-    /sbin/chkconfig --del %{servicename} 
+if [ $1 -eq 0 ] ; then
+    # Package removal, not upgrade
+    /bin/systemctl --no-reload disable %{servicename} > /dev/null 2>&1 || :
+    /bin/systemctl stop %{servicename} > /dev/null 2>&1 || :
 fi
 
 %postun
-if [ "$1" -ge "1" ] ; then
-        /sbin/service %{servicename} 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 %{servicename} >/dev/null 2>&1 || :
 fi
 
+%triggerun -- fsniper < 1.0-2
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply fsniper
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save fsniper >/dev/null 2>&1 ||:
+
+# If the package is allowed to autostart:
+/bin/systemctl --no-reload enable %{servicename} >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del fsniper >/dev/null 2>&1 || :
+/bin/systemctl try-restart %{servicename} >/dev/null 2>&1 || :
+
 %changelog
+* Mon Jan 02 2012 Jakub Hrozek <jhrozek at redhat.com> 1.3.1-7
+- systemd support
+- fix the upstream URL. The source0 URL stays the same until upstream
+  releases a new version
+
 * Tue Feb 08 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.3.1-6
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
 


More information about the scm-commits mailing list