File thola.spec of Package thola

#
# spec file for package thola
#
# Copyright (c) 2021, Martin Hauke <mardnh@gmx.de>
#
# 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:           thola
Version:        0.5.2
Release:        0
Summary:        A tool for monitoring network devices
License:        BSD-2-Clause
Group:          System/Monitoring
URL:            https://thola.io/
#Git-Clone:     https://github.com/inexio/thola.git
Source:         https://github.com/inexio/thola/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        vendor.tar.gz
BuildRequires:  go
BuildRequires:  golang-packaging
Requires:       group(thola)
Requires:       user(thola)
ExclusiveArch:  x86_64 aarch64
%{go_provides}

%description
A tool for monitoring network devices written in Go (mainly using SNMP).
It features a check mode which complies with the monitoring plugins
development guidelines and is therefore compatible with Nagios, Icinga,
Zabbix, Checkmk, etc.

%prep
%autosetup -a 1
sed -i 's|/usr/local/bin/|/usr/bin/|g' scripts/thola.service

%build
for f in thola thola-client; do
  go build \
  -mod=vendor \
  -buildmode=pie \
  -o "$f" .
done

%install
for f in thola thola-client; do
  install -D -m0755 "$f" "%{buildroot}%{_bindir}/$f"
done

install -d %{buildroot}%{_localstatedir}/lib/thola/
install -m0644 config/config.yaml %{buildroot}%{_localstatedir}/lib/thola/
install -D -m0644 scripts/thola.service %{buildroot}%{_unitdir}/%{name}.service

%pre
%service_add_pre %{name}.service

%post
%service_add_post %{name}.service

%preun
%service_del_preun %{name}.service

%postun
%service_del_postun %{name}.service

%check
# Tests disabled since those need a docker environment
#cd test && go test -v -mod=vendor

%files
%license LICENSE
%doc README.md
%{_bindir}/thola
%{_bindir}/thola-client
%{_unitdir}/%{name}.service
%dir               %attr(-,thola,thola) %{_localstatedir}/lib/thola
%config(noreplace) %attr(-,thola,thola) %{_localstatedir}/lib/thola/config.yaml

%changelog
openSUSE Build Service is sponsored by