summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3641c34)
raw | patch | inline | side by side (parent: 3641c34)
author | Marc Fournier <marc.fournier@camptocamp.com> | |
Mon, 1 Dec 2014 13:31:14 +0000 (14:31 +0100) | ||
committer | Marc Fournier <marc.fournier@camptocamp.com> | |
Wed, 3 Dec 2014 10:31:02 +0000 (11:31 +0100) |
Favor using systemd when installing on EL7, and upstart on EL6. No
changes for EL5. Uses the upstart & systemd config files from
the contrib/ directory.
The sysv initscript used on EL5 is still available in the
collectd-contrib package, for those who prefer using the traditional
init system.
changes for EL5. Uses the upstart & systemd config files from
the contrib/ directory.
The sysv initscript used on EL5 is still available in the
collectd-contrib package, for those who prefer using the traditional
init system.
contrib/redhat/collectd.spec | patch | blob | history |
index 29efd75d8d611650f6a0085708814e259df22ac1..ef8296fc3a0db89ed6fe8e971f392eaadefb8767 100644 (file)
BuildRequires: libgcrypt-devel, kernel-headers
Vendor: collectd development team <collectd@verplant.org>
+%if 0%{?el7:1}
+Requires(pre): initscripts
+Requires(post): systemd
+Requires(preun): systemd
+Requires(postun): systemd
+%else
+%if 0%{?el6:1}
+Requires(pre): initscripts
+Requires(preun): upstart
+Requires(postun): upstart
+%else
Requires(post): chkconfig
Requires(preun): chkconfig, initscripts
Requires(postun): initscripts
+%endif
+%endif
%description
collectd is a small daemon which collects system information periodically and
%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
+%if 0%{?el6:1}
+%{__install} -Dp -m0644 contrib/upstart.collectd.conf %{buildroot}%{_sysconfdir}/init/collectd.conf
+%else
+%{__install} -Dp -m0755 contrib/redhat/init.d-collectd %{buildroot}%{_initrddir}/collectd
+%endif
+%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}%{?el6:1}
+# stop sysv-based instance before upgrading to upstart/systemd
+if [ $1 -eq 2 ] && [ -f /var/lock/subsys/collectd ]; then
+ SYSTEMCTL_SKIP_REDIRECT=1 /etc/rc.d/init.d/collectd stop >/dev/null 2>&1 || :
+fi
+%else
+/bin/true
+%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
+%if 0%{?el6:1}
+/bin/true
+%else
+/sbin/chkconfig --add collectd || :
+%endif
+%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
+%if 0%{?el6:1}
+ /sbin/initctl stop collectd >/dev/null 2>&1 || :
+%else
+ /sbin/service collectd stop >/dev/null 2>&1 || :
+ /sbin/chkconfig --del collectd || :
+%endif
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
+%if 0%{?el6:1}
+ if /sbin/initctl status collectd 2>/dev/null | grep -q 'running'; then
+ /sbin/initctl restart collectd >/dev/null 2>&1 || :
+ else
+ /sbin/initctl start collectd >/dev/null 2>&1 || :
+ fi
+%else
+ /sbin/service collectd condrestart >/dev/null 2>&1 || :
+%endif
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
+%if 0%{?el6:1}
+%{_sysconfdir}/init/collectd.conf
+%else
%{_initrddir}/collectd
+%endif
+%endif
%{_sbindir}/collectd
%{_bindir}/collectd-nagios
%{_bindir}/collectd-tg