Line 0
Link Here
|
|
|
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 |
MY_P=${PN/-core}-${PV} |
10 |
DESCRIPTION="A monitoring system based on Nagios" |
11 |
HOMEPAGE="http://www.icinga.org/" |
12 |
#SRC_URI="mirror://sourceforge/${PN/-core}/${MY_P}.tar.gz" |
13 |
SRC_URI="http://ovh.dl.sourceforge.net/project/icinga/icinga/${PV}/icinga-${PV}.tar.gz" |
14 |
|
15 |
LICENSE="GPL-2" |
16 |
SLOT="0" |
17 |
KEYWORDS="amd64 x86" |
18 |
# USE oracle gets added when ocilib made it in the repository |
19 |
IUSE="lighttpd perl cgi mysql apache2 vim-syntax ssl postgres" |
20 |
DEPEND="virtual/mailx |
21 |
cgi? ( >=media-libs/gd-1.8.3-r5[jpeg,png] |
22 |
lighttpd? ( www-servers/lighttpd ) |
23 |
apache2? ( www-servers/apache ) |
24 |
) |
25 |
perl? ( >=dev-lang/perl-5.6.1-r7 ) |
26 |
postgres? ( |
27 |
dev-db/postgresql-base |
28 |
dev-db/libdbi-drivers[postgres] |
29 |
) |
30 |
mysql? ( |
31 |
dev-db/mysql |
32 |
dev-db/libdbi-drivers[mysql] |
33 |
) |
34 |
ssl? ( dev-libs/openssl ) |
35 |
vim-syntax? ( app-vim/nagios-syntax ) |
36 |
" |
37 |
# oracle? ( |
38 |
# >=dev-db/ocilib-3.7.0 |
39 |
# ) |
40 |
|
41 |
RDEPEND="${DEPEND}" |
42 |
|
43 |
want_apache2 |
44 |
|
45 |
S="${WORKDIR}/${MY_P}" |
46 |
|
47 |
SELF_BINDIR=/usr/bin |
48 |
SELF_SBINDIR=/usr/$(get_libdir)/icinga/cgi-bin |
49 |
SELF_DATAROOTDIR=/usr/share/icinga/htdocs |
50 |
SELF_LOCALSTATEDIR=/var/icinga |
51 |
SELF_SYSCONFDIR=/etc/icinga |
52 |
SELF_LIBEXECDIR=/usr/$(get_libdir)/icinga/plugins |
53 |
|
54 |
pkg_setup() { |
55 |
depend.apache_pkg_setup |
56 |
|
57 |
enewgroup icinga |
58 |
enewuser icinga -1 /bin/bash /var/icinga/home icinga |
59 |
} |
60 |
|
61 |
src_prepare() { |
62 |
local strip="$(echo '$(MAKE) strip-post-install')" |
63 |
sed -i -e "s:${strip}::" {cgi,base}/Makefile.in || die "sed failed in Makefile.in" |
64 |
} |
65 |
|
66 |
src_configure() { |
67 |
local myconf |
68 |
|
69 |
if use perl ; then |
70 |
myconf="${myconf} --enable-embedded-perl --with-perlcache" |
71 |
fi |
72 |
|
73 |
if use !apache2 && use !lighttpd ; then |
74 |
myconf="${myconf} --with-command-group=icinga" |
75 |
else |
76 |
if use apache2 ; then |
77 |
myconf="${myconf} --with-command-group=apache" |
78 |
myconf="${myconf} --with-httpd-conf=/etc/apache2/modules.d" |
79 |
elif use lighttpd ; then |
80 |
myconf="${myconf} --with-command-group=lighttpd" |
81 |
fi |
82 |
fi |
83 |
|
84 |
if use ssl; then |
85 |
myconf="${myconf} --enable-ssl" |
86 |
fi |
87 |
|
88 |
if use oracle; then |
89 |
myconf="${myconf} --enable-oracle" |
90 |
fi |
91 |
|
92 |
if use postgres; then |
93 |
myconf="${myconf} --enable-pgsql" |
94 |
fi |
95 |
|
96 |
if use mysql || use postgres || use oracle; then |
97 |
myconf="${myconf} --enable-idoutils" |
98 |
fi |
99 |
|
100 |
econf ${myconf} \ |
101 |
--prefix=/usr \ |
102 |
--bindir=$SELF_BINDIR \ |
103 |
--sbindir=$SELF_SBINDIR \ |
104 |
--datarootdir=$SELF_DATAROOTDIR \ |
105 |
--localstatedir=$SELF_LOCALSTATEDIR \ |
106 |
--sysconfdir=$SELF_SYSCONFDIR \ |
107 |
--libexecdir=$SELF_LIBEXECDIR \ |
108 |
--enable-event-broker \ |
109 |
|| die "./configure failed" |
110 |
} |
111 |
|
112 |
src_compile() { |
113 |
emake CC=$(tc-getCC) icinga || die "make failed" |
114 |
|
115 |
if use mysql || use postgres || use oracle; then |
116 |
# Only compile the idoutils if one database is set. |
117 |
emake CC=$(tc-getCC) DESTDIR="${D}" idoutils || die "make failed" |
118 |
fi |
119 |
if use cgi; then |
120 |
# Only compile the idoutils if one database is set. |
121 |
emake CC=$(tc-getCC) DESTDIR="${D}" cgis html || die "make failed" |
122 |
fi |
123 |
|
124 |
} |
125 |
|
126 |
src_install() { |
127 |
local DBMODEL |
128 |
|
129 |
dodoc Changelog INSTALLING LEGAL README UPGRADING |
130 |
|
131 |
emake DESTDIR="${D}" install |
132 |
emake DESTDIR="${D}" install-config |
133 |
emake DESTDIR="${D}" install-commandmode |
134 |
|
135 |
TEMP_INSTALL_FILES=${T}/gentoo_install_files |
136 |
mkdir $TEMP_INSTALL_FILES |
137 |
cp ${FILESDIR}/* $TEMP_INSTALL_FILES/ |
138 |
|
139 |
# substitude dirs |
140 |
sed -i -e "s:<BINDIR>:${SELF_BINDIR}:g" \ |
141 |
-e "s:<SBINDIR>:$SELF_SBINDIR:g" \ |
142 |
-e "s:<DATAROOTDIR>:$SELF_DATAROOTDIR:g" \ |
143 |
-e "s:<LOCALSTATEDIR>:$SELF_LOCALSTATEDIR:g" \ |
144 |
-e "s:<SYSCONFDIR>:$SELF_SYSCONFDIR:g" \ |
145 |
${TEMP_INSTALL_FILES}/* |
146 |
|
147 |
newinitd "${TEMP_INSTALL_FILES}"/icinga icinga |
148 |
newconfd "${TEMP_INSTALL_FILES}"/conf.d icinga |
149 |
|
150 |
if use mysql || use postgres || use oracle; then |
151 |
emake DESTDIR="${D}" install-idoutils |
152 |
newinitd "${TEMP_INSTALL_FILES}"/ido2db ido2db |
153 |
fi |
154 |
|
155 |
# Apache Module |
156 |
if use cgi ; then |
157 |
emake DESTDIR="${D}" install-cgis |
158 |
touch ${D}/etc/icinga/htpasswd.users |
159 |
if use apache2 ; then |
160 |
sed -i -e 's|$(HTTPD_CONF)/\(icinga.conf\)$|$(HTTPD_CONF)/99_\1|' Makefile |
161 |
emake DESTDIR="${D}" install-webconf |
162 |
elif use lighttpd ; then |
163 |
insinto /etc/lighttpd |
164 |
newins "${FILESDIR}/lighttpd_icinga-r1.conf" icinga.conf |
165 |
else |
166 |
ewarn "${CATEGORY}/${PF} only supports Apache-2.x or Lighttpd webserver" |
167 |
ewarn "out-of-the-box. Since you are not using one of them, you" |
168 |
ewarn "have to configure your webserver accordingly yourself." |
169 |
fi |
170 |
|
171 |
fi |
172 |
|
173 |
for dir in etc/icinga var/icinga ; do |
174 |
chown -R icinga:icinga "${D}/${dir}" || die "Failed chown of ${D}/${dir}" |
175 |
done |
176 |
|
177 |
chown -R root:root "${D}"/usr/$(get_libdir)/icinga |
178 |
find "${D}"/usr/$(get_libdir)/icinga -type d -print0 | xargs -0 chmod 755 |
179 |
find "${D}"/usr/$(get_libdir)/icinga/cgi-bin -type f -print0 | xargs -0 chmod 755 |
180 |
|
181 |
keepdir /etc/icinga |
182 |
keepdir /var/icinga |
183 |
keepdir /var/icinga/archives |
184 |
keepdir /var/icinga/rw |
185 |
keepdir /var/icinga/spool/checkresults |
186 |
|
187 |
if use !apache2 && use !lighttpd; then |
188 |
chown -R icinga:icinga "${D}"/var/icinga/rw || die "Failed chown of ${D}/var/icinga/rw" |
189 |
else |
190 |
if use apache2 ; then |
191 |
chown -R icinga:apache "${D}"/var/icinga/rw || die "Failed chown of ${D}/var/icinga/rw" |
192 |
elif use lighttpd ; then |
193 |
chown -R icinga:lighttpd "${D}"/var/icinga/rw || die "Failed chown of ${D}/var/icinga/rw" |
194 |
fi |
195 |
fi |
196 |
|
197 |
chmod ug+s "${D}"/var/icinga/rw || die "Failed chmod of ${D}/var/icinga/rw" |
198 |
chmod 0755 "${D}"/etc/icinga || die "Failed chmod of ${D}/etc/icinga" |
199 |
} |
200 |
|
201 |
pkg_postinst() { |
202 |
einfo "Fixing permissions" |
203 |
chown icinga:icinga "${ROOT}"var/icinga |
204 |
|
205 |
|
206 |
elog "If you want icinga to start at boot time" |
207 |
elog "remember to execute:" |
208 |
elog " rc-update add icinga default" |
209 |
elog |
210 |
|
211 |
if use mysql || use postgres || use oracle; then |
212 |
elog "remember to execute:" |
213 |
elog " rc-update add ido2db default" |
214 |
elog "to activate idoutils" |
215 |
elog |
216 |
fi |
217 |
|
218 |
if use cgi ; then |
219 |
elog "This does not include cgis that are perl-dependent" |
220 |
elog "Note that the user your webserver is running at needs" |
221 |
elog "read-access to /etc/icinga." |
222 |
elog |
223 |
|
224 |
if use apache2 || use lighttpd ; then |
225 |
elog "There are several possible solutions to accomplish this," |
226 |
elog "choose the one you are most comfortable with:" |
227 |
elog |
228 |
if use apache2 ; then |
229 |
elog " usermod -G icinga apache" |
230 |
elog "or" |
231 |
elog " chown icinga:apache /etc/icinga" |
232 |
elif use lighttpd ; then |
233 |
elog " usermod -G icinga lighttpd " |
234 |
elog "or" |
235 |
elog " chown icinga:lighttpd /etc/icinga" |
236 |
fi |
237 |
elog |
238 |
elog "That will make icinga's web front end visable via" |
239 |
elog "http://localhost/icinga/" |
240 |
elog |
241 |
else |
242 |
elog "IMPORTANT: Do not forget to add the user your webserver" |
243 |
elog "is running as to the icinga group!" |
244 |
fi |
245 |
|
246 |
else |
247 |
elog "Please note that you have installed Icinga without web interface." |
248 |
elog "Please don't file any bugs about having no web interface when you do this." |
249 |
elog "Thank you!" |
250 |
fi |
251 |
|
252 |
elog |
253 |
elog "If your kernel has /proc protection, icinga" |
254 |
elog "will not be happy as it relies on accessing the proc" |
255 |
elog "filesystem. You can fix this by adding icinga into" |
256 |
elog "the group wheel, but this is not recomended." |
257 |
elog |
258 |
} |