Name: icingadb-redis
Version: 7.2.6
Release: 2%{?dist}
Summary: Redis database for Icinga DB
Group: Productivity/Databases/Daemons
License: BSD-3-Clause
URL: https://icinga.com
Source0: icingadb-redis-7.2.6.tgz
Source1: icingadb-redis-rpm.tgz

BuildRequires: gcc
BuildRequires: make
BuildRequires: openssl-devel
BuildRequires: sed
BuildRequires: systemd-devel
BuildRequires: systemd-rpm-macros
BuildRequires: tcl
BuildRequires: which
BuildRequires: rpm-build

Requires(pre): shadow-utils

%description
Icinga DB is a set of components for publishing, synchronizing and
visualizing monitoring data in the Icinga ecosystem.
This provides a dedicated Redis server for Icinga DB.

%define debug_package %{nil}

%prep
%autosetup
cd '/%_topdir/BUILD'
cd 'icingadb-redis-7.2.6'
rm -rf '%_topdir/BUILD/icingadb-redis-7.2.6-SPECPARTS'
/usr/bin/mkdir -p '%_topdir/BUILD/icingadb-redis-7.2.6-SPECPARTS'
tar -xzvf '%_topdir/SOURCES/icingadb-redis-rpm.tgz'
STATUS=$?
if [ $STATUS -ne 0 ]; then
exit $STATUS
fi
/usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
patch -sp1 < redis.conf.patch

sed -i 's@/usr/libexec@/usr/libexec@g' icingadb-redis-cli-6380.sh
make BUILD_TLS=yes USE_SYSTEMD=yes

%check
./runtest --tags unit

%install

install -dm 0750 %_topdir/BUILDROOT/icingadb-redis-7.2.6-2%{?dist}.%{_arch}/var/lib/icingadb-redis
install -dm 0750 %_topdir/BUILDROOT/icingadb-redis-7.2.6-2%{?dist}.%{_arch}/etc/icingadb-redis
install -pm 0640 redis.conf %_topdir/BUILDROOT/icingadb-redis-7.2.6-2%{?dist}.%{_arch}/etc/icingadb-redis/icingadb-redis.conf
install -dm 0755 %_topdir/BUILDROOT/icingadb-redis-7.2.6-2%{?dist}.%{_arch}/usr/share/icingadb-redis
install -pm 0644 icingadb-redis-systemd.conf %_topdir/BUILDROOT/icingadb-redis-7.2.6-2%{?dist}.%{_arch}/usr/share/icingadb-redis/icingadb-redis-systemd.conf
install -Dpm 0644 icingadb-redis.service %_topdir/BUILDROOT/icingadb-redis-7.2.6-2%{?dist}.%{_arch}%{_unitdir}/icingadb-redis.service
install -dm 0755 %_topdir/BUILDROOT/icingadb-redis-7.2.6-2%{?dist}.%{_arch}/usr/bin
install -pm 0755 src/redis-server %_topdir/BUILDROOT/icingadb-redis-7.2.6-2%{?dist}.%{_arch}/usr/bin/icingadb-redis-server
install -dm 0755 %_topdir/BUILDROOT/icingadb-redis-7.2.6-2%{?dist}.%{_arch}/usr/libexec
install -dm 0755 %_topdir/BUILDROOT/icingadb-redis-7.2.6-2%{?dist}.%{_arch}/usr/libexec/icingadb-redis
install -pm 0755 src/redis-cli %_topdir/BUILDROOT/icingadb-redis-7.2.6-2%{?dist}.%{_arch}/usr/libexec/icingadb-redis/redis-cli
install -pm 0755 icingadb-redis-cli-6380.sh %_topdir/BUILDROOT/icingadb-redis-7.2.6-2%{?dist}.%{_arch}/usr/bin/icingadb-redis-cli

%pre
getent passwd icingadb-redis >/dev/null || useradd -rU -d /var/lib/icingadb-redis -s /sbin/nologin icingadb-redis

%post
%systemd_post icingadb-redis.service

%preun
%systemd_preun icingadb-redis.service

%postun
%systemd_postun_with_restart icingadb-redis.service

%files
%dir /usr/share/icingadb-redis
/usr/share/icingadb-redis/icingadb-redis-systemd.conf
%{_unitdir}/icingadb-redis.service
%dir /usr/libexec/icingadb-redis
/usr/libexec/icingadb-redis/redis-cli
/usr/bin/icingadb-redis-server
/usr/bin/icingadb-redis-cli

%attr(-, icingadb-redis, root) %dir /etc/icingadb-redis
%attr(-, icingadb-redis, root) %config(noreplace) /etc/icingadb-redis/icingadb-redis.conf
%attr(-, icingadb-redis, root) %dir /var/lib/icingadb-redis

%changelog
* Fri Oct 25 2024 Icinga GmbH <info@icinga.com> - 7.2.6-2
- Version 7.2.6-2