File systemd-htop-service.spec of Package systemd-htop-service

#
# spec file for package systemd-htop-service
#
# Copyright (c) 2012-2024 Malcolm J Lewis <malcolmlewis@opensuse.org>
#
# 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 http://bugs.opensuse.org/
#

%define         htop_user htopd
%define         htop_homedir /var/lib/htopd

Name:           systemd-htop-service
Version:        0.9
Release:        0
License:        GPL-2.0
Summary:        Systemd service for htop
Url:            https://github.com/malcolmlewis/systemd-htop-service
Group:          System/Daemons
Source0:        https://github.com/malcolmlewis/%{name}/archive/%{name}.tar.gz#/%{name}-%{version}.tar.gz
BuildRequires:  systemd
BuildRequires:  udev
Requires(pre):  %fillup_prereq
# MANUAL BEGIN
Requires:       htop
Requires:       systemd
# MANUAL END
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%description
This is a systemd service to start htop on a virtual terminal
(aka /dev/ttyN).

%prep
%setup -q

%build
# No building required, just a placehoder.

%install
%makeinstall
mkdir -p %{buildroot}%{_sbindir}
pushd %{buildroot}%{_sbindir}
ln -s service rchtop
popd

%pre
%service_add_pre htop.service

%post
# Add the htopd user as a system user
/usr/sbin/useradd -r -g tty \
    -s /usr/bin/false -c "systemd htop user" \
    -d %{htop_homedir} %{htop_user} >/dev/null 2>&1 || :
%{fillup_only -n htop}
%service_add_post htop.service

%preun
%service_del_preun htop.service

%postun
%service_del_postun htop.service

%files
%defattr(-,root,root,-)
%doc README.md
%license LICENSE
%{_udevrulesdir}/10-tty.rules
%{_sbindir}/rchtop
%{_fillupdir}/sysconfig.htop
%{_unitdir}/htop.service

%changelog
openSUSE Build Service is sponsored by