BuildRequires: libgcrypt-devel, kernel-headers, libtool-ltdl-devel
Vendor: collectd development team <collectd@verplant.org>
+%if 0%{?el7:1}
+Requires(pre): initscripts
+Requires(post): systemd
+Requires(preun): systemd
+Requires(postun): systemd
+%else
Requires(post): chkconfig
Requires(preun): chkconfig, initscripts
Requires(postun): initscripts
+%endif
%description
collectd is a small daemon which collects system information periodically and
Group: System Environment/Daemons
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
-%if 0%{?rhel} >= 6
+ %if 0%{?rhel} >= 6
BuildRequires: perl-ExtUtils-Embed
-%else
+ %else
BuildRequires: perl
-%endif
+ %endif
%description perl
The Perl plugin embeds a Perl interpreter into collectd and exposes the
application programming interface (API) to Perl-scripts.
Summary: Python plugin for collectd
Group: System Environment/Daemons
Requires: %{name}%{?_isa} = %{version}-%{release}
-%if 0%{?rhel} >= 6
+ %if 0%{?rhel} >= 6
BuildRequires: python-devel
-%else
+ %else
BuildRequires: python26-devel
-%endif
+ %endif
%description python
The Python plugin embeds a Python interpreter into collectd and exposes the
application programming interface (API) to Python-scripts.
%endif
%if %{with_python}
-%if 0%{?rhel} >= 6
+ %if 0%{?rhel} >= 6
%define _with_python --enable-python
-%else
+ %else
%define _with_python --enable-python --with-python=%{_bindir}/python2.6
-%endif
+ %endif
%else
%define _with_python --disable-python
%endif
%install
rm -rf %{buildroot}
%{__make} install DESTDIR=%{buildroot}
-%{__install} -Dp -m 0755 contrib/redhat/init.d-collectd %{buildroot}%{_initrddir}/collectd
+%if 0%{?el7:1}
+%{__install} -Dp -m0644 contrib/systemd.collectd.service %{buildroot}%{_unitdir}/collectd.service
+%else
+%{__install} -Dp -m0755 contrib/redhat/init.d-collectd %{buildroot}%{_initrddir}/collectd
+%endif
%{__install} -Dp -m0644 src/collectd.conf %{buildroot}%{_sysconfdir}/collectd.conf
%{__install} -d %{buildroot}%{_sharedstatedir}/collectd/
%{__install} -d %{buildroot}%{_sysconfdir}/collectd.d/
%clean
rm -rf %{buildroot}
+%pre
+%if 0%{?el7:1}
+# stop sysv-based instance before upgrading to systemd
+if [ $1 -eq 2 ] && [ -f /var/lock/subsys/collectd ]; then
+ SYSTEMCTL_SKIP_REDIRECT=1 %{_initddir}/collectd stop >/dev/null 2>&1 || :
+fi
+%endif
+
%post
-/sbin/chkconfig --add collectd
+%if 0%{?el7:1}
+if [ $1 -eq 2 ]; then
+ /usr/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
+%systemd_post collectd.service
+%else
+/sbin/chkconfig --add collectd || :
+%endif
%preun
+%if 0%{?el7:1}
+%systemd_preun collectd.service
+%else
+# stop collectd only when uninstalling
if [ $1 -eq 0 ]; then
- /sbin/service collectd stop &>/dev/null
- /sbin/chkconfig --del collectd
+ /sbin/service collectd stop >/dev/null 2>&1 || :
+ /sbin/chkconfig --del collectd || :
fi
+%endif
%postun
-if [ $1 -ge 1 ]; then
- /sbin/service collectd condrestart &>/dev/null || :
+%if 0%{?el7:1}
+%systemd_postun_with_restart collectd.service
+%else
+# restart collectd only when upgrading
+if [ $1 -eq 1 ]; then
+ /sbin/service collectd condrestart >/dev/null 2>&1 || :
fi
+%endif
%post -n libcollectdclient -p /sbin/ldconfig
%postun -n libcollectdclient -p /sbin/ldconfig
%files
%doc AUTHORS COPYING ChangeLog README
%config(noreplace) %{_sysconfdir}/collectd.conf
+%if 0%{?el7:1}
+%{_unitdir}/collectd.service
+%else
%{_initrddir}/collectd
+%endif
%{_sbindir}/collectd
%{_bindir}/collectd-nagios
%{_bindir}/collectd-tg
# - New plugins disabled by default: barometer, write_kafka
# - Enable zfs_arc, now supported on Linux
# - Install disk plugin in an dedicated package, as it depends on libudev
+# - use systemd on EL7, sysvinit on EL6 & EL5
* Mon Aug 19 2013 Marc Fournier <marc.fournier@camptocamp.com> 5.4.0-1
- New upstream version