specfile: migrate initscript to systemd service

This commit is contained in:
Jan Vcelak 2011-10-25 18:24:10 +02:00
parent 0a9b211e8c
commit 2d2d8a4c8a

View File

@ -81,11 +81,12 @@ customized LDAP clients.
Summary: LDAP server Summary: LDAP server
License: OpenLDAP License: OpenLDAP
Requires: openldap = %{version}-%{release}, openssl Requires: openldap = %{version}-%{release}, openssl
Requires(pre): shadow-utils, initscripts Requires(pre): shadow-utils
Requires(post): chkconfig, /sbin/runuser, make, initscripts Requires(post): systemd-units, systemd-sysv, chkconfig
Requires(preun): chkconfig, initscripts Requires(preun): systemd-units
# BEWARE: DB 5.1 is the latest version supported by OpenLDAP 2.4.25; however we have 5.2 in Rawhide Requires(postun): systemd-units
BuildRequires: libdb-devel >= 5.0, libdb-devel < 5.3 BuildRequires: libdb-devel >= 5.0, libdb-devel < 5.3
BuildRequires: systemd-units
Group: System Environment/Daemons Group: System Environment/Daemons
%description servers %description servers
@ -321,6 +322,13 @@ mkdir -p %{buildroot}/var/lib/ldap
mkdir -p %{buildroot}%{_sysconfdir}/tmpfiles.d mkdir -p %{buildroot}%{_sysconfdir}/tmpfiles.d
install -m 644 %SOURCE3 %{buildroot}%{_sysconfdir}/tmpfiles.d/slapd.conf 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 # 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}/%{_sysconfdir}/openldap/*.conf
perl -pi -e "s|%{buildroot}||g" %{buildroot}%{_mandir}/*/*.* 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 rm -f %{buildroot}/%{_sysconfdir}/openldap/schema/*.default
# install an init script for the servers # install an init script for the servers
mkdir -p %{buildroot}%{_sysconfdir}/rc.d/init.d mkdir -p %{buildroot}%{_unitdir}
install -m 755 %SOURCE1 %{buildroot}%{_sysconfdir}/rc.d/init.d/slapd install -m 0644 %SOURCE1 %{buildroot}%{_unitdir}/
# install syconfig/ldap # install syconfig/ldap
mkdir -p %{buildroot}%{_sysconfdir}/sysconfig mkdir -p %{buildroot}%{_sysconfdir}/sysconfig
@ -471,7 +479,11 @@ exit 0
%post servers %post servers
/sbin/ldconfig /sbin/ldconfig
/sbin/chkconfig --add slapd
if [ $1 -eq 1 ]; then
# initial installation
/sbin/systemctl daemon-reload &>/dev/null || :
fi
# generate sample TLS certificates # generate sample TLS certificates
if [ ! -f %{_sysconfdir}/pki/tls/certs/slapd.pem ] ; then if [ ! -f %{_sysconfdir}/pki/tls/certs/slapd.pem ] ; then
@ -533,21 +545,33 @@ fi
exit 0 exit 0
%preun servers %preun servers
if [ $1 -eq 0 ] ; then if [ $1 -eq 0 ]; then
/sbin/service slapd stop > /dev/null 2>&1 || : # package removal
/sbin/chkconfig --del slapd /bin/systemctl --no-reload disable slapd.service &>/dev/null || :
/bin/systemctl stop slapd.service &>/dev/null || :
# openldap-servers are being removed from system
# do not touch the database!
fi fi
%postun servers %postun servers
/sbin/ldconfig /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 %post devel -p /sbin/ldconfig
%postun 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 %triggerin servers -- db4
# db4 upgrade (see %triggerun) # db4 upgrade (see %triggerun)