[flumotion] Migrate to systemd.

Jon Ciesla limb at fedoraproject.org
Thu May 10 17:36:43 UTC 2012


commit ee750a49b3c3ff5bdab260bb35f9367ce4b8b293
Author: Jon Ciesla <limburgher at gmail.com>
Date:   Thu May 10 12:36:32 2012 -0500

    Migrate to systemd.

 flumotion.service |   13 ++++++++++
 flumotion.spec    |   68 +++++++++++++++++++++++++++++++++++------------------
 2 files changed, 58 insertions(+), 23 deletions(-)
---
diff --git a/flumotion.service b/flumotion.service
new file mode 100644
index 0000000..d3261c0
--- /dev/null
+++ b/flumotion.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Flumotion Streaming Server
+After=network.target 
+
+[Service]
+User=flumotion
+Group=flumotion
+Type=oneshot
+ExecStart=/usr/sbin/flumotion -d 3 -l /var/log/flumotion/service.log start 
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
diff --git a/flumotion.spec b/flumotion.spec
index ba50317..8e05172 100644
--- a/flumotion.spec
+++ b/flumotion.spec
@@ -8,13 +8,14 @@
 
 Name:           flumotion
 Version:        0.10.0
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Streaming Server based on GStreamer and Twisted
 
 Group:          Applications/Internet
 License:        LGPLv2
 URL:            http://www.flumotion.net/
-Source:         http://www.flumotion.net/src/flumotion/%{name}-%{version}.tar.bz2
+Source0:         http://www.flumotion.net/src/flumotion/%{name}-%{version}.tar.bz2
+Source1:	flumotion.service
 
 Requires:       python >= 2.4
 Requires:       %{gstreamer} >= %{gst_minver}
@@ -30,6 +31,11 @@ Requires:       pyOpenSSL
 Requires:       pkgconfig
 Requires:       python-crypto
 Requires:       python-kiwi >= %{kiwi_minver}
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+# For triggerun
+Requires(post): systemd-sysv
 
 # for make-dummy-cert to work
 Requires(post): openssl
@@ -105,10 +111,10 @@ desktop-file-install \
 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/flumotion
 
 # install service files
-install -d $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d
-install -m 755 \
-        doc/redhat/flumotion \
-        $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d
+install -d $RPM_BUILD_ROOT%{_unitdir}
+install -m 644 \
+        %{SOURCE1} \
+        $RPM_BUILD_ROOT%{_unitdir}/flumotion.service
 
 # create log and run and cache directory
 install -d $RPM_BUILD_ROOT%{_localstatedir}/log/flumotion
@@ -133,7 +139,10 @@ rm -rf $RPM_BUILD_ROOT
         flumotion > /dev/null 2> /dev/null || :
 
 %post
-/sbin/chkconfig --add flumotion
+if [ $1 -eq 1 ] ; then 
+    # Initial installation 
+    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
 # generate a default .pem certificate ?
 PEM_FILE="%{_sysconfdir}/flumotion/default.pem"
 if ! test -e ${PEM_FILE}
@@ -205,25 +214,35 @@ fi
 
 %preun
 # if removal and not upgrade, stop the processes, clean up locks
-if [ $1 -eq 0 ]
-then
-  /sbin/service flumotion stop > /dev/null
+if [ $1 -eq 0 ] ; then
+    # Package removal, not upgrade
+    /bin/systemctl --no-reload disable flumotion.service > /dev/null 2>&1 || :
+    /bin/systemctl stop flumotion.service > /dev/null 2>&1 || :
+    rm -rf %{_localstatedir}/lock/flumotion*
+    rm -rf %{_localstatedir}/run/flumotion*
+
+    # clean out the cache/home dir too, without deleting it or the user
+    rm -rf %{_localstatedir}/cache/flumotion/*
+    rm -rf %{_localstatedir}/cache/flumotion/.[^.]*
+fi
 
-  rm -rf %{_localstatedir}/lock/flumotion*
-  rm -rf %{_localstatedir}/run/flumotion*
+%postun
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+    # Package upgrade, not uninstall
+    /bin/systemctl try-restart flumotion.service >/dev/null 2>&1 || :
+fi
 
-  # clean out the cache/home dir too, without deleting it or the user
-  rm -rf %{_localstatedir}/cache/flumotion/*
-  rm -rf %{_localstatedir}/cache/flumotion/.[^.]*
+%triggerun -- flumotion < 0.10.0-3
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply flumotion
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save flumotion >/dev/null 2>&1 ||:
 
-  /sbin/chkconfig --del flumotion
-fi
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del flumotion >/dev/null 2>&1 || :
+/bin/systemctl try-restart flumotion.service >/dev/null 2>&1 || :
 
-# Think about this first, we don't really want to stop everything
-#%postun
-# if [ $1 -ge 1 ]; then
-#   /sbin/service flumotion condrestart
-# fi
 
 %files -f flumotion.lang
 %defattr(-,root,root,-)
@@ -263,9 +282,12 @@ fi
 %attr(770,root,flumotion) %{_localstatedir}/run/flumotion
 %attr(770,root,flumotion) %{_localstatedir}/log/flumotion
 %attr(770,root,flumotion) %{_localstatedir}/cache/flumotion
-%{_sysconfdir}/rc.d/init.d/flumotion
+%{_unitdir}/flumotion.service
 
 %changelog
+* Thu May 10 2012 Jon Ciesla <limburgher at gmail.com> - 0.10.0-3
+- Migrate to systemd, BZ 767409.
+
 * Fri Jan 13 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.10.0-2
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
 


More information about the scm-commits mailing list