]> Pileus Git - ~andy/sunrise/blob - net-analyzer/icinga/icinga-1.2.0-r1.ebuild
net-analyzer/icinga: add --with-cgiurl=cgi-bin to configure, contributed by RedPepper
[~andy/sunrise] / net-analyzer / icinga / icinga-1.2.0-r1.ebuild
1 # Copyright 1999-2010 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 EAPI=2
6
7 inherit eutils depend.apache toolchain-funcs
8
9 DESCRIPTION="Nagios Fork - Check daemon, CGIs, docs, IDOutils"
10 HOMEPAGE="http://www.icinga.org/"
11 SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
12
13 LICENSE="GPL-2"
14 SLOT="0"
15 KEYWORDS="~amd64 ~x86"
16 IUSE="+apache2 api debug +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 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/false /var/spool/icinga icinga
35         if use web ; then
36                 elog "This does not include cgis that are perl-dependent"
37                 elog "Currently traceroute.cgi is perl-dependent"
38                 elog "To have ministatus.cgi requires copying of ministatus.c"
39                 elog "to cgi directory for compiling."
40
41                 elog "Note that the user your webserver is running at needs"
42                 elog "read-access to /etc/icinga."
43                 elog
44
45                 if use apache2 || use lighttpd ; then
46                         elog "There are several possible solutions to accomplish this,"
47                         elog "choose the one you are most comfortable with:"
48                         elog
49                         if use apache2 ; then
50                                 elog "  usermod -G icinga apache"
51                                 elog "or"
52                                 elog "  chown icinga:apache /etc/icinga"
53                                 elog
54                                 elog "Also edit /etc/conf.d/apache2 and add \"-D ICINGA\""
55                         elif use lighttpd ; then
56                                 elog "  usermod -G icinga lighttpd "
57                                 elog "or"
58                                 elog "  chown icinga:lighttpd /etc/icinga"
59                         fi
60                         elog
61                         elog "That will make icinga's web front end visable via"
62                         elog "http://localhost/icinga/"
63                         elog
64                 else
65                         elog "IMPORTANT: Do not forget to add the user your webserver"
66                         elog "is running as to the icinga group!"
67                 fi
68
69         else
70                 ewarn "Please note that you have installed Icinga without web interface."
71                 ewarn "Please don't file any bugs about having no web interface when you do this."
72                 ewarn "Thank you!"
73         fi
74
75 }
76
77 src_prepare() {
78         if use api ; then
79                 sed -i -e 's/\(USE_ICINGAAPI=\)no/\1yes/g' Makefile.in || die "sed failed in Makefile.in"
80         fi
81 }
82
83 src_configure() {
84         local myconf
85
86         myconf="$(use_enable perl embedded-perl)
87         $(use_with perl perlcache)
88         $(use_enable idoutils)
89         $(use_enable ssl)
90         $(use_enable debug DEBUG0)
91         $(use_enable debug DEBUG1)
92         $(use_enable debug DEBUG2)
93         $(use_enable debug DEBUG3)
94         $(use_enable debug DEBUG4)
95         $(use_enable debug DEBUG5)
96         --disable-statuswrl
97         --with-cgiurl=cgi-bin
98         --bindir=/usr/sbin
99         --sbindir=/usr/$(get_libdir)/icinga/cgi-bin
100         --datarootdir=/usr/share/icinga/htdocs
101         --localstatedir=/var/icinga
102         --sysconfdir=/etc/icinga
103         --libexecdir=/usr/$(get_libdir)/icinga/plugins"
104
105         if use !apache2 && use !lighttpd ; then
106                 myconf+=" --with-command-group=icinga"
107         else
108                 if use apache2 ; then
109                         myconf+=" --with-command-group=apache --with-httpd-conf=/etc/apache2/conf.d"
110                 elif use lighttpd ; then
111                         myconf+=" --with-command-group=lighttpd"
112                 fi
113         fi
114
115         econf ${myconf}
116         if use api ; then
117                 cd module/icinga-api
118                 econf ${myconf}
119         fi
120 }
121
122 src_compile() {
123         tc-export CC
124
125         emake icinga || die "make failed"
126
127         if use web ; then
128                 emake DESTDIR="${D}" cgis || die
129         fi
130
131         if use idoutils ; then
132                 emake DESTDIR="${D}" idoutils || die
133         fi
134 }
135
136 src_install() {
137         dodoc Changelog README UPGRADING || die
138
139         if ! use web ; then
140                 sed -i -e '/cd $(SRC_\(CGI\|HTM\))/d' Makefile || die
141         fi
142         sed -i -e 's/^contactgroups$//g' Makefile || die
143
144         emake DESTDIR="${D}" install{,-config,-commandmode} || die
145
146         if use idoutils ; then
147                  emake DESTDIR="${D}" install-idoutils || die
148         fi
149         if use api ; then
150                  emake DESTDIR="${D}" install-api || die
151         fi
152
153         newinitd "${FILESDIR}"/icinga-init.d icinga || die
154         newconfd "${FILESDIR}"/icinga-conf.d icinga || die
155         if use idoutils ; then
156                 newinitd "${FILESDIR}"/ido2db-init.d ido2db || die
157                 newconfd "${FILESDIR}"/ido2db-conf.d ido2db || die
158                 insinto /usr/share/icinga/contrib/db
159                 doins -r module/idoutils/db/* || die
160         fi
161         # Apache Module
162         if use web ; then
163                 if use apache2 ; then
164                         insinto "${APACHE_MODULES_CONFDIR}"
165                         newins "${FILESDIR}"/icinga-apache.conf 99_icinga.conf || die
166                 elif use lighttpd ; then
167                         insinto /etc/lighttpd
168                         newins "${FILESDIR}"/icinga-lighty.conf lighttpd_icinga.conf || die
169                 else
170                         ewarn "${CATEGORY}/${PF} only supports Apache-2.x or Lighttpd webserver"
171                         ewarn "out-of-the-box. Since you are not using one of them, you"
172                         ewarn "have to configure your webserver accordingly yourself."
173                 fi
174
175         fi
176
177         fowners -R icinga:icinga /etc/icinga /var/icinga || die "Failed chown of /etc/icinga"
178
179         fowners -R root:root /usr/$(get_libdir)/icinga
180         find "${D}"/usr/$(get_libdir)/icinga -type d -exec fperms 755 {} +
181         find "${D}"/usr/$(get_libdir)/icinga/cgi-bin -type f -exec fperms 755 {} +
182
183         keepdir /etc/icinga
184         keepdir /var/icinga
185         keepdir /var/icinga/archives
186         keepdir /var/icinga/rw
187         keepdir /var/icinga/spool/checkresults
188
189         use apache2 && webserver=apache2 || use lighttpd && webserver=lighttpd || webserver=icinga
190         fowners -R icinga:${webserver} /var/icinga/rw || die "Failed chown of /var/icinga/rw"
191
192         fperms 6755 /var/icinga/rw || die "Failed Chmod of ${D}/var/icinga/rw"
193         fperms 0750 /etc/icinga || die "Failed chmod of ${D}/etc/icinga"
194 }
195
196 pkg_postinst() {
197         elog "If you want icinga to start at boot time"
198         elog "remember to execute:"
199         elog "  rc-update add icinga default"
200         elog
201         elog "If your kernel has /proc protection, icinga"
202         elog "will not be happy as it relies on accessing the proc"
203         elog "filesystem. You can fix this by adding icinga into"
204         elog "the group wheel, but this is not recomended."
205 }