[certmaster/f16] systemd support for f16+

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


commit 24d1c155d5674c56c8f0346335f1d9715c491d22
Author: Tom "spot" Callaway <tcallawa at redhat.com>
Date:   Fri Sep 9 15:40:18 2011 -0400

    systemd support for f16+

 certmaster.service |   12 ++++++++++
 certmaster.spec    |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 70 insertions(+), 1 deletions(-)
---
diff --git a/certmaster.service b/certmaster.service
new file mode 100644
index 0000000..b5200fa
--- /dev/null
+++ b/certmaster.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Certificate Master For Fedora Unified Network Control
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/certmaster --daemon
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
+
diff --git a/certmaster.spec b/certmaster.spec
index 0281f20..63135a8 100644
--- a/certmaster.spec
+++ b/certmaster.spec
@@ -17,8 +17,9 @@
 Summary: Remote certificate distribution framework
 Name: certmaster
 Version: 0.28
-Release: 1%{?dist}
+Release: 2%{?dist}
 Source0: %{name}-%{version}.tar.gz
+Source1: %{name}.service
 License: GPLv2+
 Group: Applications/System
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
@@ -46,6 +47,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
 
 
 
@@ -67,6 +75,12 @@ ln -s %{_bindir}/certmaster-sync $RPM_BUILD_ROOT/var/lib/certmaster/triggers/rem
 touch $RPM_BUILD_ROOT/var/log/certmaster/certmaster.log
 touch $RPM_BUILD_ROOT/var/log/certmaster/audit.log
 
+# systemd
+%if 0%{?fedora} >= 16
+rm -rf $RPM_BUILD_ROOT/etc/init.d/
+mkdir -p $RPM_BUILD_ROOT%{_unitdir}
+install -m0644 %{SOURCE1} $RPM_BUILD_ROOT%{_unitdir}/
+%endif
 
 %clean
 rm -fr $RPM_BUILD_ROOT
@@ -80,7 +94,11 @@ rm -fr $RPM_BUILD_ROOT
 %{_bindir}/certmaster-request
 %{_bindir}/certmaster-ca
 %{_bindir}/certmaster-sync
+%if 0%{?fedora} >= 16
+%{_unitdir}/certmaster.service
+%else
 /etc/init.d/certmaster
+%endif
 %dir %{_sysconfdir}/%{name}
 %dir %{_sysconfdir}/%{name}/minion-acl.d/
 %dir %{_sysconfdir}/pki/%{name}
@@ -114,6 +132,41 @@ rm -fr $RPM_BUILD_ROOT
 %doc AUTHORS README LICENSE
 %{_mandir}/man1/*.1.gz
 
+%if 0%{?fedora} >= 16
+%post
+if [ $1 -eq 1 ] ; then 
+    # Initial installation 
+    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
+# fix perms on log files
+chmod 600 /var/log/certmaster/certmaster.log
+chmod 600 /var/log/certmaster/audit.log
+
+%preun
+if [ $1 -eq 0 ] ; then
+    # Package removal, not upgrade
+    /bin/systemctl --no-reload disable certmaster.service > /dev/null 2>&1 || :
+    /bin/systemctl stop certmaster.service > /dev/null 2>&1 || :
+fi
+
+%postun
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+    # Package upgrade, not uninstall
+    /bin/systemctl try-restart certmaster.service >/dev/null 2>&1 || :
+fi
+
+%triggerun -- certmaster < 0.28-2
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply certmaster
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save certmaster >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del certmaster >/dev/null 2>&1 || :
+/bin/systemctl try-restart certmaster.service >/dev/null 2>&1 || :
+
+%else
 
 %post
 # for suse 
@@ -147,9 +200,13 @@ if [ "$1" = 0 ] ; then
     rm -f /etc/rc.d/rc?.d/???certmaster
   fi
 fi
+%endif
 
 
 %changelog
+* Fri Sep  9 2011 Tom Callaway <spot at fedoraproject.org> - 0.28-2
+- systemd support for f16+
+
 * Thu Apr  7 2011 Seth Vidal <skvidal at fedoraproject.org> - 0.28-1
 - 0.28
 


More information about the scm-commits mailing list