File pandorafms_console.spec of Package pandorafms_console

#
# spec file for package pandora_console
#
# Copyright (c) 2017 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/
#

# User and Group under which Apache is running
%define httpd_user  wwwrun
%define httpd_group www
%define httpd_root  /srv/www

Name:           pandorafms_console
Version:        6.0SP5
Release:        0
Summary:        Pandora FMS Console
License:        GPL-2.0
Group:          System/Monitoring
Url:            http://www.pandorafms.org
Source0:        %{name}-%{version}.tar.gz
Source1:        %{name}.conf
Source2:        %{name}.logrotate
Source100:      %{name}-rpmlintrc
# PATCH-FIX-OPENSUSE -- disable integrated Update Manager
Patch1:         pandorafms_console-dis_update_manager.patch
# PATCH-FIX-OPENSUSE -- disable some writable checks
Patch2:         pandorafms_console-dis_install_checks.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  fdupes
BuildArch:      noarch
Requires:       apache2
Requires:       apache2-mod_php5
Requires:       graphviz
Requires:       graphviz-gd
Requires:       php >= 5.2
Requires:       php5-calendar
Requires:       php5-curl
Requires:       php5-gd
Requires:       php5-gettext
Requires:       php5-json
Requires:       php5-ldap
Requires:       php5-mbstring
Requires:       php5-mysql
Requires:       php5-snmp
Requires:       php5-zip
Requires:       php5-zlib
Requires:       xorg-x11-fonts-core

Recommends:     logrotate

# 2017-03: we got an old package with this name
Provides:       PandoraFMS_Console = %{version}
Obsoletes:      PandoraFMS_Console < %{version}

%description
Pandora FMS Console is a web application to manage Pandora FMS. Console allows to see graphical reports, state of every agent, also to access to the information sent by the agent, to see every monitored parameter and to see its evolution throughout the time, to form the different nodes, groups and users of the system. It is the part that interacts with the final user, and that will allows you to administer the system.

%prep
%setup -q -n pandora_console
%patch1 -p1
%patch2 -p1

# remove unnecessary files
rm -r \
  attachment/downloads/.gitignore \
  extras/check_other_languages.sh \
  include/languages/util-* \
  include/languages/*.sh \
  include/languages/*.po

# rpmlint: wrong-file-end-of-line-encoding
find include -type f -exec perl -p -i -e "s|\r\n|\n|" {} +

%build

%install
install -d \
  %{buildroot}%{_sysconfdir}/apache2/conf.d \
  %{buildroot}%{_sysconfdir}/logrotate.d \
  %{buildroot}%{_localstatedir}/log/pandorafms \
  %{buildroot}%{httpd_root}/pandora_console
# TODO config.php
#  %%{buildroot}%%{_sysconfdir}/pandorafms \

# install Pandora FMS Console
cp -r attachment/ extensions/ fonts/ \
  general/ godmode/ images/ include/ mobile/ \
  operation/ COPYING *.php *.sql \
  %{buildroot}%{httpd_root}/pandora_console

# create empty config
# TODO config.php
#touch %%{buildroot}%%{_sysconfdir}/pandorafms/console.config.php
#ln -sf %%{_sysconfdir}/pandorafms/console.config.php %%{buildroot}%%{httpd_root}/pandora_console/include/config.php
touch %{buildroot}%{httpd_root}/pandora_console/config.php

# create empty log
touch %{buildroot}%{_localstatedir}/log/pandorafms/pandora_console.log
ln -sf %{_localstatedir}/log/pandorafms/pandora_console.log %{buildroot}%{httpd_root}/pandora_console/pandora_console.log

# install apache2 config
cp %{SOURCE1} %{buildroot}%{_sysconfdir}/apache2/conf.d/%{name}.conf

# install logrotate config
cp %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}

# fdupes
%fdupes %{buildroot}%{httpd_root}/pandora_console

%post
# Has an install already been done, if so we only want to update the files
# push install.php aside so that the console works immediately using existing
# configuration.
if [ -s %{httpd_root}/pandora_console/include/config.php ] ; then
  mv %{httpd_root}/pandora_console/install.php %{httpd_root}/pandora_console/install.done
else
  echo "Please, now, point your browser to http://your_IP_address/pandora_console/install.php and follow all the steps described on it."
fi

%files
%defattr(0644,root,root,0755)
%doc AUTHORS COPYING extras/
%dir %{_sysconfdir}/apache2
%dir %{_sysconfdir}/apache2/conf.d
# TODO config.php
#%%dir %%{_sysconfdir}/pandorafms
%dir %{_localstatedir}/log/pandorafms
%config(noreplace) %{_sysconfdir}/apache2/conf.d/%{name}.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%{httpd_root}/pandora_console/*

%defattr(0644,wwwrun,www,0755)
# installer will check for writable include/ and after installation rename install.php to install_old.php
# TODO include: remove check, when packaged this shouldn't need to be writable
%dir %{httpd_root}/pandora_console
%dir %{httpd_root}/pandora_console/attachment
%{httpd_root}/pandora_console/install.php

%defattr(0640,wwwrun,www,-)
# TODO config.php
#%%config(noreplace) %%{_sysconfdir}/pandorafms/console.config.php
%config(noreplace) %{httpd_root}/pandora_console/config.php
%{_localstatedir}/log/pandorafms/pandora_console.log

%changelog