[func/f16] use systemd in f16+

Tom Callaway spot at fedoraproject.org
Fri Sep 9 19:30:40 UTC 2011


commit 04609ae4171981d09c5c68aaa27e9f04ac701e37
Author: Tom "spot" Callaway <tcallawa at redhat.com>
Date:   Fri Sep 9 15:30:28 2011 -0400

    use systemd in f16+

 func.service |   11 +++++++++++
 func.spec    |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 65 insertions(+), 3 deletions(-)
---
diff --git a/func.service b/func.service
new file mode 100644
index 0000000..1fd5d88
--- /dev/null
+++ b/func.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Fedora Unified Network Control
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/funcd --daemon
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
diff --git a/func.spec b/func.spec
index 2c1c8ef..8bc48d8 100644
--- a/func.spec
+++ b/func.spec
@@ -12,8 +12,9 @@
 Summary: Remote management framework
 Name: func
 Version: 0.28
-Release: 1%{?dist}
+Release: 2%{?dist}
 Source0: %{name}-%{version}.tar.gz
+Source1: func.service
 License: GPLv2+
 Group: Applications/System
 %if 0%{?rhel} == 3
@@ -39,6 +40,13 @@ BuildRequires: python-setuptools
 %endif
 %endif
 %endif
+%if 0%{?fedora} >= 16
+BuildRequires: systemd-units
+Requires(post): systemd-sysv
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+%endif
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
 BuildArch: noarch
 Url: https://fedorahosted.org/func/
@@ -61,6 +69,12 @@ test "x$RPM_BUILD_ROOT" != "x" && rm -rf $RPM_BUILD_ROOT
 touch $RPM_BUILD_ROOT/var/log/func/func.log
 touch $RPM_BUILD_ROOT/var/log/func/audit.log
 
+%if 0%{?fedora} >= 16
+mkdir -p $RPM_BUILD_ROOT%{_unitdir}
+install -m0644 %{SOURCE1} $RPM_BUILD_ROOT%{_unitdir}/funcd.service
+rm -rf $RPM_BUILD_ROOT/etc/init.d
+%endif
+
 %clean
 rm -fr $RPM_BUILD_ROOT
 
@@ -87,7 +101,11 @@ rm -fr $RPM_BUILD_ROOT
 
 #%{_bindir}/update-func
 
+%if 0%{?fedora} >= 16
+%{_unitdir}/funcd.service
+%else
 /etc/init.d/funcd
+%endif
 %dir %{_sysconfdir}/%{name}
 %dir %{_sysconfdir}/%{name}/minion-acl.d/
 %dir /etc/func/modules/
@@ -145,8 +163,14 @@ rm -fr $RPM_BUILD_ROOT
 %{_mandir}/man1/func-create-module.1.gz
 
 %post
+# systemd
+if [ -x /bin/systemctl ]; then
+  if [ $1 -eq 1 ] ; then 
+    # Initial installation 
+    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+  fi
 # for suse 
-if [ -x /usr/lib/lsb/install_initd ]; then
+elif [ -x /usr/lib/lsb/install_initd ]; then
   /usr/lib/lsb/install_initd /etc/init.d/funcd
 # for red hat distros
 elif [ -x /sbin/chkconfig ]; then
@@ -171,7 +195,11 @@ exit 0
 %preun
 if [ "$1" = 0 ] ; then
   /etc/init.d/funcd stop  > /dev/null 2>&1
-  if [ -x /usr/lib/lsb/remove_initd ]; then
+  if [ -x /bin/systemctl ]; then
+    # Package removal, not upgrade
+    /bin/systemctl --no-reload disable funcd.service > /dev/null 2>&1 || :
+    /bin/systemctl stop funcd.service > /dev/null 2>&1 || :
+  elif [ -x /usr/lib/lsb/remove_initd ]; then
     /usr/lib/lsb/remove_initd /etc/init.d/funcd
   elif [ -x /sbin/chkconfig ]; then
     /sbin/chkconfig --del funcd
@@ -180,9 +208,32 @@ if [ "$1" = 0 ] ; then
   fi
 fi
 
+%postun
+if [ -x /bin/systemctl ]; then
+  /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+  if [ $1 -ge 1 ] ; then
+      # Package upgrade, not uninstall
+      /bin/systemctl try-restart funcd.service >/dev/null 2>&1 || :
+  fi
+fi
+
+%if 0%{?fedora} >= 16
+%triggerun -- func < 0.28-2
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply funcd
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save funcd >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del funcd >/dev/null 2>&1 || :
+/bin/systemctl try-restart funcd.service >/dev/null 2>&1 || :
+%endif
 
 
 %changelog
+* Fri Sep  9 2011 Tom Callaway <spot at fedoraproject.org> - 0.28-2
+- convert to systemd
+
 * Thu Apr  7 2011 Seth Vidal <skvidal at fedoraproject.org> - 0.28-1
 - 0.28  - require newer certmaster
 


More information about the scm-commits mailing list