diff --git a/cronie.spec b/cronie.spec index b1e4d6d..0f4b92b 100644 --- a/cronie.spec +++ b/cronie.spec @@ -2,11 +2,12 @@ %bcond_without pam %bcond_without audit %bcond_without inotify +%bcond_without systemd Summary: Cron daemon for executing programs at set times Name: cronie Version: 1.4.7 -Release: 1%{?dist} +Release: 2%{?dist} License: MIT and BSD and ISC and GPLv2 Group: System Environment/Base URL: https://fedorahosted.org/cronie @@ -31,15 +32,19 @@ Buildrequires: pam-devel >= 1.0.1 Buildrequires: audit-libs-devel >= 1.4.1 %endif -Requires(post): /sbin/chkconfig coreutils sed -Requires(postun): /sbin/chkconfig -Requires(postun): /sbin/service -Requires(preun): /sbin/chkconfig -Requires(preun): /sbin/service +Requires(post): coreutils sed +%if %{with systemd} # systemd compatibility Requires(post): systemd-units Requires(preun): 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 Cronie contains the standard UNIX daemon crond that runs specified programs at @@ -98,13 +103,11 @@ make %{?_smp_mflags} %install make install DESTDIR=$RPM_BUILD_ROOT DESTMAN=$RPM_BUILD_ROOT%{_mandir} mkdir -pm700 $RPM_BUILD_ROOT%{_localstatedir}/spool/cron -mkdir -pm755 $RPM_BUILD_ROOT%{_initrddir} mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/ mkdir -pm755 $RPM_BUILD_ROOT%{_sysconfdir}/cron.d/ %if ! %{with pam} rm -f $RPM_BUILD_ROOT%{_sysconfdir}/pam.d/crond %endif -install -m 755 cronie.init $RPM_BUILD_ROOT%{_initrddir}/crond install -m 644 crond.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/crond touch $RPM_BUILD_ROOT%{_sysconfdir}/cron.deny 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 install -m 644 contrib/dailyjobs $RPM_BUILD_ROOT/%{_sysconfdir}/cron.d/dailyjobs +%if %{with systemd} # install systemd initscript mkdir -p $RPM_BUILD_ROOT/lib/systemd/system/ 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 +%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 || : -/bin/systemctl enable crond.service >/dev/null 2>&1 || : +%endif %post anacron [ -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 %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 ||: /sbin/chkconfig --del crond - # systemd - /bin/systemctl disable crond.service >/dev/null 2>&1 || : - /bin/systemctl stop crond.service > /dev/null 2>&1 || : +%endif fi %postun -if [ "$1" -ge "1" ]; then - service crond condrestart > /dev/null 2>&1 ||: - # systemd +%if %{with systemd} +/bin/systemctl daemon-reload >/dev/null 2>&1 || : +%endif +if [ $1 -ge 1 ]; then +%if %{with systemd} /bin/systemctl try-restart crond.service >/dev/null 2>&1 || : +%else + service crond condrestart > /dev/null 2>&1 ||: +%endif fi -# empty /etc/crontab in case there are only old regular jobs %triggerun -- cronie < 1.4.1 +# empty /etc/crontab in case there are only old regular jobs cp -a /etc/crontab /etc/crontab.rpmsave sed -e '/^01 \* \* \* \* root run-parts \/etc\/cron\.hourly/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 exit 0 -#copy the lock, remove old daemon from chkconfig -%triggerun -- vixie-cron -cp -a /var/lock/subsys/crond /var/lock/subsys/cronie > /dev/null 2>&1 ||: +%if %{with systemd} +%triggerun -- cronie < 1.4.7-2 +# 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). -#add new daemon into chkconfig everytime, when we upgrade to cronie from vixie-cron -%triggerpostun -- vixie-cron -/sbin/chkconfig --add crond -[ -f /var/lock/subsys/cronie ] && ( rm -f /var/lock/subsys/cronie ; service crond restart ) > /dev/null 2>&1 ||: +# The package is allowed to autostart: +/bin/systemctl enable crond.service >/dev/null 2>&1 + +/sbin/chkconfig --del crond >/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 %defattr(-,root,root,-) @@ -178,14 +214,17 @@ cp -a /var/lock/subsys/crond /var/lock/subsys/cronie > /dev/null 2>&1 ||: %{_mandir}/man1/crontab.* %dir %{_localstatedir}/spool/cron %dir %{_sysconfdir}/cron.d -%{_initrddir}/crond %if %{with pam} %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/pam.d/crond %endif %config(noreplace) %{_sysconfdir}/sysconfig/crond %config(noreplace) %{_sysconfdir}/cron.deny %attr(0644,root,root) %{_sysconfdir}/cron.d/0hourly +%if %{with systemd} %attr(0644,root,root) /lib/systemd/system/crond.service +%else +%{_initrddir}/crond +%endif %files anacron %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 %changelog +* Thu May 05 2011 Tomáš Mráz - 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á - 1.4.7-1 - new release 1.4.7