File snclient.spec of Package snclient
#
# spec file for package snclient
#
# Copyright (c) 2024-2025, 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: snclient
Version: 0.37
Release: 0
Summary: Monitoring agent designed as replacement for NRPE and NSClient+
License: MIT
Group: System/Monitoring
URL: https://github.com/ConSol-Monitoring/snclient
#Git-Clone: https://github.com/ConSol-Monitoring/snclient.git
Source: https://github.com/ConSol-Monitoring/snclient/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1: vendor.tar.gz
BuildRequires: go1.24
BuildRequires: golang-packaging
BuildRequires: help2man
BuildRequires: openssl
BuildRequires: systemd-rpm-macros
Recommends: logrotate
%{go_provides}
%description
SNClient+ (Secure Naemon Client) is a general purpose monitoring agent
designed providing NRPE/NSCP like system checks and prometheus metrics.
%package bash-completion
Summary: Bash Completion for %{name}
Group: Productivity/Networking/Diagnostic
Requires: %{name} = %{version}
Requires: bash-completion
Supplements: (%{name} and bash-completion)
BuildArch: noarch
%description bash-completion
Bash completion script for %{name}.
%prep
%autosetup -a 1
%build
go build \
-mod=vendor \
-buildmode=pie \
-o snclient ./cmd/snclient
# create certificates, manpages
%make_build dist
# generate bash-completion script
./snclient completion bash > snclient.bash
%install
install -Dm 0755 snclient %{buildroot}%{_bindir}/snclient
install -Dm 0644 packaging/snclient.ini %{buildroot}%{_sysconfdir}/snclient/snclient.ini
# certs
install -m 0644 dist/server.crt %{buildroot}%{_sysconfdir}/snclient/server.crt
install -m 0644 dist/server.key %{buildroot}%{_sysconfdir}/snclient/server.key
install -m 0644 dist/cacert.pem %{buildroot}%{_sysconfdir}/snclient/cacert.pem
install -m 0644 dist/ca.key %{buildroot}%{_sysconfdir}/snclient/ca.key
# manpages
install -Dm 0644 dist/snclient.1 %{buildroot}%{_mandir}/man1/snclient.1
install -Dm 0644 dist/snclient.8 %{buildroot}%{_mandir}/man8/snclient.8
# logrotate
install -d %{buildroot}%{_localstatedir}/log/snclient/
install -Dm 0644 packaging/snclient.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/snclient
# systemd service
install -Dm 0644 packaging/snclient.service %{buildroot}%{_unitdir}/snclient.service
# bash-completion
install -Dm 0644 snclient.bash %{buildroot}%{_datadir}/bash-completion/completions/%{name}
%pre
%service_add_pre snclient.service
%preun
%service_del_preun snclient.service
%post
%service_add_post snclient.service
%postun
%service_del_postun snclient.service
%files
%license LICENSE
%doc Changes README.md
%{_bindir}/snclient
%dir %{_sysconfdir}/snclient/
%config(noreplace)%{_sysconfdir}/snclient/snclient.ini
%config(noreplace) %{_sysconfdir}/snclient/server.crt
%config(noreplace) %{_sysconfdir}/snclient/server.key
%config(noreplace) %{_sysconfdir}/snclient/cacert.pem
%config(noreplace) %{_sysconfdir}/snclient/ca.key
%{_mandir}/man1/snclient.1%{?ext_man}
%{_mandir}/man8/snclient.8%{?ext_man}
%{_localstatedir}/log/snclient/
%config %{_sysconfdir}/logrotate.d/snclient
%{_unitdir}/snclient.service
%files bash-completion
%{_datadir}/bash-completion/completions/%{name}
%changelog