cron and systemd adjustments

- Move cron to a separate file, and require crontabs (RHBZ #947047).
- Update for systemd (RHBZ #947047).

Thanks Jóhann B. Guðmundsson <johannbg@fedoraproject.org> for both
fixes.

- Replace tab with spaces to satisfy rpmlint.
This commit is contained in:
Ken Dreyer 2014-02-06 21:15:39 -07:00
parent 88983c1129
commit 3badc5cd12
2 changed files with 35 additions and 9 deletions

1
cacti.cron Normal file
View File

@ -0,0 +1 @@
#*/5 * * * * cacti /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

View File

@ -1,8 +1,13 @@
Name: cacti Name: cacti
Version: 0.8.8b Version: 0.8.8b
Release: 3%{?dist} Release: 4%{?dist}
Summary: An rrd based graphing tool 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 Group: Applications/System
# There's a lot of stuff in there. It's all compatible. # 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) 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 Source4: d.gif
Source5: d.png Source5: d.png
Source6: throbber.gif Source6: throbber.gif
Source7: %{name}.cron
# Add replacement files for treeview # Add replacement files for treeview
Patch0: cacti-0.8.8a-legal.patch Patch0: cacti-0.8.8a-legal.patch
# Thanks to Paul Gevers and Jan Zalesak (Debian) # 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: php, php-mysql, mysql, httpd, rrdtool, net-snmp, php-snmp
Requires: net-snmp-utils Requires: net-snmp-utils
Requires: crontabs
Requires(pre): %{_sbindir}/useradd Requires(pre): %{_sbindir}/useradd
%if 0%{?_with_systemd}
Requires(preun): systemd
Requires(postun): systemd
Requires(post): systemd
%else
Requires(postun): /sbin/service Requires(postun): /sbin/service
%endif
BuildArch: noarch BuildArch: noarch
# This macro was added in Fedora 20. Use the old version if it's undefined # 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/ cp %{SOURCE4} %{SOURCE5} %{SOURCE6} include/js/jquery/themes/default/
rm -rf include/treeview rm -rf include/treeview
echo "#*/5 * * * * cacti %{_bindir}/php %{_datadir}/%{name}/poller.php > /dev/null 2>&1" >cacti.cron
%build %build
# cacti's build is a noop # cacti's build is a noop
@ -83,14 +94,14 @@ rm -rf %{buildroot}
%{__install} -m 0755 scripts/* %{buildroot}/%{_localstatedir}/lib/%{name}/scripts/ %{__install} -m 0755 scripts/* %{buildroot}/%{_localstatedir}/lib/%{name}/scripts/
%{__install} -d -m 0755 cli/ %{buildroot}/%{_localstatedir}/lib//%{name}/cli/ %{__install} -d -m 0755 cli/ %{buildroot}/%{_localstatedir}/lib//%{name}/cli/
%{__install} -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 %{SOURCE1} %{buildroot}/%{_sysconfdir}/httpd/conf.d/cacti.conf
%{__install} -D -m 0644 %{SOURCE2} %{buildroot}/%{_sysconfdir}/logrotate.d/cacti %{__install} -D -m 0644 %{SOURCE2} %{buildroot}/%{_sysconfdir}/logrotate.d/cacti
# The su parameter will trip up older logrotate versions. # The su parameter will trip up older logrotate versions.
# Conditionally remove it here. # Conditionally remove it here.
%if 0%{?rhel} && 0%{?rhel} <= 6 %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 %endif
%{__cp} -a images/ include/ install/ lib/ plugins/ resource/ %{buildroot}%{_datadir}/%{name} %{__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 || : %{_sbindir}/useradd -d %{_datadir}/%{name} -r -s /sbin/nologin cacti 2> /dev/null || :
%post %post
if [ $1 == 1 ]; then %if 0%{?_with_systemd}
/sbin/service httpd condrestart > /dev/null 2>&1 || : %systemd_post httpd.service
fi %else
if [ $1 == 1 ]; then
/sbin/service httpd condrestart > /dev/null 2>&1 || :
fi
%endif
%postun %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 %files
%defattr(-,root,root,-) %defattr(-,root,root,-)
@ -152,6 +171,12 @@ fi
%attr(0644,root,root) %{_localstatedir}/lib/%{name}/lib %attr(0644,root,root) %{_localstatedir}/lib/%{name}/lib
%changelog %changelog
* Fri Feb 07 2014 Ken Dreyer <ktdreyer@ktdreyer.com> - 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 <ktdreyer@ktdreyer.com> - 0.8.8b-3 * Wed Sep 04 2013 Ken Dreyer <ktdreyer@ktdreyer.com> - 0.8.8b-3
- Fix comments in thumbnails (BZ #1004550) - Fix comments in thumbnails (BZ #1004550)