File adguard-exporter.spec of Package adguard-exporter
#
# spec file for package adguard-exporter
#
# Copyright (c) 2021 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#
Name: adguard-exporter
Version: 1.12
Release: 0
Summary: A Prometheus exporter for AdguardHome's Raspberry PI ad blocker
License: MIT
URL: https://github.com/ebrianne/adguard-exporter
Source0: %{name}-%{version}.tar.xz
Source1: vendor.tar.xz
Source2: %{name}.service
BuildRequires: golang(API) >= 1.14
BuildRequires: golang-packaging
Requires: adguardhome
%{?systemd_ordering}
%description
This is a Prometheus exporter for AdguardHome's Raspberry PI ad blocker.
It is based on the famous eko/pihole-exporter
%prep
%setup -q -a 1
%build
go build -mod vendor -buildmode pie -ldflags="-s -w" -o %{name} .
%install
install -Dm 0755 -t %{buildroot}%{_bindir} %{name}
install -Dm 0644 -t %{buildroot}%{_unitdir} %{S:2}
install -d %{buildroot}%{_sbindir}
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
%pre
%service_add_pre %{name}.service
%post
%service_add_post %{name}.service
# notify edit systemd unit after first installation
if [ "$1" -le 1 ]; then
mkdir -p %{_localstatedir}/adm/update-messages
cat > %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release}-something << EOF
INFO: You need to use 'systemctl edit adguard-exporter' to reset ExecStart, override file may like blow:
[Service]
ExecStart=
ExecStart=/usr/bin/adguard-exporter -adguard_protocol http -adguard_hostname <hostname> -adguard_username <username> -adguard_password <password> -log_limit 5000
EOF
fi
%preun
%service_del_preun %{name}.service
%postun
%service_del_postun %{name}.service
%files
%license LICENSE
%doc README.md
%{_bindir}/%{name}
%{_unitdir}/%{name}.service
%{_sbindir}/rc%{name}
%changelog