############################# # AUTOGENERATED FROM TEMPLATE ############################# %define debug_package %{nil} %define user prometheus %define group prometheus Name: node_exporter Version: 1.0.1 Release: 2%{?dist} Summary: Prometheus exporter for machine metrics, written in Go with pluggable metric collectors. License: ASL 2.0 URL: https://github.com/prometheus/node_exporter Source0: https://github.com/prometheus/node_exporter/releases/download/v%{version}/%{name}-%{version}.linux-amd64.tar.gz Source1: autogen_%{name}.unit Source2: %{name}.default Source3: autogen_%{name}.init %if 0%{?rhel} < 8 BuildRequires: systemd %else BuildRequires: systemd-rpm-macros %endif %{?systemd_requires} Requires(pre): shadow-utils %if 0%{?el6} || 0%{?el5} Requires(post): chkconfig Requires(preun): chkconfig # This is for /sbin/service Requires(preun): initscripts %endif %description Prometheus exporter for hardware and OS metrics exposed by *NIX kernels, written in Go with pluggable metric collectors. %prep %setup -q -n %{name}-%{version}.linux-amd64 %build /bin/true %install mkdir -vp %{buildroot}%{_sharedstatedir}/prometheus install -D -m 755 %{name} %{buildroot}%{_bindir}/%{name} install -D -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/default/%{name} %if 0%{?el5} install -D -m 755 %{SOURCE3} %{buildroot}%{_initrddir}/%{name} %else %if 0%{?el6} install -D -m 755 %{SOURCE3} %{buildroot}%{_initddir}/%{name} %else install -D -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service %endif %endif %pre getent group prometheus >/dev/null || groupadd -r prometheus getent passwd prometheus >/dev/null || \ useradd -r -g prometheus -d %{_sharedstatedir}/prometheus -s /sbin/nologin \ -c "Prometheus services" prometheus exit 0 %post %if 0%{?el6} || 0%{?el5} chkconfig --add %{name} %else %systemd_post %{name}.service %endif %preun %if 0%{?el6} || 0%{?el5} if [ $1 -eq 0 ] ; then service %{name} stop > /dev/null 2>&1 chkconfig --del %{name} fi %else %systemd_preun %{name}.service %endif %postun %if 0%{?el6} || 0%{?el5} if [ "$1" -ge "1" ] ; then service %{name} condrestart >/dev/null 2>&1 || : fi %else %systemd_postun %{name}.service %endif %files %defattr(-,root,root,-) %{_bindir}/%{name} %config(noreplace) %{_sysconfdir}/default/%{name} %dir %attr(755, %{user}, %{group}) %{_sharedstatedir}/prometheus %if 0%{?el5} %{_initrdddir}/%{name} %else %if 0%{?el6} %{_initddir}/%{name} %else %{_unitdir}/%{name}.service %endif %endif