File monitorix.spec of Package monitorix

#
# spec file for package monitorix
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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/
#

%if !%{defined _fillupdir}
%define _fillupdir %{_localstatedir}/adm/fillup-templates
%endif
Name:           monitorix
Version:        3.14.0
Release:        0
Summary:        A lightweight system monitoring tool
License:        GPL-2.0-or-later
Group:          System/Monitoring
URL:            http://www.monitorix.org
Source:         http://www.monitorix.org/monitorix-%{version}.tar.gz
Source1:        monitorix-rpmlintrc
BuildRequires:  perl
Requires:       logrotate
Requires:       perl-MailTools
Requires:       perl-libwww-perl
Requires:       rrdtool
Requires:       perl(Config::General)
Requires:       perl(DBI)
Requires:       perl(HTTP::Server::Simple)
Requires:       perl(IO::Socket::SSL)
Requires:       perl(MIME::Lite)
Requires:       perl(XML::Simple)
BuildArch:      noarch
%{perl_requires}

%description
Monitorix is a free, open source, lightweight system monitoring tool designed
to monitor as many services and system resources as possible. It has been
created to be used on production Linux/UNIX servers, but due to its
simplicity and small size may also be used to monitor embedded devices as well.

%prep
%setup -q -n monitorix-%{version}
sed -i '/^#!/ s/env perl$/perl/' monitorix monitorix.cgi docs/htpasswd.pl

%build
# do nothing

%install
make install-systemd-all \
    DESTDIR=%{buildroot} \
    MAN5DIR=%{_mandir}/man5 \
    MAN8DIR=%{_mandir}/man8 \
    DOCDIR="%{_docdir}/%{name}"
rm %{buildroot}%{_docdir}/%{name}/COPYING
rm  %{buildroot}%{_docdir}/%{name}/README.BSD

mkdir -p %{buildroot}%{_fillupdir}
mv %{buildroot}%{_sysconfdir}/sysconfig/monitorix \
  %{buildroot}%{_fillupdir}/sysconfig.monitorix

mkdir -p %{buildroot}%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcmonitorix

%pre
%service_add_pre monitorix.service

%post
%service_add_post monitorix.service
%fillup_only monitorix
%set_permissions %{_localstatedir}/lib/monitorix/www/imgs/

%preun
%service_del_preun monitorix.service

%postun
%service_del_postun monitorix.service

# TODO: chown to monitorix
%verifyscript
%verify_permissions -e %{_localstatedir}/lib/monitorix/www/imgs/

%files
%defattr(-,root,root)
%if 0%{?suse_version} >= 1500
%license COPYING
%else
%doc COPYING
%endif
%doc %{_docdir}/%{name}/
%config(noreplace) %{_sysconfdir}/logrotate.d/monitorix
%dir %{_sysconfdir}/monitorix/
%dir %{_sysconfdir}/monitorix/conf.d/
%config(noreplace) %{_sysconfdir}/monitorix/monitorix.conf
%{_bindir}/monitorix
%{_sbindir}/rcmonitorix
%{_unitdir}/monitorix.service
%{_prefix}/lib/monitorix/
%{_localstatedir}/lib/monitorix/
%{_fillupdir}/sysconfig.monitorix
%{_mandir}/man5/monitorix.conf.5%{?ext_man}
%{_mandir}/man8/monitorix.8%{?ext_man}

%changelog
openSUSE Build Service is sponsored by