dev-python/pytest: arm64 stable (bug #723996)
[gentoo.git] / net-analyzer / pnp4nagios / pnp4nagios-0.6.26-r9.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 DESCRIPTION="A performance data analyzer for nagios"
7 HOMEPAGE="http://www.pnp4nagios.org/"
8 SRC_URI="mirror://sourceforge/${PN}/PNP-0.6/${P}.tar.gz"
9
10 LICENSE="GPL-2"
11 SLOT="0"
12 IUSE="apache2 icinga +nagios"
13 KEYWORDS="amd64 ppc ppc64 ~sparc x86"
14
15 REQUIRED_USE="^^ ( icinga nagios )"
16
17 # Some things (sync mode, for one) are broken with nagios-4.x, but since
18 # nagios-3.x has been end-of-life'd, we don't have much choice here but
19 # to accept it.
20 DEPEND="
21         dev-lang/php:*[filter,gd,json,simplexml,xml,zlib]
22         net-analyzer/rrdtool[graph,perl]
23         icinga? ( net-analyzer/icinga2 )
24         nagios? ( net-analyzer/nagios-core )"
25
26 # A list of modules used in our Apache config file.
27 APACHE_MODS="apache2_modules_alias,"       # "Alias" directive
28 APACHE_MODS+="apache2_modules_authz_core," # "Require" directive
29 APACHE_MODS+="apache2_modules_rewrite"     # "RewriteEngine" and friends
30
31 RDEPEND="${DEPEND}
32         virtual/perl-Getopt-Long
33         virtual/perl-Time-HiRes
34         media-fonts/dejavu
35         apache2? ( >=www-servers/apache-2.4[${APACHE_MODS}] )"
36
37 PATCHES=( "${FILESDIR}/${PN}-0.6.14-makefile.patch" )
38
39 src_configure() {
40         local user_group=nagios
41         use icinga && user_group=icinga
42
43         econf \
44                 --sysconfdir="${EPREFIX}"/etc/pnp \
45                 --datarootdir="${EPREFIX}"/usr/share/pnp \
46                 --localstatedir="${EPREFIX}"/var/lib/pnp \
47                 --with-nagios-user="${user_group}" \
48                 --with-nagios-group="${user_group}" \
49                 --with-perfdata-logfile="${EPREFIX}"/var/log/pnp/process_perfdata.log
50 }
51
52 src_compile() {
53         # The default target just shows a help
54         emake all
55 }
56
57 src_install() {
58         # Don't use INSTALL_OPTS because they set insecure permissions on
59         # all of /etc/pnp (https://github.com/lingej/pnp4nagios/issues/140).
60         emake INSTALL_OPTS="" DESTDIR="${D}" install install-config
61         einstalldocs
62         newinitd "${FILESDIR}"/npcd.initd npcd
63         rm "${ED%/}/usr/share/pnp/install.php" || \
64                 die "unable to remove ${ED%/}/usr/share/pnp/install.php"
65
66         # Fix CVE-2012-3457 (Gentoo bug 430358)
67         fperms o-rwx /etc/pnp/process_perfdata.cfg
68
69         if use apache2 ; then
70                 insinto /etc/apache2/modules.d
71                 newins "${FILESDIR}"/98_pnp4nagios-2.4.conf 98_pnp4nagios.conf
72         fi
73
74         # The nagios or icinga user needs to write performance data to the
75         # perfdata-dir...
76         local user_group=nagios
77         use icinga && user_group=icinga
78         fowners ":${user_group}" /var/lib/pnp/{,perfdata,spool}
79         fperms g+rwx /var/lib/pnp/{,perfdata,spool}
80
81         # and likewise for its logs...
82         dodir /var/log/pnp
83         fowners ":${user_group}" /var/log/pnp
84         fperms g+rwx /var/log/pnp
85
86         # and its statistics. This one is arguably the responsibility of the
87         # build system, since process_perfdata.cfg refers to this location.
88         dodir /var/lib/pnp/stats
89         fowners ":${user_group}" /var/lib/pnp/stats
90         fperms g+rwx /var/lib/pnp/stats
91 }
92
93 pkg_postinst() {
94         elog "To enable the pnp4nagios web front-end, please visit"
95         elog "${EROOT%/}/etc/conf.d/apache2 and add \"-D PNP -D PHP\""
96         elog "to APACHE2_OPTS. Then pnp4nagios will be available at,"
97         elog
98         elog "  http://localhost/pnp4nagios"
99         elog
100 }