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