[sks] Add systemd support
Nick Bebout
nb at fedoraproject.org
Thu Sep 11 21:23:13 UTC 2014
commit dcca52b771dd3f53f2d51f3c345bbcdb1d5cbf31
Author: Nick Bebout <nb at fedoraproject.org>
Date: Thu Sep 11 16:22:57 2014 -0500
Add systemd support
sks-db.service | 10 +++++++
sks-recon.service | 12 ++++++++
sks.spec | 77 ++++++++++++++++++++++++++++++++++++++++++++---------
3 files changed, 86 insertions(+), 13 deletions(-)
---
diff --git a/sks-db.service b/sks-db.service
new file mode 100644
index 0000000..4e4bac0
--- /dev/null
+++ b/sks-db.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=SKS database service
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/sks db
+User=sks
+
+[Install]
+WantedBy=multi-user.target
diff --git a/sks-recon.service b/sks-recon.service
new file mode 100644
index 0000000..9552728
--- /dev/null
+++ b/sks-recon.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=SKS reconciliation service
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/sks recon
+User=sks
+BindTo=sks-db.service
+After=sks-db.service
+
+[Install]
+WantedBy=multi-user.target
diff --git a/sks.spec b/sks.spec
index 57af1a5..5245567 100644
--- a/sks.spec
+++ b/sks.spec
@@ -1,3 +1,11 @@
+# sks is a daemon application and that's why needs hardening
+%global _hardened_build 1
+
+# Define variables to use in conditionals
+%if 0%{?fedora} >= 21 || 0%{?rhel} >= 7
+%global use_systemd 1
+%endif # 0%{?fedora} >= 21 || 0%{?rhel} >= 7
+
Summary: Synchronizing Key Server
Name: sks
Version: 1.1.5
@@ -7,8 +15,11 @@ Group: System Environment/Daemons
URL: http://code.google.com/p/sks-keyserver/
# hg clone https://code.google.com/r/johnclizbe-sks-keyserver/
Source0: https://bitbucket.org/skskeyserver/sks-keyserver/downloads/sks-1.1.5.tgz
+%if 0%{?use_systemd}
Source1: sks-db.init
Source2: sks-recon.init
+%else # 0%{?use_systemd}
+%endif # 0%{?use_systemd}
Patch0: sks-libdb5.3.patch
Patch1: sks-build.patch
#Patch1: sks-1.1.1-bdb.patch
@@ -17,11 +28,24 @@ BuildRequires: ocaml ocaml-camlp4-devel libdb-devel zlib-devel chrpath
%if 0%{?fedora} >= 19
BuildRequires: perl-podlators
%endif
+%if 0%{?use_systemd}
+BuildRequires: systemd-units
+%endif
+
Requires: libdb
Requires(pre): /usr/sbin/groupadd /usr/sbin/useradd
-Requires(post): /sbin/chkconfig
-Requires(preun): /sbin/chkconfig /sbin/service
-Requires(postun): /sbin/service
+%if 0%{?use_systemd}
+Requires(post): systemd-units
+Requires(post): systemd-sysv
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+%else # 0%{?use_systemd}
+Requires(post): chkconfig
+Requires(preun): chkconfig
+# This is for /sbin/service
+Requires(preun): initscripts
+Requires(postun): initscripts
+%endif # 0%{?use_systemd}
%description
SKS is a OpenPGP keyserver whose goal is to provide easy to
@@ -41,13 +65,19 @@ make CFLAGS="$RPM_OPT_FLAGS -I`ocamlc -where` -I ." all
make install PREFIX="%{buildroot}%{_prefix}" MANDIR="%{buildroot}%{_mandir}"
chmod -x %{buildroot}%{_mandir}/man8/sks.8.gz
chrpath --delete %{buildroot}%{_bindir}/sks
-install -Dp -m0755 %{SOURCE1} %{buildroot}%{_initrddir}/sks-db
-install -Dp -m0755 %{SOURCE2} %{buildroot}%{_initrddir}/sks-recon
mkdir -p %{buildroot}%{_sbindir}
for TYPE in db recon; do
ln -s %{_bindir}/%{name} %{buildroot}%{_sbindir}/%{name}-${TYPE}
done
-
+%if 0%{?use_systemd}
+mkdir -p %buildroot%{_unitdir}
+install -m 0644 %{SOURCE3} %buildroot%{_unitdir}/sks-db.service
+install -m 0644 %{SOURCE4} %buildroot%{_unitdir}/sks-recon.service
+%else # 0%{?use_systemd}
+mkdir -p %buildroot%{_initrddir}
+install -Dp -m0755 %{SOURCE1} %{buildroot}%{_initrddir}/sks-db
+install -Dp -m0755 %{SOURCE2} %{buildroot}%{_initrddir}/sks-recon
+%endif # 0%{?use_systemd}
%pre
if ! getent group %{name} >/dev/null 2>&1; then
@@ -61,27 +91,39 @@ if ! getent passwd %{name} >/dev/null 2>&1; then
fi
exit 0 # Always pass
-
%post
+%if 0%{?use_systemd}
+%systemd_post sks-db.service
+%systemd_post sks-recon.service
+%else # 0%{?use_systemd}
+# This adds the proper /etc/rc*.d links for the script
/sbin/chkconfig --add %{name}-db
/sbin/chkconfig --add %{name}-recon
+%endif # 0%{?use_systemd}
%preun
-if [ $1 -eq 0 ]; then # Remove
+%if 0%{?use_systemd}
+%systemd_preun sks-db.service
+%systemd_preun sks-recon.service
+%else # 0%{?use_systemd}
+if [ $1 -eq 0 ] ; then # Remove
/sbin/service %{name}-recon stop >/dev/null 2>&1
/sbin/service %{name}-db stop >/dev/null 2>&1
-
/sbin/chkconfig --del %{name}-recon
/sbin/chkconfig --del %{name}-db
fi
-
+%endif # 0%{?use_systemd}
%postun
-if [ $1 -ge 1 ]; then # Upgrade
+%if 0%{?use_systemd}
+%systemd_postun_with_restart sks-db.service
+%systemd_postun_with_restart sks-recon.service
+%else # 0%{?use_systemd}
+if [ "$1" -ge "1" ] ; then
/sbin/service %{name}-db condrestart >/dev/null 2>&1 || :
/sbin/service %{name}-recon condrestart >/dev/null 2>&1 || :
fi
-
+%endif # 0%{?use_systemd}
%triggerin -- prelink, %{_sysconfdir}/prelink.conf
# Prevent prelink from modifying programs
@@ -100,9 +142,18 @@ fi
%{_sbindir}/%{name}-db
%{_sbindir}/%{name}-recon
%{_mandir}/man8/sks.8.gz
-%{_initrddir}/sks-*
+%if 0%{?use_systemd}
+%{_unitdir}/sks-db.service
+%{_unitdir}/sks-recon.service
+%else # 0%{?use_systemd}
+%{_initrddir}/sks-db
+%{_initrddir}/sks-recon
+%endif # 0%{?use_systemd}
%changelog
+* Thu Sep 11 2014 Nick Bebout <nb at fedoraproject.org> - 1.1.5-6
+- Add systemd support
+
* Thu Aug 21 2014 Kevin Fenzi <kevin at scrye.com> - 1.1.5-5
- Rebuild for rpm bug 1131960
More information about the scm-commits
mailing list