use only systemd units with systemd

add trigger for restart on glibc, libselinux or pam upgrades (#699189)
This commit is contained in:
Tomas Mraz 2011-05-05 09:05:19 +02:00 committed by Marcela Mašláňová
parent 3a6490b2b2
commit 06e88d9ea6

View File

@ -2,11 +2,12 @@
%bcond_without pam %bcond_without pam
%bcond_without audit %bcond_without audit
%bcond_without inotify %bcond_without inotify
%bcond_without systemd
Summary: Cron daemon for executing programs at set times Summary: Cron daemon for executing programs at set times
Name: cronie Name: cronie
Version: 1.4.7 Version: 1.4.7
Release: 1%{?dist} Release: 2%{?dist}
License: MIT and BSD and ISC and GPLv2 License: MIT and BSD and ISC and GPLv2
Group: System Environment/Base Group: System Environment/Base
URL: https://fedorahosted.org/cronie URL: https://fedorahosted.org/cronie
@ -31,15 +32,19 @@ Buildrequires: pam-devel >= 1.0.1
Buildrequires: audit-libs-devel >= 1.4.1 Buildrequires: audit-libs-devel >= 1.4.1
%endif %endif
Requires(post): /sbin/chkconfig coreutils sed Requires(post): coreutils sed
Requires(postun): /sbin/chkconfig %if %{with systemd}
Requires(postun): /sbin/service
Requires(preun): /sbin/chkconfig
Requires(preun): /sbin/service
# systemd compatibility # systemd compatibility
Requires(post): systemd-units Requires(post): systemd-units
Requires(preun): systemd-units Requires(preun): systemd-units
Requires(postun): systemd-units Requires(postun): systemd-units
%else
Requires(post): /sbin/chkconfig
Requires(postun): /sbin/chkconfig
Requires(postun): /sbin/service
Requires(preun): /sbin/chkconfig
Requires(preun): /sbin/service
%endif
%description %description
Cronie contains the standard UNIX daemon crond that runs specified programs at Cronie contains the standard UNIX daemon crond that runs specified programs at
@ -98,13 +103,11 @@ make %{?_smp_mflags}
%install %install
make install DESTDIR=$RPM_BUILD_ROOT DESTMAN=$RPM_BUILD_ROOT%{_mandir} make install DESTDIR=$RPM_BUILD_ROOT DESTMAN=$RPM_BUILD_ROOT%{_mandir}
mkdir -pm700 $RPM_BUILD_ROOT%{_localstatedir}/spool/cron mkdir -pm700 $RPM_BUILD_ROOT%{_localstatedir}/spool/cron
mkdir -pm755 $RPM_BUILD_ROOT%{_initrddir}
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/ mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/
mkdir -pm755 $RPM_BUILD_ROOT%{_sysconfdir}/cron.d/ mkdir -pm755 $RPM_BUILD_ROOT%{_sysconfdir}/cron.d/
%if ! %{with pam} %if ! %{with pam}
rm -f $RPM_BUILD_ROOT%{_sysconfdir}/pam.d/crond rm -f $RPM_BUILD_ROOT%{_sysconfdir}/pam.d/crond
%endif %endif
install -m 755 cronie.init $RPM_BUILD_ROOT%{_initrddir}/crond
install -m 644 crond.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/crond install -m 644 crond.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/crond
touch $RPM_BUILD_ROOT%{_sysconfdir}/cron.deny touch $RPM_BUILD_ROOT%{_sysconfdir}/cron.deny
install -m 644 contrib/anacrontab $RPM_BUILD_ROOT%{_sysconfdir}/anacrontab install -m 644 contrib/anacrontab $RPM_BUILD_ROOT%{_sysconfdir}/anacrontab
@ -119,13 +122,25 @@ touch $RPM_BUILD_ROOT/var/spool/anacron/cron.monthly
# noanacron package # noanacron package
install -m 644 contrib/dailyjobs $RPM_BUILD_ROOT/%{_sysconfdir}/cron.d/dailyjobs install -m 644 contrib/dailyjobs $RPM_BUILD_ROOT/%{_sysconfdir}/cron.d/dailyjobs
%if %{with systemd}
# install systemd initscript # install systemd initscript
mkdir -p $RPM_BUILD_ROOT/lib/systemd/system/ mkdir -p $RPM_BUILD_ROOT/lib/systemd/system/
install -m 644 %SOURCE1 $RPM_BUILD_ROOT/lib/systemd/system/crond.service install -m 644 %SOURCE1 $RPM_BUILD_ROOT/lib/systemd/system/crond.service
%else
mkdir -pm755 $RPM_BUILD_ROOT%{_initrddir}
install -m 755 cronie.init $RPM_BUILD_ROOT%{_initrddir}/crond
%endif
%post %post
%if %{with systemd}
if [ $1 -eq 1 ] ; then
# Initial installation
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
/bin/systemctl enable crond.service >/dev/null 2>&1 || :
fi
%else
/sbin/chkconfig --add crond >/dev/null 2>&1 || : /sbin/chkconfig --add crond >/dev/null 2>&1 || :
/bin/systemctl enable crond.service >/dev/null 2>&1 || : %endif
%post anacron %post anacron
[ -e /var/spool/anacron/cron.daily ] || touch /var/spool/anacron/cron.daily [ -e /var/spool/anacron/cron.daily ] || touch /var/spool/anacron/cron.daily
@ -133,23 +148,30 @@ install -m 644 %SOURCE1 $RPM_BUILD_ROOT/lib/systemd/system/crond.service
[ -e /var/spool/anacron/cron.monthly ] || touch /var/spool/anacron/cron.monthly [ -e /var/spool/anacron/cron.monthly ] || touch /var/spool/anacron/cron.monthly
%preun %preun
if [ "$1" = "0" ]; then if [ $1 -eq 0 ]; then
%if %{with systemd}
/bin/systemctl --no-reload disable crond.service >/dev/null 2>&1 || :
/bin/systemctl stop crond.service > /dev/null 2>&1 || :
%else
service crond stop >/dev/null 2>&1 ||: service crond stop >/dev/null 2>&1 ||:
/sbin/chkconfig --del crond /sbin/chkconfig --del crond
# systemd %endif
/bin/systemctl disable crond.service >/dev/null 2>&1 || :
/bin/systemctl stop crond.service > /dev/null 2>&1 || :
fi fi
%postun %postun
if [ "$1" -ge "1" ]; then %if %{with systemd}
service crond condrestart > /dev/null 2>&1 ||: /bin/systemctl daemon-reload >/dev/null 2>&1 || :
# systemd %endif
if [ $1 -ge 1 ]; then
%if %{with systemd}
/bin/systemctl try-restart crond.service >/dev/null 2>&1 || : /bin/systemctl try-restart crond.service >/dev/null 2>&1 || :
%else
service crond condrestart > /dev/null 2>&1 ||:
%endif
fi fi
# empty /etc/crontab in case there are only old regular jobs
%triggerun -- cronie < 1.4.1 %triggerun -- cronie < 1.4.1
# empty /etc/crontab in case there are only old regular jobs
cp -a /etc/crontab /etc/crontab.rpmsave cp -a /etc/crontab /etc/crontab.rpmsave
sed -e '/^01 \* \* \* \* root run-parts \/etc\/cron\.hourly/d'\ sed -e '/^01 \* \* \* \* root run-parts \/etc\/cron\.hourly/d'\
-e '/^02 4 \* \* \* root run-parts \/etc\/cron\.daily/d'\ -e '/^02 4 \* \* \* root run-parts \/etc\/cron\.daily/d'\
@ -157,15 +179,29 @@ sed -e '/^01 \* \* \* \* root run-parts \/etc\/cron\.hourly/d'\
-e '/^42 4 1 \* \* root run-parts \/etc\/cron\.monthly/d' /etc/crontab.rpmsave > /etc/crontab -e '/^42 4 1 \* \* root run-parts \/etc\/cron\.monthly/d' /etc/crontab.rpmsave > /etc/crontab
exit 0 exit 0
#copy the lock, remove old daemon from chkconfig %if %{with systemd}
%triggerun -- vixie-cron %triggerun -- cronie < 1.4.7-2
cp -a /var/lock/subsys/crond /var/lock/subsys/cronie > /dev/null 2>&1 ||: # Save the current service runlevel info
# User must manually run systemd-sysv-convert --apply crond
# to migrate them to systemd targets
/usr/bin/systemd-sysv-convert --save crond
#if the lock exist, then we restart daemon (it was running in the past). # The package is allowed to autostart:
#add new daemon into chkconfig everytime, when we upgrade to cronie from vixie-cron /bin/systemctl enable crond.service >/dev/null 2>&1
%triggerpostun -- vixie-cron
/sbin/chkconfig --add crond /sbin/chkconfig --del crond >/dev/null 2>&1 || :
[ -f /var/lock/subsys/cronie ] && ( rm -f /var/lock/subsys/cronie ; service crond restart ) > /dev/null 2>&1 ||: /bin/systemctl try-restart crond.service >/dev/null 2>&1 || :
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
%endif
%triggerin -- pam, glibc, libselinux
# changes in pam, glibc or libselinux can make crond crash
# when it calls pam
%if %{with systemd}
/bin/systemctl try-restart crond.service >/dev/null 2>&1 || :
%else
service crond condrestart > /dev/null 2>&1 ||:
%endif
%files %files
%defattr(-,root,root,-) %defattr(-,root,root,-)
@ -178,14 +214,17 @@ cp -a /var/lock/subsys/crond /var/lock/subsys/cronie > /dev/null 2>&1 ||:
%{_mandir}/man1/crontab.* %{_mandir}/man1/crontab.*
%dir %{_localstatedir}/spool/cron %dir %{_localstatedir}/spool/cron
%dir %{_sysconfdir}/cron.d %dir %{_sysconfdir}/cron.d
%{_initrddir}/crond
%if %{with pam} %if %{with pam}
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/pam.d/crond %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/pam.d/crond
%endif %endif
%config(noreplace) %{_sysconfdir}/sysconfig/crond %config(noreplace) %{_sysconfdir}/sysconfig/crond
%config(noreplace) %{_sysconfdir}/cron.deny %config(noreplace) %{_sysconfdir}/cron.deny
%attr(0644,root,root) %{_sysconfdir}/cron.d/0hourly %attr(0644,root,root) %{_sysconfdir}/cron.d/0hourly
%if %{with systemd}
%attr(0644,root,root) /lib/systemd/system/crond.service %attr(0644,root,root) /lib/systemd/system/crond.service
%else
%{_initrddir}/crond
%endif
%files anacron %files anacron
%defattr(-,root,root,-) %defattr(-,root,root,-)
@ -204,6 +243,10 @@ cp -a /var/lock/subsys/crond /var/lock/subsys/cronie > /dev/null 2>&1 ||:
%attr(0644,root,root) %{_sysconfdir}/cron.d/dailyjobs %attr(0644,root,root) %{_sysconfdir}/cron.d/dailyjobs
%changelog %changelog
* Thu May 05 2011 Tomáš Mráz <tmraz@redhat.com> - 1.4.7-2
- use only systemd units with systemd
- add trigger for restart on glibc, libselinux or pam upgrades (#699189)
* Tue Mar 15 2011 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.7-1 * Tue Mar 15 2011 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.7-1
- new release 1.4.7 - new release 1.4.7