File cacti.spec of Package cacti
#
# spec file for package cacti
#
# 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/
#
Name: cacti
Version: 1.1.38
Release: 0
Summary: Web Front-End to Monitor System Data via RRDtool
License: GPL-2.0+
Group: System/Monitoring
Url: http://www.cacti.net/
Source0: http://www.cacti.net/downloads/%{name}-%{version}.tar.gz
Source1: %{name}.cron
Source2: %{name}-httpd.conf
Source3: %{name}.logrotate
Source4: %{name}-httpd.conf.default
# PATCH-FIX-UPSTREAM cacti-config.patch
Patch0: %{name}-config.patch
BuildRequires: apache-rpm-macros
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
%if 0%{?suse_version}
BuildRequires: apache2-devel
%else
BuildRequires: httpd-devel
%endif
Requires: httpd
Requires: logrotate
Requires: net-snmp
Requires: php-gmp
Requires: php-ldap
Requires: php-mbstring
Requires: php-openssl
Requires: php-posix
Requires: php-snmp >= 5.4
Requires: php-zlib
Requires: rrdtool
%if 0%{?suse_version}
Requires: cron
Requires: mod_php_any >= 5.4
Requires: php-sockets >= 5.4
%endif
%if 0%{?fedora_version}
Requires: php-mysqlnd >= 5.4
%else
Requires: php-mysql >= 5.4
%endif
Provides: cacti-system
Obsoletes: cacti-PA
Provides: cacti-PA
Conflicts: cacti-spine < %{version}
Conflicts: cacti-spine > %{version}
%if 0%{?suse_version} <= 1210
%define cacti_dir %{_datadir}/cacti
%else
%define cacti_dir %{apache_datadir}/cacti
%endif
%description
Cacti is a complete front-end to RRDtool: it stores all necessary
information for creating graphs and populates them with data from a
MySQL database. The front-end is completely PHP driven. Along with
being ableto maintain graphs, data sources, and round robin archives
ina database, Cacti also handles data gathering. There exists an SNMP
support for those accustomed to creating traffic graphs with MRTG as
well.
%package doc
Summary: Documentation for Cacti
Group: Documentation/HTML
Requires: %{name} = %{version}
%description doc
Cacti is a complete front-end to RRDtool: it stores all necessary
information for creating graphs and populates them with data from a
MySQL database. The front-end is completely PHP driven. Along with
being ableto maintain graphs, data sources, and round robin archives
ina database, Cacti also handles data gathering. There exists an SNMP
support for those accustomed to creating traffic graphs with MRTG as
well.
This package contains the HTML documentation for Cacti.
%prep
%setup -q
%patch0 -p1
#delete the *.orig files
find . -type f -name "*\.orig" -exec rm {} \;
%build
#nothing to build
%install
install -d -m 0755 %{buildroot}%{cacti_dir}
install -d -m 0755 %{buildroot}%{_localstatedir}/lib/%{name}
install -d -m 0755 %{buildroot}%{_localstatedir}/log/%{name}
cp *.php %{buildroot}%{cacti_dir}
cp -pr cache %{buildroot}%{cacti_dir}
cp -pr cli %{buildroot}%{cacti_dir}
cp -pr formats %{buildroot}%{cacti_dir}
cp -pr images %{buildroot}%{cacti_dir}
cp -pr include %{buildroot}%{cacti_dir}
cp -pr install %{buildroot}%{cacti_dir}
cp -pr lib %{buildroot}%{cacti_dir}
cp -pr locales %{buildroot}%{cacti_dir}
cp -pr mibs %{buildroot}%{cacti_dir}
cp -pr plugins %{buildroot}%{cacti_dir}
cp -pr resource %{buildroot}%{cacti_dir}
cp -pr rra %{buildroot}%{cacti_dir}
cp -pr scripts %{buildroot}%{cacti_dir}
install -d -m 0755 scripts %{buildroot}%{cacti_dir}/scripts
install -m 0755 scripts/* %{buildroot}%{cacti_dir}/scripts
install -d -m 0755 cli %{buildroot}%{cacti_dir}/cli
install -m 0755 cli/* %{buildroot}%{cacti_dir}/cli
install -m 0644 *.sql %{buildroot}%{cacti_dir}
# cron task
install -d -m 0755 %{buildroot}%{_sysconfdir}/cron.d
sed -e "s;__CACTIDIR__;%{cacti_dir};g" -e "s;__APACHEUSER__;%{apache_user};g" \
%{SOURCE1} > %{buildroot}%{_sysconfdir}/cron.d/%{name}
# apache2 config
%if 0%{?suse_version}
%if 0%{?suse_version} > 1210
install -d -m 0755 %{buildroot}%{apache_sysconfdir}/conf.d
sed -e "s;__CACTIDIR__;%{cacti_dir};g" %{SOURCE4} > %{buildroot}%{apache_sysconfdir}/conf.d/%{name}.conf
install -d -m 0755 %{buildroot}%{apache_sysconfdir}/vhosts.d/conf.d
sed -e "s;__CACTIDIR__;%{cacti_dir};g" -e "s;<IfDefine CACTI>;<IfDefine CACTIVHOST>;g" \
%{SOURCE4} > %{buildroot}%{apache_sysconfdir}/vhosts.d/conf.d/%{name}.conf
%endif
%if 0%{?suse_version} <= 1210
install -d -m 0755 %{buildroot}%{apache_sysconfdir}/conf.d
sed -e "s;__CACTIDIR__;%{cacti_dir};g" %{SOURCE2} > %{buildroot}%{apache_sysconfdir}/conf.d/%{name}.conf
%endif
%else
install -d -m 0755 %{buildroot}%{apache_sysconfdir}/../conf.d
sed -e "s;__CACTIDIR__;%{cacti_dir};g" %{SOURCE2} > %{buildroot}%{apache_sysconfdir}/../conf.d/%{name}.conf
%endif
# logrotate config
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d/
sed -e "s;__APACHEUSER__;%{apache_user};g" -e "s;__APACHEGROUP__;%{apache_group};g" \
%{SOURCE3} > %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
# Set the correct permissions for pl and sh files
#find %%{buildroot}%%{cacti_dir} -type f -name "*.sh" -o -name "*.pl" -exec chmod ugo+x {} \;
# compute files list without config file
find %{buildroot}%{cacti_dir} -type d | sed -e 's|'%{buildroot}'|%dir |' >> %{name}.list
find %{buildroot}%{cacti_dir} -type f ! -name config.php | sed -e 's|'%{buildroot}'||' >> %{name}.list
ln -sf %{_localstatedir}/log/%{name} %{buildroot}%{cacti_dir}/log
%post
chown -R %{apache_user}:%{apache_group} %{cacti_dir}/rra
%files -f %{name}.list
%defattr(-,root,root)
%doc LICENSE README.md docs/txt
%attr(-,%{apache_user},%{apache_group}) %dir %{_localstatedir}/lib/%{name}
%attr(-,%{apache_user},%{apache_group}) %dir %{_localstatedir}/log/%{name}
%attr(-,%{apache_user},%{apache_group}) %{cacti_dir}/log
%config(noreplace) %{cacti_dir}/include/config.php
%config(noreplace) %{_sysconfdir}/cron.d/%{name}
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%if 0%{?suse_version}
%if 0%{?suse_version} <= 1210
%dir %{apache_sysconfdir}/conf.d
%config(noreplace) %{apache_sysconfdir}/conf.d/%{name}.conf
%endif
%if 0%{?suse_version} > 1210
%dir %{apache_sysconfdir}/conf.d
%config(noreplace) %{apache_sysconfdir}/conf.d/%{name}.conf
%dir %{apache_sysconfdir}/vhosts.d/conf.d
%config(noreplace) %{apache_sysconfdir}/vhosts.d/conf.d/%{name}.conf
%endif
%else
%dir %{apache_sysconfdir}/../conf.d
%config(noreplace) %{apache_sysconfdir}/../conf.d/%{name}.conf
%endif
%files doc
%defattr(-,root,root)
%doc docs/html
%changelog