%define debug_package %{nil}
Name:    tezos-accuser-PsQuebec
Version: 21.4
Release: 1
Epoch: 1
Summary: Daemon for accusing
License: MIT
BuildArch: x86_64 aarch64
Source0: tezos-accuser-PsQuebec-21.4.tar.gz
Source1: https://gitlab.com/tezos/tezos/tree/v21.4/
BuildRequires: make wget systemd systemd-rpm-macros
Requires: , udev
%description
Daemon for accusing
Maintainer: Serokell <hi@serokell.io>
%prep
%setup -q
%build
%install
make octez-accuser-PsQuebec
mkdir -p %{buildroot}/%{_bindir}
install -m 0755 octez-accuser-PsQuebec %{buildroot}/%{_bindir}
ln -s %{_bindir}/octez-accuser-PsQuebec %{buildroot}/%{_bindir}/tezos-accuser-PsQuebec



mkdir -p %{buildroot}/%{_unitdir}
install -m 644 tezos-accuser-psquebec.service %{buildroot}/%{_unitdir}
install -m 644 tezos-accuser-psquebec@.service %{buildroot}/%{_unitdir}

mkdir -p %{buildroot}/%{_sysconfdir}/default
install -m 644 tezos-accuser-psquebec.default %{buildroot}/%{_sysconfdir}/default/tezos-accuser-psquebec

install -m 0755 tezos-accuser-psquebec-start %{buildroot}/%{_bindir}


%files
%license LICENSE

%{_bindir}/octez-accuser-PsQuebec
%{_bindir}/tezos-accuser-PsQuebec

%{_bindir}/tezos-accuser-psquebec-start

%{_unitdir}/tezos-accuser-psquebec.service
%{_unitdir}/tezos-accuser-psquebec@.service

%{_sysconfdir}/default/tezos-accuser-psquebec



%post
%systemd_post tezos-accuser-psquebec.service
%systemd_post tezos-accuser-psquebec@.service


if [ -z $(getent passwd tezos) ]; then
    useradd -r -s /bin/false -m -d /var/lib/tezos tezos
    chmod 0755 /var/lib/tezos
fi

mkdir -p /var/lib/tezos/.tezos-client
chown -R tezos:tezos /var/lib/tezos/.tezos-client


%preun
%systemd_preun tezos-accuser-psquebec.service
%systemd_preun tezos-accuser-psquebec@.service


%postun
%systemd_postun_with_restart tezos-accuser-psquebec.service
%systemd_postun_with_restart tezos-accuser-psquebec@.service