diff --git a/cacti.cron b/cacti.cron new file mode 100644 index 0000000..14b5f76 --- /dev/null +++ b/cacti.cron @@ -0,0 +1 @@ +#*/5 * * * * cacti /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1 diff --git a/cacti.spec b/cacti.spec index c1f595c..5ca9847 100644 --- a/cacti.spec +++ b/cacti.spec @@ -1,8 +1,13 @@ Name: cacti Version: 0.8.8b -Release: 3%{?dist} +Release: 4%{?dist} Summary: An rrd based graphing tool +# Use systemd unit files on Fedora 21+ and RHEL 7. +%if 0%{?fedora} >= 21 || 0%{?rhel} >= 7 + %global _with_systemd 1 +%endif + Group: Applications/System # There's a lot of stuff in there. It's all compatible. License: GPLv2+ and LGPLv2 and (MPLv1.1 or GPLv2 or LGPLv2) and (LGPLv2 or BSD) @@ -21,6 +26,7 @@ Source3: cacti.README.fedora Source4: d.gif Source5: d.png Source6: throbber.gif +Source7: %{name}.cron # Add replacement files for treeview Patch0: cacti-0.8.8a-legal.patch # Thanks to Paul Gevers and Jan Zalesak (Debian) @@ -38,8 +44,15 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Requires: php, php-mysql, mysql, httpd, rrdtool, net-snmp, php-snmp Requires: net-snmp-utils +Requires: crontabs Requires(pre): %{_sbindir}/useradd +%if 0%{?_with_systemd} +Requires(preun): systemd +Requires(postun): systemd +Requires(post): systemd +%else Requires(postun): /sbin/service +%endif BuildArch: noarch # This macro was added in Fedora 20. Use the old version if it's undefined @@ -65,8 +78,6 @@ used to creating traffic graphs with MRTG. cp %{SOURCE4} %{SOURCE5} %{SOURCE6} include/js/jquery/themes/default/ rm -rf include/treeview -echo "#*/5 * * * * cacti %{_bindir}/php %{_datadir}/%{name}/poller.php > /dev/null 2>&1" >cacti.cron - %build # cacti's build is a noop @@ -83,14 +94,14 @@ rm -rf %{buildroot} %{__install} -m 0755 scripts/* %{buildroot}/%{_localstatedir}/lib/%{name}/scripts/ %{__install} -d -m 0755 cli/ %{buildroot}/%{_localstatedir}/lib//%{name}/cli/ %{__install} -m 0755 cli/* %{buildroot}/%{_localstatedir}/lib/%{name}/cli/ -%{__install} -D -m 0644 cacti.cron %{buildroot}/%{_sysconfdir}/cron.d/cacti +%{__install} -p -D -m 0644 %{SOURCE7} %{buildroot}/%{_sysconfdir}/cron.d/%{name} %{__install} -D -m 0644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/httpd/conf.d/cacti.conf %{__install} -D -m 0644 %{SOURCE2} %{buildroot}/%{_sysconfdir}/logrotate.d/cacti # The su parameter will trip up older logrotate versions. # Conditionally remove it here. %if 0%{?rhel} && 0%{?rhel} <= 6 - sed -i %{buildroot}/%{_sysconfdir}/logrotate.d/cacti -e '/^[ \t]*su /d' + sed -i %{buildroot}/%{_sysconfdir}/logrotate.d/cacti -e '/^[ \t]*su /d' %endif %{__cp} -a images/ include/ install/ lib/ plugins/ resource/ %{buildroot}%{_datadir}/%{name} @@ -113,12 +124,20 @@ rm -rf %{buildroot} %{_sbindir}/useradd -d %{_datadir}/%{name} -r -s /sbin/nologin cacti 2> /dev/null || : %post -if [ $1 == 1 ]; then - /sbin/service httpd condrestart > /dev/null 2>&1 || : -fi +%if 0%{?_with_systemd} + %systemd_post httpd.service +%else + if [ $1 == 1 ]; then + /sbin/service httpd condrestart > /dev/null 2>&1 || : + fi +%endif %postun -/sbin/service httpd condrestart > /dev/null 2>&1 || : +%if 0%{?_with_systemd} + %systemd_postun_with_restart httpd.service +%else + /sbin/service httpd condrestart > /dev/null 2>&1 || : +%endif %files %defattr(-,root,root,-) @@ -152,6 +171,12 @@ fi %attr(0644,root,root) %{_localstatedir}/lib/%{name}/lib %changelog +* Fri Feb 07 2014 Ken Dreyer - 0.8.8b-4 +- Move cron to a separate file and require crontabs (RHBZ #947047). Thanks + Jóhann B. Guðmundsson. +- Update for systemd (RHBZ #947047). Thanks Jóhann B. Guðmundsson. +- Fix rpmlint warning about spaces-to-tabs + * Wed Sep 04 2013 Ken Dreyer - 0.8.8b-3 - Fix comments in thumbnails (BZ #1004550)