]> Pileus Git - ~andy/sunrise/blob - net-analyzer/icinga/icinga-1.2.1.ebuild
net-analyzer/icinga: fixed small fixups
[~andy/sunrise] / net-analyzer / icinga / icinga-1.2.1.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 -1 /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                                 elog "Also edit /etc/lighttpd/lighttpd.conf and add 'include \"lighttpd_icinga.conf\"'"
60                         fi
61                         elog
62                         elog "That will make icinga's web front end visable via"
63                         elog "http://localhost/icinga/"
64                         elog
65                 else
66                         elog "IMPORTANT: Do not forget to add the user your webserver"
67                         elog "is running as to the icinga group!"
68                 fi
69
70         else
71                 ewarn "Please note that you have installed Icinga without web interface."
72                 ewarn "Please don't file any bugs about having no web interface when you do this."
73                 ewarn "Thank you!"
74         fi
75
76 }
77
78 src_prepare() {
79         if use api ; then
80                 sed -i -e 's/\(USE_ICINGAAPI=\)no/\1yes/g' Makefile.in || die "sed failed in Makefile.in"
81         fi
82 }
83
84 src_configure() {
85         local myconf
86
87         myconf="$(use_enable perl embedded-perl)
88         $(use_with perl perlcache)
89         $(use_enable idoutils)
90         $(use_enable ssl)
91         $(use_enable debug DEBUG0)
92         $(use_enable debug DEBUG1)
93         $(use_enable debug DEBUG2)
94         $(use_enable debug DEBUG3)
95         $(use_enable debug DEBUG4)
96         $(use_enable debug DEBUG5)
97         --disable-statuswrl
98         --with-cgiurl=cgi-bin
99         --bindir=/usr/sbin
100         --sbindir=/usr/$(get_libdir)/icinga/cgi-bin
101         --datarootdir=/usr/share/icinga/htdocs
102         --localstatedir=/var/icinga
103         --sysconfdir=/etc/icinga
104         --libexecdir=/usr/$(get_libdir)/icinga/plugins"
105
106         if use !apache2 && use !lighttpd ; then
107                 myconf+=" --with-command-group=icinga"
108         else
109                 if use apache2 ; then
110                         myconf+=" --with-command-group=apache --with-httpd-conf=/etc/apache2/conf.d"
111                 elif use lighttpd ; then
112                         myconf+=" --with-command-group=lighttpd"
113                 fi
114         fi
115
116         econf ${myconf}
117         if use api ; then
118                 cd module/icinga-api
119                 econf ${myconf}
120         fi
121 }
122
123 src_compile() {
124         tc-export CC
125
126         emake icinga || die "make failed"
127
128         if use web ; then
129                 emake DESTDIR="${D}" cgis || die
130         fi
131
132         if use idoutils ; then
133                 emake DESTDIR="${D}" idoutils || die
134         fi
135 }
136
137 src_install() {
138         dodoc Changelog README UPGRADING || die
139
140         if ! use web ; then
141                 sed -i -e '/cd $(SRC_\(CGI\|HTM\))/d' Makefile || die
142         fi
143         sed -i -e 's/^contactgroups$//g' Makefile || die
144
145         emake DESTDIR="${D}" install{,-config,-commandmode} || die
146
147         if use idoutils ; then
148                  emake DESTDIR="${D}" install-idoutils || die
149         fi
150         if use api ; then
151                  emake DESTDIR="${D}" install-api || die
152         fi
153
154         newinitd "${FILESDIR}"/icinga-init.d icinga || die
155         newconfd "${FILESDIR}"/icinga-conf.d icinga || die
156         if use idoutils ; then
157                 newinitd "${FILESDIR}"/ido2db-init.d ido2db || die
158                 newconfd "${FILESDIR}"/ido2db-conf.d ido2db || die
159                 insinto /usr/share/icinga/contrib/db
160                 doins -r module/idoutils/db/* || die
161         fi
162         # Apache Module
163         if use web ; then
164                 if use apache2 ; then
165                         insinto "${APACHE_MODULES_CONFDIR}"
166                         newins "${FILESDIR}"/icinga-apache.conf 99_icinga.conf || die
167                 elif use lighttpd ; then
168                         insinto /etc/lighttpd
169                         newins "${FILESDIR}"/icinga-lighty.conf lighttpd_icinga.conf || die
170                 else
171                         ewarn "${CATEGORY}/${PF} only supports Apache-2.x or Lighttpd webserver"
172                         ewarn "out-of-the-box. Since you are not using one of them, you"
173                         ewarn "have to configure your webserver accordingly yourself."
174                 fi
175
176         fi
177
178         fowners -R icinga:icinga /etc/icinga /var/icinga || die "Failed chown of /etc/icinga"
179
180         fowners -R root:root /usr/$(get_libdir)/icinga
181         cd "${D}" || die
182         find usr/$(get_libdir)/icinga -type d -exec fperms 755 {} +
183         find usr/$(get_libdir)/icinga/cgi-bin -type f -exec fperms 755 {} +
184
185         keepdir /etc/icinga
186         keepdir /var/icinga
187         keepdir /var/icinga/archives
188         keepdir /var/icinga/rw
189         keepdir /var/icinga/spool/checkresults
190
191         if use apache2 ; then
192                 webserver=apache
193         elif use lighttpd ; then
194                 webserver=lighttpd
195         else
196                 webserver=icinga
197         fi
198         fowners -R icinga:${webserver} /var/icinga/rw || die "Failed chown of /var/icinga/rw"
199
200         fperms 6755 /var/icinga/rw || die "Failed Chmod of ${D}/var/icinga/rw"
201         fperms 0750 /etc/icinga || die "Failed chmod of ${D}/etc/icinga"
202 }
203
204 pkg_postinst() {
205         elog "If you want icinga to start at boot time"
206         elog "remember to execute:"
207         elog "  rc-update add icinga default"
208         elog
209         elog "If your kernel has /proc protection, icinga"
210         elog "will not be happy as it relies on accessing the proc"
211         elog "filesystem. You can fix this by adding icinga into"
212         elog "the group wheel, but this is not recomended."
213 }