File crowdsec-custom-bouncer.spec of Package crowdsec-custom-bouncer
#
# spec file for package crowdsec-custom-bouncer
#
# Copyright (c) 2025 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: crowdsec-custom-bouncer
Version: 0.0.19
Release: 0
Summary: CrowdSec bouncer to use custom scripts
License: MIT
URL: https://github.com/crowdsecurity/cs-custom-bouncer
Source0: %{name}-%{version}.tar.gz
Source1: vendor.tar.gz
Source2: setup-%{name}
Source3: %{name}.service
BuildRequires: crowdsec
BuildRequires: golang(API) >= 1.20
%{?systemd_requires}
%description
Crowdsec bouncer written in golang for custom scripts.
crowdsec-custom-bouncer will periodically fetch new and expired/removed
decisions from CrowdSec Local API and will pass them as arguments to a custom
user script.
%prep
%autosetup -a1
%build
go build -buildmode=pie -mod=vendor -tags netgo -trimpath \
-ldflags "-X 'github.com/crowdsecurity/go-cs-lib/version.Version=%{version}'" \
-o %{name}
%install
install -Dm0755 %{name} %{buildroot}%{_bindir}/%{name}
install -Dm0600 config/%{name}.yaml %{buildroot}/etc/crowdsec/bouncers/%{name}.yaml
install -Dm0755 %{SOURCE2} %{buildroot}%{_bindir}/setup-%{name}
install -Dm0644 %{SOURCE3} %{buildroot}%{_unitdir}/%{name}.service
# we need to put a dummy bin_path variable into the config, otherwise the daemon won't start
sed -i 's|bin_path: \${BINARY_PATH}|bin_path: /usr/bin/true|g' %{buildroot}%{_sysconfdir}/crowdsec/bouncers/%{name}.yaml
%pre
%service_add_pre %{name}.service
%post
%service_add_post %{name}.service
%preun
%service_del_preun %{name}.service
%postun
%service_del_postun %{name}.service
%files
%doc README.md
%license LICENSE
%config(noreplace) %{_sysconfdir}/crowdsec/bouncers/%{name}.yaml
%{_bindir}/%{name}
%{_bindir}/setup-%{name}
%{_unitdir}/%{name}.service
%changelog