[openldap] specfile: migrate initscript to systemd service
jvcelak
jvcelak at fedoraproject.org
Tue Nov 1 14:39:51 UTC 2011
commit 2d2d8a4c8a3730e3319583b343f6c93bceb001c0
Author: Jan Vcelak <jvcelak at redhat.com>
Date: Tue Oct 25 18:24:10 2011 +0200
specfile: migrate initscript to systemd service
openldap.spec | 50 +++++++++++++++++++++++++++++++++++++-------------
1 files changed, 37 insertions(+), 13 deletions(-)
---
diff --git a/openldap.spec b/openldap.spec
index b90d5e7..76a2dbd 100644
--- a/openldap.spec
+++ b/openldap.spec
@@ -81,11 +81,12 @@ customized LDAP clients.
Summary: LDAP server
License: OpenLDAP
Requires: openldap = %{version}-%{release}, openssl
-Requires(pre): shadow-utils, initscripts
-Requires(post): chkconfig, /sbin/runuser, make, initscripts
-Requires(preun): chkconfig, initscripts
-# BEWARE: DB 5.1 is the latest version supported by OpenLDAP 2.4.25; however we have 5.2 in Rawhide
+Requires(pre): shadow-utils
+Requires(post): systemd-units, systemd-sysv, chkconfig
+Requires(preun): systemd-units
+Requires(postun): systemd-units
BuildRequires: libdb-devel >= 5.0, libdb-devel < 5.3
+BuildRequires: systemd-units
Group: System Environment/Daemons
%description servers
@@ -321,6 +322,13 @@ mkdir -p %{buildroot}/var/lib/ldap
mkdir -p %{buildroot}%{_sysconfdir}/tmpfiles.d
install -m 644 %SOURCE3 %{buildroot}%{_sysconfdir}/tmpfiles.d/slapd.conf
+# setup maintainance scripts
+mkdir -p %{buildroot}%{_libexecdir}/slapd
+install -m 0644 %SOURCE50 %{buildroot}%{_libexecdir}/slapd/functions
+install -m 0755 %SOURCE51 %{buildroot}%{_libexecdir}/slapd/convert-config.sh
+install -m 0755 %SOURCE52 %{buildroot}%{_libexecdir}/slapd/check-config.sh
+install -m 0755 %SOURCE53 %{buildroot}%{_libexecdir}/slapd/upgrade-db.sh
+
# remove build root from config files and manual pages
perl -pi -e "s|%{buildroot}||g" %{buildroot}/%{_sysconfdir}/openldap/*.conf
perl -pi -e "s|%{buildroot}||g" %{buildroot}%{_mandir}/*/*.*
@@ -330,8 +338,8 @@ rm -f %{buildroot}/%{_sysconfdir}/openldap/*.default
rm -f %{buildroot}/%{_sysconfdir}/openldap/schema/*.default
# install an init script for the servers
-mkdir -p %{buildroot}%{_sysconfdir}/rc.d/init.d
-install -m 755 %SOURCE1 %{buildroot}%{_sysconfdir}/rc.d/init.d/slapd
+mkdir -p %{buildroot}%{_unitdir}
+install -m 0644 %SOURCE1 %{buildroot}%{_unitdir}/
# install syconfig/ldap
mkdir -p %{buildroot}%{_sysconfdir}/sysconfig
@@ -471,7 +479,11 @@ exit 0
%post servers
/sbin/ldconfig
-/sbin/chkconfig --add slapd
+
+if [ $1 -eq 1 ]; then
+ # initial installation
+ /sbin/systemctl daemon-reload &>/dev/null || :
+fi
# generate sample TLS certificates
if [ ! -f %{_sysconfdir}/pki/tls/certs/slapd.pem ] ; then
@@ -533,21 +545,33 @@ fi
exit 0
%preun servers
-if [ $1 -eq 0 ] ; then
- /sbin/service slapd stop > /dev/null 2>&1 || :
- /sbin/chkconfig --del slapd
-
- # openldap-servers are being removed from system
- # do not touch the database!
+if [ $1 -eq 0 ]; then
+ # package removal
+ /bin/systemctl --no-reload disable slapd.service &>/dev/null || :
+ /bin/systemctl stop slapd.service &>/dev/null || :
fi
%postun servers
/sbin/ldconfig
+/bin/systemctl daemon-reload &>/dev/null || :
+if [ $1 -ge 1 ]; then
+ # package upgrade
+ /bin/systemctl try-restart slapd.service &>/dev/null || :
+fi
+
%post devel -p /sbin/ldconfig
%postun devel -p /sbin/ldconfig
+%triggerun servers -- openldap-servers < 2.4.26-6
+
+# migration from SysV to systemd
+/usr/bin/systemd-sysv-convert --save slapd &>/dev/null || :
+/sbin/chkconfig --del slapd &>/dev/null || :
+/bin/systemctl try-restart slapd.service &>/dev/null || :
+
+
%triggerin servers -- db4
# db4 upgrade (see %triggerun)
More information about the scm-commits
mailing list