]> Pileus Git - ~andy/sunrise/blob - net-analyzer/icinga-core/icinga-core-1.0.2.ebuild
app-text/odt2txt: Remove hardened_makefile.patch
[~andy/sunrise] / net-analyzer / icinga-core / icinga-core-1.0.2.ebuild
1 # Copyright 1999-2010 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/net-analyzer/icinga-core/icinga-core-3.1.0.ebuild,v 1.3 2009/02/24 17:07:42 dertobi123 Exp $
4
5 EAPI="2"
6
7 inherit eutils depend.apache toolchain-funcs
8
9 SRC_URI="mirror://sourceforge/icinga/icinga-${PV}.tar.gz"
10 DESCRIPTION="Icinga - Check daemon, CGIs, docs, IDOutils"
11 HOMEPAGE="http://www.icinga.org/"
12
13 LICENSE="GPL-2"
14 SLOT="0"
15 KEYWORDS="~amd64 ~x86"
16 IUSE="+apache2 api debug +idoutils lighttpd perl plugins +vim-syntax +web"
17 DEPEND="idoutils? ( dev-db/libdbi-drivers[mysql] )
18         perl? ( >=dev-lang/perl-5.6.1-r7 )
19         virtual/mailx
20         web? (
21                 >=media-libs/gd-1.8.3-r5[jpeg,png]
22                 lighttpd? ( www-servers/lighttpd dev-lang/php[cgi] )
23                 apache2? ( || ( dev-lang/php[apache2] dev-lang/php[cgi] ) )
24         )
25         !net-analyzer/nagios-core"
26 RDEPEND="${DEPEND}
27         plugins? ( net-analyzer/nagios-plugins )
28         vim-syntax? ( app-vim/nagios-syntax )"
29
30 want_apache2
31
32 pkg_setup() {
33         enewgroup icinga
34         enewuser icinga -1 /bin/bash /var/spool/icinga icinga
35 }
36
37 src_prepare() {
38         local strip="$(echo '$(MAKE) strip-post-install')"
39         sed -i -e "s:${strip}::" {cgi,base}/Makefile.in || die "sed failed in
40         Makefile.in"
41         if use api ; then
42                 sed -i -e 's/USE_ICINGAAPI=no/USE_ICINGAAPI=yes/g' Makefile.in
43         fi
44 }
45
46 src_configure() {
47         local myconf
48
49         if use perl ; then
50                 myconf="${myconf} --enable-embedded-perl --with-perlcache"
51         fi
52
53         myconf="${myconf} --disable-statuswrl $(use_enable idoutils)"
54
55         if use debug; then
56                 myconf="${myconf} --enable-DEBUG0"
57                 myconf="${myconf} --enable-DEBUG1"
58                 myconf="${myconf} --enable-DEBUG2"
59                 myconf="${myconf} --enable-DEBUG3"
60                 myconf="${myconf} --enable-DEBUG4"
61                 myconf="${myconf} --enable-DEBUG5"
62         fi
63
64         if use !apache2 && use !lighttpd ; then
65                 myconf="${myconf} --with-command-group=icinga"
66         else
67                 if use apache2 ; then
68                         myconf="${myconf} --with-command-group=apache"
69                         myconf="${myconf} --with-httpd-conf=/etc/apache2/conf.d"
70                 elif use lighttpd ; then
71                         myconf="${myconf} --with-command-group=lighttpd"
72                 fi
73         fi
74
75         econf ${myconf} \
76                 --prefix=/usr \
77                 --bindir=/usr/sbin \
78                 --sbindir=/usr/$(get_libdir)/icinga/cgi-bin \
79                 --datarootdir=/usr/share/icinga/htdocs \
80                 --localstatedir=/var/icinga \
81                 --sysconfdir=/etc/icinga \
82                 --libexecdir=/usr/$(get_libdir)/icinga/plugins \
83                 || die "./configure failed"
84         if use api ; then
85                 sed -i -e 's/USE_ICINGAAPI=no/USE_ICINGAAPI=yes/g' Makefile
86         fi
87         if use api ; then
88                 cd module/icinga-api
89                 econf --prefix=/usr \
90                         --bindir=/usr/sbin \
91                 --sbindir=/usr/$(get_libdir)/icinga/cgi-bin \
92                         --datarootdir=/usr/share/icinga/htdocs \
93                         --localstatedir=/var/icinga \
94                 --sysconfdir=/etc/icinga \
95                         --libexecdir=/usr/$(get_libdir)/icinga/plugins \
96                         || die "./configure failed"
97         fi
98 }
99
100 src_compile() {
101
102         emake CC=$(tc-getCC) icinga || die "make failed"
103
104         if use web ; then
105                 # Only compile the CGI's if "web" useflag is set.
106                 emake CC=$(tc-getCC) DESTDIR="${D}" cgis || die
107         fi
108
109         if use idoutils ; then
110                 # Only compile IDOUtils if "idoutils" useflag is set.
111                 emake CC=$(tc-getCC) DESTDIR="${D}" idoutils || die
112         fi
113 }
114
115 src_install() {
116         dodoc Changelog INSTALLING LEGAL README UPGRADING
117
118         if ! use web ; then
119                 sed -i -e 's/cd $(SRC_CGI) && $(MAKE) $@/# line removed due missing web use flag/' \
120                         -e 's/cd $(SRC_HTM) && $(MAKE) $@/# line removed due missing web use flag/' \
121                         Makefile
122         fi
123         sed -i -e 's/^contactgroups$//g' Makefile
124
125         emake DESTDIR="${D}" install
126         emake DESTDIR="${D}" install-config
127         emake DESTDIR="${D}" install-commandmode
128
129         if use idoutils ; then
130                  emake DESTDIR="${D}" install-idoutils
131         fi
132         if use api ; then
133                  emake DESTDIR="${D}" install-api
134         fi
135
136         newinitd "${FILESDIR}"/icinga-init.d icinga
137         newconfd "${FILESDIR}"/icinga-conf.d icinga
138         if use idoutils ; then
139                 newinitd "${FILESDIR}"/ido2db-init.d ido2db
140                 newconfd "${FILESDIR}"/ido2db-conf.d ido2db
141                 mkdir -p "${D}"/usr/share/icinga/contrib/db
142                 cp -r "${S}"/module/idoutils/db/* "${D}"/usr/share/icinga/contrib/db/
143         fi
144         # Apache Module
145         if use web ; then
146                 if use apache2 ; then
147                         insinto "${APACHE_MODULES_CONFDIR}"
148                         newins "${FILESDIR}"/icinga-apache.conf 99_icinga.conf
149             elif use lighttpd ; then
150                         insinto /etc/lighttpd
151                         newins "${FILESDIR}"/icinga-lighty.conf lighttpd_icinga.conf
152                 else
153                         ewarn "${CATEGORY}/${PF} only supports Apache-2.x or Lighttpd webserver"
154                         ewarn "out-of-the-box. Since you are not using one of them, you"
155                         ewarn "have to configure your webserver accordingly yourself."
156                 fi
157
158         fi
159
160         for dir in etc/icinga var/icinga ; do
161                 chown -R icinga:icinga "${D}/${dir}" || die "Failed chown of ${D}/${dir}"
162         done
163
164         chown -R root:root "${D}"/usr/$(get_libdir)/icinga
165         find "${D}"/usr/$(get_libdir)/icinga -type d -print0 | xargs -0 chmod 755
166         find "${D}"/usr/$(get_libdir)/icinga/cgi-bin -type f -print0 | xargs -0 chmod 755
167
168         keepdir /etc/icinga
169         keepdir /var/icinga
170         keepdir /var/icinga/archives
171         keepdir /var/icinga/rw
172         keepdir /var/icinga/spool/checkresults
173
174         if use !apache2 && use !lighttpd; then
175                 chown -R icinga:icinga "${D}"/var/icinga/rw || die "Failed chown of ${D}/var/icinga/rw"
176         else
177                 if use apache2 ; then
178                         chown -R icinga:apache "${D}"/var/icinga/rw || die "Failed chown of ${D}/var/icinga/rw"
179                 elif use lighttpd ; then
180                         chown -R icinga:lighttpd "${D}"/var/icinga/rw || die "Failed chown of ${D}/var/icinga/rw"
181                 fi
182         fi
183
184         chmod ug+s "${D}"/var/icinga/rw || die "Failed Chmod of ${D}/var/icinga/rw"
185         chmod 0750 "${D}"/etc/icinga || die "Failed chmod of ${D}/etc/icinga"
186 }
187
188 pkg_postinst() {
189         elog "If you want icinga to start at boot time"
190         elog "remember to execute:"
191         elog "  rc-update add icinga default"
192         elog
193
194         if use web ; then
195                 elog "This does not include cgis that are perl-dependent"
196                 elog "Currently traceroute.cgi is perl-dependent"
197                 elog "To have ministatus.cgi requires copying of ministatus.c"
198                 elog "to cgi directory for compiling."
199
200                 elog "Note that the user your webserver is running at needs"
201                 elog "read-access to /etc/icinga."
202                 elog
203
204                 if use apache2 || use lighttpd ; then
205                         elog "There are several possible solutions to accomplish this,"
206                         elog "choose the one you are most comfortable with:"
207                         elog
208                         if use apache2 ; then
209                                 elog "  usermod -G icinga apache"
210                                 elog "or"
211                                 elog "  chown icinga:apache /etc/icinga"
212                                 elog
213                                 elog "Also edit /etc/conf.d/apache2 and add \"-D ICINGA\""
214                         elif use lighttpd ; then
215                                 elog "  usermod -G icinga lighttpd "
216                                 elog "or"
217                                 elog "  chown icinga:lighttpd /etc/icinga"
218                         fi
219                         elog
220                         elog "That will make icinga's web front end visable via"
221                         elog "http://localhost/icinga/"
222                         elog
223                 else
224                         elog "IMPORTANT: Do not forget to add the user your webserver"
225                         elog "is running as to the icinga group!"
226                 fi
227
228         else
229                 elog "Please note that you have installed Icinga without web interface."
230                 elog "Please don't file any bugs about having no web interface when you do this."
231                 elog "Thank you!"
232         fi
233
234         elog
235         elog "If your kernel has /proc protection, icinga"
236         elog "will not be happy as it relies on accessing the proc"
237         elog "filesystem. You can fix this by adding icinga into"
238         elog "the group wheel, but this is not recomended."
239         elog
240         einfo "Fixing permissions"
241         chown icinga:icinga "${ROOT}"var/icinga
242 }