sys-apps/cpuid: bump to version 20200203
[gentoo.git] / net-analyzer / icinga / icinga-1.14.2.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit depend.apache eutils multilib pax-utils toolchain-funcs user versionator
7
8 DESCRIPTION="Nagios Fork - Check daemon, CGIs, docs, IDOutils"
9 HOMEPAGE="http://www.icinga.org/"
10 SRC_URI="https://github.com/${PN}/${PN}-core/archive/v${PV}/${P}.tar.gz"
11 S="${WORKDIR}/${PN}-core-${PV}"
12
13 LICENSE="GPL-2"
14 SLOT="0"
15 KEYWORDS="amd64 ~arm ~hppa ppc ppc64 x86"
16 IUSE="+apache2 contrib eventhandler +idoutils lighttpd +mysql perl +plugins postgres ssl +vim-syntax +web"
17 DEPEND="idoutils? ( dev-db/libdbi-drivers[mysql?,postgres?] )
18         perl? ( dev-lang/perl:= )
19         virtual/mailx
20         web? (
21                 media-libs/gd[jpeg,png]
22                 lighttpd? ( www-servers/lighttpd )
23         )
24         !net-analyzer/nagios-core"
25 RDEPEND="${DEPEND}
26         plugins? ( || (
27                 net-analyzer/monitoring-plugins
28                 net-analyzer/nagios-plugins
29         ) )"
30 RESTRICT="test"
31
32 want_apache2
33
34 pkg_setup() {
35         depend.apache_pkg_setup
36         enewgroup icinga
37         enewgroup nagios
38         enewuser icinga -1 -1 /var/lib/icinga "icinga,nagios"
39 }
40
41 src_configure() {
42         local myconf
43
44         myconf="$(use_enable perl embedded-perl)
45         $(use_with perl perlcache)
46         $(use_enable idoutils)
47         $(use_enable ssl)
48         --with-cgiurl=/icinga/cgi-bin
49         --with-log-dir=/var/log/icinga
50         --libdir=/usr/$(get_libdir)
51         --bindir=/usr/sbin
52         --sbindir=/usr/$(get_libdir)/icinga/cgi-bin
53         --datarootdir=/usr/share/icinga/htdocs
54         --localstatedir=/var/lib/icinga
55         --sysconfdir=/etc/icinga
56         --with-lockfile=/var/run/icinga/icinga.lock
57         --with-temp-dir=/tmp/icinga
58         --with-temp-file=/tmp/icinga/icinga.tmp"
59
60         if use idoutils ; then
61                 myconf+=" --with-ido2db-lockfile=/var/run/icinga/ido2db.lock
62                 --with-icinga-chkfile=/var/lib/icinga/icinga.chk
63                 --with-ido-sockfile=/var/lib/icinga/ido.sock
64                 --with-idomod-tmpfile=/tmp/icinga/idomod.tmp"
65         fi
66
67         if use eventhandler ; then
68                 myconfig+=" --with-eventhandler-dir=/etc/icinga/eventhandlers"
69         fi
70
71         if use plugins ; then
72                 myconf+=" --with-plugin-dir=/usr/$(get_libdir)/nagios/plugins"
73         else
74                 myconf+=" --with-plugin-dir=/usr/$(get_libdir)/nagios/plugins"
75         fi
76
77         if use !apache2 && use !lighttpd ; then
78                 myconf+=" --with-command-group=icinga"
79         else
80                 if use apache2 ; then
81                         myconf+=" --with-httpd-conf=/etc/apache2/conf.d"
82                         myconf+=" --with-command-group=apache"
83                 elif use lighttpd ; then
84                         myconf+=" --with-command-group=lighttpd"
85                 fi
86         fi
87
88         econf ${myconf}
89 }
90
91 src_compile() {
92         tc-export CC
93
94         emake icinga
95
96         if use web ; then
97                 emake DESTDIR="${D}" cgis
98         fi
99
100         if use contrib ; then
101                 emake DESTDIR="${D}" -C contrib
102         fi
103
104         if use idoutils ; then
105                 emake DESTDIR="${D}" idoutils
106         fi
107 }
108
109 src_install() {
110         dodoc Changelog README UPGRADING
111
112         if ! use web ; then
113                 sed -i -e '/cd $(SRC_\(CGI\|HTM\))/d' Makefile
114         fi
115
116         emake DESTDIR="${D}" install{,-config,-commandmode}
117
118         if use idoutils ; then
119                  emake DESTDIR="${D}" install-idoutils
120         fi
121
122         if use contrib ; then
123                 emake DESTDIR="${D}" -C contrib install
124         fi
125
126         if use eventhandler ; then
127                 emake DESTDIR="${D}" install-eventhandlers
128         fi
129
130         newinitd "${FILESDIR}"/icinga-init.d icinga
131         newconfd "${FILESDIR}"/icinga-conf.d icinga
132         if use idoutils ; then
133                 newinitd "${FILESDIR}"/ido2db-init.d ido2db
134                 newconfd "${FILESDIR}"/ido2db-conf.d ido2db
135                 insinto /usr/share/icinga/contrib/db
136                 doins -r module/idoutils/db/*
137         fi
138         # Apache Module
139         if use web ; then
140                 if use apache2 ; then
141                         insinto "${APACHE_MODULES_CONFDIR}"
142                         newins "${FILESDIR}"/icinga-apache.conf 99_icinga.conf
143                 elif use lighttpd ; then
144                         insinto /etc/lighttpd
145                         newins "${FILESDIR}"/icinga-lighty.conf lighttpd_icinga.conf
146                 else
147                         ewarn "${CATEGORY}/${PF} only supports Apache-2.x or Lighttpd webserver"
148                         ewarn "out-of-the-box. Since you are not using one of them, you"
149                         ewarn "have to configure your webserver accordingly yourself."
150                 fi
151                 fowners -R root:root /usr/$(get_libdir)/icinga
152                 cd "${D}"
153                 find usr/$(get_libdir)/icinga -type d -exec fperms 755 {} +
154                 find usr/$(get_libdir)/icinga/cgi-bin -type f -exec fperms 755 {} +
155         fi
156
157         if use eventhandler ; then
158                 dodir /etc/icinga/eventhandlers
159 #               fowners icinga:icinga /etc/icinga/eventhandlers
160         fi
161
162         keepdir /etc/icinga
163         keepdir /var/lib/icinga
164         keepdir /var/lib/icinga/archives
165         keepdir /var/lib/icinga/rw
166         keepdir /var/lib/icinga/spool/checkresults
167
168         if use apache2 ; then
169                 webserver=apache
170         elif use lighttpd ; then
171                 webserver=lighttpd
172         else
173                 webserver=icinga
174         fi
175
176         fowners icinga:icinga /var/lib/icinga
177         fowners -R icinga:${webserver} /var/lib/icinga/rw
178
179         fperms 6755 /var/lib/icinga/rw
180
181         # ensure ownership
182         fowners -R root:root /etc/icinga
183         fperms 0750 /etc/icinga
184         fowners -R root:root /usr/sbin
185         fowners -R root:root /usr/$(get_libdir)
186         fowners -R root:root /usr/share/icinga/htdocs
187
188         # paxmarks
189         if use idoutils ; then
190                 pax-mark m usr/sbin/ido2db
191         fi
192 }
193
194 pkg_postinst() {
195         if use web ; then
196                 elog "This does not include cgis that are perl-dependent"
197                 elog "Currently traceroute.cgi is perl-dependent"
198                 elog "Note that the user your webserver is running as needs"
199                 elog "read-access to /etc/icinga."
200                 elog
201                 if use apache2 || use lighttpd ; then
202                         elog "There are several possible solutions to accomplish this,"
203                         elog "choose the one you are most comfortable with:"
204                         elog
205                         if use apache2 ; then
206                                 elog "  usermod -G icinga apache"
207                                 elog "or"
208                                 elog "  chown icinga:apache /etc/icinga"
209                                 elog
210                                 elog "Also edit /etc/conf.d/apache2 and add a line like"
211                                 elog "APACHE2_OPTS=\"\$APACHE2_OPTS -D ICINGA\""
212                                 elog
213                                 elog "Icinga web service needs user authentication. If you"
214                                 elog "use the base configuration, you need a password file"
215                                 elog "with a password for user \"icingaadmin\""
216                                 elog "You can create this file by executing:"
217                                 elog "htpasswd -c /etc/icinga/htpasswd.users icingaadmin"
218                                 elog
219                                 elog "you may want to also add apache to the icinga group"
220                                 elog "to allow it access to the AuthUserFile"
221                                 elog
222                         elif use lighttpd ; then
223                                 elog "  usermod -G icinga lighttpd "
224                                 elog "or"
225                                 elog "  chown icinga:lighttpd /etc/icinga"
226                                 elog "Also edit /etc/lighttpd/lighttpd.conf and add 'include \"lighttpd_icinga.conf\"'"
227                         fi
228                         elog
229                         elog "That will make icinga's web front end visable via"
230                         elog "http://localhost/icinga/"
231                         elog
232                 else
233                         elog "IMPORTANT: Do not forget to add the user your webserver"
234                         elog "is running as to the icinga group!"
235                 fi
236         else
237                 ewarn "Please note that you have installed Icinga without web interface."
238                 ewarn "Please don't file any bugs about having no web interface when you do this."
239                 ewarn "Thank you!"
240         fi
241         elog
242         elog "If you want icinga to start at boot time"
243         elog "remember to execute:"
244         elog "  rc-update add icinga default"
245         elog
246         elog "If your kernel has /proc protection, icinga"
247         elog "will not be happy as it relies on accessing the proc"
248         elog "filesystem. You can fix this by adding icinga into"
249         elog "the group wheel, but this is not recomended."
250         elog
251         if [ -d "${ROOT}"/var/icinga ] ; then
252                 ewarn
253                 ewarn "/var/icinga was moved to /var/lib/icinga"
254                 ewarn "please move the files if this was an upgrade"
255                 if use idoutils ; then
256                         ewarn "and edit /etc/ido2db.cfg to change the location of the files"
257                         ewarn "it accesses"
258                         ewarn "update your db with the scripts under the directory"
259                         ewarn "/usr/share/icinga/contrib/db/"
260                 fi
261                 ewarn
262                 ewarn "The \"mv /var/icinga /var/lib/\" command works well to move the files"
263                 ewarn "remove /var/icinga afterwards to make this warning disappear"
264         fi
265 }