[spacenavd/f15] Use systemd unit file isntead of sysv.

Richard Shaw hobbes1069 at fedoraproject.org
Thu Aug 25 16:33:35 UTC 2011


commit 45f9785ea33ccd6614173b1b054648ea057cc426
Author: Richard M. Shaw <hobbes1069 at gmail.com>
Date:   Thu Aug 25 11:32:43 2011 -0500

    Use systemd unit file isntead of sysv.

 spacenavd.service |   12 ++++++++++++
 spacenavd.spec    |   35 ++++++++++++++++++++---------------
 2 files changed, 32 insertions(+), 15 deletions(-)
---
diff --git a/spacenavd.service b/spacenavd.service
new file mode 100644
index 0000000..4ba1d4f
--- /dev/null
+++ b/spacenavd.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=3Dconnexion Input Devices Userspace Driver
+After=syslog.target
+
+[Service]
+Type=forking
+PIDFile=/var/run/spnavd.pid
+ExecStart=/usr/bin/spacenavd
+StandardError=syslog
+
+[Install]
+WantedBy=graphical.target
diff --git a/spacenavd.spec b/spacenavd.spec
index fc32924..39226fb 100644
--- a/spacenavd.spec
+++ b/spacenavd.spec
@@ -7,14 +7,14 @@ Group:          User Interface/X Hardware Support
 License:        GPLv3+
 URL:            http://spacenav.sourceforge.net/
 Source0:        http://downloads.sourceforge.net/spacenav/%{name}-%{version}.tar.gz
-Source1:        spacenavd
+Source1:        spacenavd.service
 
 BuildRequires:  libX11-devel
+BuildRequires:  systemd-units
 
-Requires(post): chkconfig
-Requires(preun): chkconfig
-Requires(preun): initscripts
-Requires(postun): initscripts
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
 
 
 %description
@@ -38,9 +38,9 @@ make %{?_smp_mflags}
 %install
 make install
 
-# Install SysV init spacenavd
-mkdir -p %{buildroot}%{_initddir}
-install -p -m 0755 %{SOURCE1} %{buildroot}%{_initddir}
+# Install systemd unit file
+mkdir -p %{buildroot}%{_unitdir}
+install -p -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}
 
 
 %clean
@@ -48,25 +48,30 @@ rm -rf %{buildroot}
 
 
 %post
-# This adds the proper /etc/rc*.d links for the spacenavd
-/sbin/chkconfig --add spacenavd
+if [ $1 -eq 1 ] ; then 
+    # Initial installation
+    /bin/systemctl enable spacenavd.service >/dev/null 2>&1 || :
+fi
 
 %preun
 if [ $1 -eq 0 ] ; then
-    /sbin/service spacenavd stop >/dev/null 2>&1
-    /sbin/chkconfig --del spacenavd
+    # Package removal, not upgrade
+    /bin/systemctl --no-reload disable spacenavd.service > /dev/null 2>&1 || :
+    /bin/systemctl stop spacenavd.service > /dev/null 2>&1 || :
 fi
 
 %postun
-if [ "$1" -ge "1" ] ; then
-    /sbin/service spacenavd 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 spacenavd.service >/dev/null 2>&1 || :
 fi
 
 
 %files
 %doc AUTHORS Changelog doc/* README
 %{_bindir}/*
-%{_initddir}/%{name}
+%{_unitdir}/%{name}.service
 
 
 %changelog


More information about the scm-commits mailing list