File golang-github-lusitaniae-apache_exporter.spec of Package golang-github-lusitaniae-apache_exporter.11261

# spec file for package golang-github-lusitaniae-apache_exporter
# Copyright (c) 2019 João Cavalheiro <>
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

# Templating vars to simplify and standardize Prometheus exporters spec files
%define	githubrepo
%define	upstreamname  apache_exporter
%define	targetname    prometheus-apache_exporter
%define	serviceuser   prometheus

Name:           golang-github-lusitaniae-apache_exporter
Version:        0.5.0
Release:        0
License:        MIT
Summary:        Apache Exporter for Prometheus
Url:            http://%{githubrepo}
Group:          System/Management
Source:         %{upstreamname}-%{version}.tar.gz
Source1:        %{targetname}.service
BuildRequires:  fdupes
BuildRequires:  golang-packaging
BuildRequires:  xz
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires(pre):  shadow

Exports apache mod_status statistics via HTTP for Prometheus consumption.

%setup -q -n %{upstreamname}-%{version}

%goprep %{githubrepo}

install -D -m0755 %{_builddir}/go/bin/%{upstreamname} %{buildroot}/%{_bindir}/%{targetname}
install -d -m 0755 %{buildroot}%{_unitdir}
install -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}
install -d -m 0755 %{buildroot}%{_sbindir}
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rc%{targetname}

%service_add_pre %{targetname}.service
getent group %{serviceuser} >/dev/null || %{_sbindir}/groupadd -r %{serviceuser}
getent passwd %{serviceuser} >/dev/null || %{_sbindir}/useradd -r -g %{serviceuser} -d %{_localstatedir}/lib/%{serviceuser} -M -s /sbin/nologin %{serviceuser}

%service_add_post %{targetname}.service

%service_del_preun %{targetname}.service

%service_del_postun %{targetname}.service


openSUSE Build Service is sponsored by