| 1 |
# Copyright 1999-2012 Gentoo Foundation |
| 2 |
# Distributed under the terms of the GNU General Public License v2 |
| 3 |
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/zabbix/zabbix-2.0.1.ebuild,v 1.1 2012/07/02 05:43:41 mattm Exp $ |
| 4 |
|
| 5 |
EAPI="2" |
| 6 |
|
| 7 |
# needed to make webapp-config dep optional |
| 8 |
WEBAPP_OPTIONAL="yes" |
| 9 |
inherit flag-o-matic webapp depend.php autotools java-pkg-opt-2 user |
| 10 |
|
| 11 |
DESCRIPTION="ZABBIX is software for monitoring of your applications, network and servers." |
| 12 |
HOMEPAGE="http://www.zabbix.com/" |
| 13 |
MY_P=${P/_/} |
| 14 |
SRC_URI="http://prdownloads.sourceforge.net/zabbix/${MY_P}.tar.gz" |
| 15 |
LICENSE="GPL-2" |
| 16 |
SLOT="0" |
| 17 |
WEBAPP_MANUAL_SLOT="yes" |
| 18 |
KEYWORDS="~amd64 ~x86" |
| 19 |
IUSE="agent java curl frontend ipv6 jabber ldap mysql openipmi oracle postgres proxy server ssh snmp sqlite iodbc odbc static" |
| 20 |
|
| 21 |
COMMON_DEPEND="snmp? ( net-analyzer/net-snmp ) |
| 22 |
ldap? ( |
| 23 |
net-nds/openldap |
| 24 |
=dev-libs/cyrus-sasl-2* |
| 25 |
net-libs/gnutls |
| 26 |
) |
| 27 |
mysql? ( >=virtual/mysql-5.0 ) |
| 28 |
sqlite? ( >=dev-db/sqlite-3.3.5 ) |
| 29 |
postgres? ( >=dev-db/postgresql-base-8.3.0 ) |
| 30 |
oracle? ( >=dev-db/oracle-instantclient-basic-10.0.0.0 ) |
| 31 |
jabber? ( dev-libs/iksemel ) |
| 32 |
curl? ( net-misc/curl ) |
| 33 |
openipmi? ( sys-libs/openipmi ) |
| 34 |
ssh? ( net-libs/libssh2 ) |
| 35 |
java? ( >=virtual/jdk-1.4 ) |
| 36 |
odbc? ( |
| 37 |
iodbc? ( dev-db/libiodbc ) |
| 38 |
!iodbc? ( dev-db/unixODBC ) |
| 39 |
)" |
| 40 |
|
| 41 |
RDEPEND="${COMMON_DEPEND} |
| 42 |
proxy? ( <=net-analyzer/fping-2.9 ) |
| 43 |
server? ( <=net-analyzer/fping-2.9 |
| 44 |
app-admin/webapp-config ) |
| 45 |
java? ( |
| 46 |
>=virtual/jre-1.4 |
| 47 |
dev-java/slf4j-api |
| 48 |
dev-java/json-simple |
| 49 |
) |
| 50 |
frontend? ( |
| 51 |
dev-lang/php[bcmath,ctype,sockets,gd,truetype,xml,session,xmlreader,xmlwriter,nls] |
| 52 |
media-libs/gd[png] |
| 53 |
app-admin/webapp-config )" |
| 54 |
DEPEND="${COMMON_DEPEND} |
| 55 |
virtual/pkgconfig" |
| 56 |
|
| 57 |
use frontend && need_php_httpd |
| 58 |
|
| 59 |
S=${WORKDIR}/${MY_P} |
| 60 |
|
| 61 |
ZABBIXJAVA_BASE="opt/zabbix_java" |
| 62 |
|
| 63 |
java_prepare() { |
| 64 |
cd "${S}/src/zabbix_java/lib" |
| 65 |
rm -v *.jar || die |
| 66 |
|
| 67 |
java-pkg_jar-from slf4j-api |
| 68 |
java-pkg_jar-from json-simple |
| 69 |
} |
| 70 |
|
| 71 |
src_prepare() { |
| 72 |
eautoreconf |
| 73 |
} |
| 74 |
|
| 75 |
pkg_setup() { |
| 76 |
if use server || use proxy ; then |
| 77 |
local dbnum dbtypes="mysql oracle postgres sqlite" dbtype |
| 78 |
declare -i dbnum=0 |
| 79 |
for dbtype in ${dbtypes}; do |
| 80 |
use ${dbtype} && let dbnum++ |
| 81 |
done |
| 82 |
if [ ${dbnum} -gt 1 ]; then |
| 83 |
eerror |
| 84 |
eerror "You can't use more than one database type in Zabbix." |
| 85 |
eerror "Select exactly one database type out of these: ${dbtypes}" |
| 86 |
eerror |
| 87 |
die "Multiple database types selected." |
| 88 |
elif [ ${dbnum} -lt 1 ]; then |
| 89 |
eerror |
| 90 |
eerror "Select exactly one database type out of these: ${dbtypes}" |
| 91 |
eerror |
| 92 |
die "No database type selected." |
| 93 |
fi |
| 94 |
if use oracle; then |
| 95 |
if [ -z "${ORACLE_HOME}" ]; then |
| 96 |
eerror |
| 97 |
eerror "The environment variable ORACLE_HOME must be set" |
| 98 |
eerror "and point to the correct location." |
| 99 |
eerror "It looks like you don't have Oracle installed." |
| 100 |
eerror |
| 101 |
die "Environment variable ORACLE_HOME is not set" |
| 102 |
fi |
| 103 |
if has_version 'dev-db/oracle-instantclient-basic'; then |
| 104 |
ewarn |
| 105 |
ewarn "Please ensure you have a full install of the Oracle client." |
| 106 |
ewarn "dev-db/oracle-instantclient* is NOT sufficient." |
| 107 |
ewarn |
| 108 |
fi |
| 109 |
fi |
| 110 |
fi |
| 111 |
|
| 112 |
if use frontend; then |
| 113 |
webapp_pkg_setup |
| 114 |
fi |
| 115 |
|
| 116 |
enewgroup zabbix |
| 117 |
enewuser zabbix -1 -1 /var/lib/zabbix/home zabbix |
| 118 |
} |
| 119 |
|
| 120 |
pkg_postinst() { |
| 121 |
if use server || use proxy ; then |
| 122 |
elog |
| 123 |
elog "You may need to configure your database for Zabbix," |
| 124 |
elog "if you have not already done so. Most minor version" |
| 125 |
elog "zabbix updates do not require db changes. However, " |
| 126 |
elog "you should read the release notes to be sure." |
| 127 |
elog |
| 128 |
elog "Have a look at /usr/share/zabbix for" |
| 129 |
elog "database creation and upgrades." |
| 130 |
elog |
| 131 |
elog "Execute schema, images, and data sql files in that order." |
| 132 |
elog |
| 133 |
elog "For more info read the Zabbix manual at" |
| 134 |
elog "http://www.zabbix.com/documentation.php" |
| 135 |
elog |
| 136 |
elog "New use flags: java, odbc, iodbc" |
| 137 |
elog |
| 138 |
|
| 139 |
zabbix_homedir=$(egethome zabbix) |
| 140 |
if [ -n "${zabbix_homedir}" ] && \ |
| 141 |
[ "${zabbix_homedir}" != "/var/lib/zabbix/home" ]; then |
| 142 |
ewarn |
| 143 |
ewarn "The user 'zabbix' should have his homedir changed" |
| 144 |
ewarn "to /var/lib/zabbix/home if you want to use" |
| 145 |
ewarn "custom alert scripts." |
| 146 |
ewarn |
| 147 |
ewarn "A real homedir might be needed for configfiles" |
| 148 |
ewarn "for custom alert scripts (e.g. ~/.sendxmpprc when" |
| 149 |
ewarn "using sendxmpp for Jabber alerts)." |
| 150 |
ewarn |
| 151 |
ewarn "To change the homedir use:" |
| 152 |
ewarn " usermod -d /var/lib/zabbix/home zabbix" |
| 153 |
ewarn |
| 154 |
fi |
| 155 |
fi |
| 156 |
|
| 157 |
if use server; then |
| 158 |
elog |
| 159 |
elog "For distributed monitoring you have to run:" |
| 160 |
elog |
| 161 |
elog "zabbix_server -n <nodeid>" |
| 162 |
elog |
| 163 |
elog "This will convert database data for use with Node ID" |
| 164 |
elog "and also adds a local node." |
| 165 |
elog |
| 166 |
fi |
| 167 |
|
| 168 |
elog "--" |
| 169 |
elog |
| 170 |
elog "You may need to add these lines to /etc/services:" |
| 171 |
elog |
| 172 |
elog "zabbix-agent 10050/tcp Zabbix Agent" |
| 173 |
elog "zabbix-agent 10050/udp Zabbix Agent" |
| 174 |
elog "zabbix-trapper 10051/tcp Zabbix Trapper" |
| 175 |
elog "zabbix-trapper 10051/udp Zabbix Trapper" |
| 176 |
elog |
| 177 |
|
| 178 |
elog "Zabbix is incompatible with fping 3.0 - (Zabbix bug #ZBX-4894)." |
| 179 |
elog |
| 180 |
elog "Feel free to download or contribute gentoo specific zabbix templates" |
| 181 |
elog "via https://github.com/deploylinux/gentooZabbixTemplates (WIP). We may" |
| 182 |
elog "eventually create a seperate package in portage for them." |
| 183 |
|
| 184 |
# repeat fowners/fperms functionality from src_install() |
| 185 |
# here to catch wrong permissions on existing files in |
| 186 |
# the live filesystem (yeah, that sucks). |
| 187 |
chown -R zabbix:zabbix \ |
| 188 |
"${ROOT}"/etc/zabbix \ |
| 189 |
"${ROOT}"/var/lib/zabbix \ |
| 190 |
"${ROOT}"/var/lib/zabbix/home \ |
| 191 |
"${ROOT}"/var/lib/zabbix/scripts \ |
| 192 |
"${ROOT}"/var/log/zabbix \ |
| 193 |
"${ROOT}"/var/run/zabbix |
| 194 |
chmod 0750 \ |
| 195 |
"${ROOT}"/etc/zabbix \ |
| 196 |
"${ROOT}"/var/lib/zabbix \ |
| 197 |
"${ROOT}"/var/lib/zabbix/home \ |
| 198 |
"${ROOT}"/var/lib/zabbix/scripts \ |
| 199 |
"${ROOT}"/var/log/zabbix \ |
| 200 |
"${ROOT}"/var/run/zabbix |
| 201 |
|
| 202 |
chmod 0640 \ |
| 203 |
"${ROOT}"/etc/zabbix/zabbix_* |
| 204 |
|
| 205 |
if use server || use proxy ; then |
| 206 |
# check for fping |
| 207 |
fping_perms=$(stat -c %a /usr/sbin/fping 2>/dev/null) |
| 208 |
case "${fping_perms}" in |
| 209 |
4[157][157][157]) |
| 210 |
;; |
| 211 |
*) |
| 212 |
ewarn |
| 213 |
ewarn "If you want to use the checks 'icmpping' and 'icmppingsec'," |
| 214 |
ewarn "you have to make /usr/sbin/fping setuid root and executable" |
| 215 |
ewarn "by everyone. Run the following command to fix it:" |
| 216 |
ewarn |
| 217 |
ewarn " chmod u=rwsx,g=rx,o=rx /usr/sbin/fping" |
| 218 |
ewarn |
| 219 |
ewarn "Please be aware that this might impose a security risk," |
| 220 |
ewarn "depending on the code quality of fping." |
| 221 |
ewarn |
| 222 |
ebeep 3 |
| 223 |
epause 5 |
| 224 |
;; |
| 225 |
esac |
| 226 |
fi |
| 227 |
} |
| 228 |
|
| 229 |
src_configure() { |
| 230 |
|
| 231 |
local myconf |
| 232 |
|
| 233 |
if use odbc && use iodbc ; then |
| 234 |
myconf="${myconf} --with-iodbc --without-unixodbc" |
| 235 |
elif use odbc && ! use iodbc; then |
| 236 |
myconf="${myconf} --with-unixodbc --without-iodbc" |
| 237 |
else |
| 238 |
myconf="${myconf} --without-unixodbc --without-iodbc" |
| 239 |
fi |
| 240 |
|
| 241 |
econf \ |
| 242 |
$myconf \ |
| 243 |
$(use_enable server) \ |
| 244 |
$(use_enable proxy) \ |
| 245 |
$(use_enable agent) \ |
| 246 |
$(use_enable ipv6) \ |
| 247 |
$(use_enable static) \ |
| 248 |
$(use_enable java) \ |
| 249 |
$(use_with ldap) \ |
| 250 |
$(use_with snmp net-snmp) \ |
| 251 |
$(use_with mysql) \ |
| 252 |
$(use_with postgres postgresql) \ |
| 253 |
$(use_with oracle) \ |
| 254 |
$(use_with sqlite sqlite3) \ |
| 255 |
$(use_with jabber) \ |
| 256 |
$(use_with curl libcurl) \ |
| 257 |
$(use_with openipmi openipmi) \ |
| 258 |
$(use_with ssh ssh2) \ |
| 259 |
|| die "econf failed" |
| 260 |
} |
| 261 |
|
| 262 |
src_install() { |
| 263 |
dodir \ |
| 264 |
/etc/zabbix \ |
| 265 |
/var/lib/zabbix \ |
| 266 |
/var/lib/zabbix/home \ |
| 267 |
/var/lib/zabbix/scripts \ |
| 268 |
/var/log/zabbix \ |
| 269 |
/var/run/zabbix |
| 270 |
|
| 271 |
keepdir \ |
| 272 |
/etc/zabbix \ |
| 273 |
/var/lib/zabbix \ |
| 274 |
/var/lib/zabbix/home \ |
| 275 |
/var/lib/zabbix/scripts \ |
| 276 |
/var/log/zabbix \ |
| 277 |
/var/run/zabbix |
| 278 |
|
| 279 |
if use server; then |
| 280 |
insinto /etc/zabbix |
| 281 |
doins \ |
| 282 |
"${FILESDIR}/1.6.6"/zabbix_server.conf \ |
| 283 |
"${FILESDIR}/1.6.6"/zabbix_trapper.conf |
| 284 |
doinitd \ |
| 285 |
"${FILESDIR}/2.0"/init.d/zabbix-server |
| 286 |
dosbin \ |
| 287 |
src/zabbix_server/zabbix_server |
| 288 |
dodir \ |
| 289 |
/usr/share/zabbix |
| 290 |
insinto /usr/share/zabbix |
| 291 |
doins -r \ |
| 292 |
database \ |
| 293 |
upgrades |
| 294 |
fowners zabbix:zabbix \ |
| 295 |
/etc/zabbix/zabbix_server.conf \ |
| 296 |
/etc/zabbix/zabbix_trapper.conf |
| 297 |
fperms 0640 \ |
| 298 |
/etc/zabbix/zabbix_server.conf \ |
| 299 |
/etc/zabbix/zabbix_trapper.conf |
| 300 |
fi |
| 301 |
|
| 302 |
if use proxy; then |
| 303 |
doinitd \ |
| 304 |
"${FILESDIR}/1.6.6"/init.d/zabbix-proxy |
| 305 |
dosbin \ |
| 306 |
src/zabbix_proxy/zabbix_proxy |
| 307 |
insinto /etc/zabbix |
| 308 |
doins \ |
| 309 |
"${FILESDIR}/1.6.6"/zabbix_proxy.conf |
| 310 |
dodir \ |
| 311 |
/usr/share/zabbix |
| 312 |
insinto /usr/share/zabbix |
| 313 |
doins -r \ |
| 314 |
database \ |
| 315 |
create |
| 316 |
fi |
| 317 |
|
| 318 |
if use agent; then |
| 319 |
insinto /etc/zabbix |
| 320 |
doins \ |
| 321 |
"${FILESDIR}/1.6.6"/zabbix_agent.conf \ |
| 322 |
"${FILESDIR}/1.6.6"/zabbix_agentd.conf |
| 323 |
doinitd \ |
| 324 |
"${FILESDIR}/2.0"/init.d/zabbix-agentd |
| 325 |
dosbin \ |
| 326 |
src/zabbix_agent/zabbix_agent \ |
| 327 |
src/zabbix_agent/zabbix_agentd |
| 328 |
dobin \ |
| 329 |
src/zabbix_sender/zabbix_sender \ |
| 330 |
src/zabbix_get/zabbix_get |
| 331 |
fowners zabbix:zabbix \ |
| 332 |
/etc/zabbix/zabbix_agent.conf \ |
| 333 |
/etc/zabbix/zabbix_agentd.conf |
| 334 |
fperms 0640 \ |
| 335 |
/etc/zabbix/zabbix_agent.conf \ |
| 336 |
/etc/zabbix/zabbix_agentd.conf |
| 337 |
fi |
| 338 |
|
| 339 |
fowners zabbix:zabbix \ |
| 340 |
/etc/zabbix \ |
| 341 |
/var/lib/zabbix \ |
| 342 |
/var/lib/zabbix/home \ |
| 343 |
/var/lib/zabbix/scripts \ |
| 344 |
/var/log/zabbix \ |
| 345 |
/var/run/zabbix |
| 346 |
fperms 0750 \ |
| 347 |
/etc/zabbix \ |
| 348 |
/var/lib/zabbix \ |
| 349 |
/var/lib/zabbix/home \ |
| 350 |
/var/lib/zabbix/scripts \ |
| 351 |
/var/log/zabbix \ |
| 352 |
/var/run/zabbix |
| 353 |
|
| 354 |
dodoc README INSTALL NEWS ChangeLog \ |
| 355 |
conf/zabbix_agent.conf \ |
| 356 |
conf/zabbix_agentd.conf \ |
| 357 |
conf/zabbix_proxy.conf \ |
| 358 |
conf/zabbix_agentd/userparameter_examples.conf \ |
| 359 |
conf/zabbix_agentd/userparameter_mysql.conf \ |
| 360 |
conf/zabbix_server.conf |
| 361 |
|
| 362 |
if use frontend; then |
| 363 |
webapp_src_preinst |
| 364 |
cp -R frontends/php/* "${D}/${MY_HTDOCSDIR}" |
| 365 |
webapp_postinst_txt en "${FILESDIR}/"1.6.6/postinstall-en.txt |
| 366 |
webapp_configfile \ |
| 367 |
"${MY_HTDOCSDIR}"/include/db.inc.php \ |
| 368 |
"${MY_HTDOCSDIR}"/include/config.inc.php |
| 369 |
webapp_src_install |
| 370 |
fi |
| 371 |
|
| 372 |
if use java; then |
| 373 |
dodir \ |
| 374 |
/${ZABBIXJAVA_BASE} \ |
| 375 |
/${ZABBIXJAVA_BASE}/bin \ |
| 376 |
/${ZABBIXJAVA_BASE}/lib |
| 377 |
keepdir /${ZABBIXJAVA_BASE} |
| 378 |
exeinto /${ZABBIXJAVA_BASE}/bin |
| 379 |
doexe src/zabbix_java/bin/zabbix-java-gateway-2.0.0rc3.jar |
| 380 |
exeinto /${ZABBIXJAVA_BASE}/lib |
| 381 |
doexe \ |
| 382 |
src/zabbix_java/lib/logback-classic-0.9.27.jar \ |
| 383 |
src/zabbix_java/lib/logback-console.xml \ |
| 384 |
src/zabbix_java/lib/logback-core-0.9.27.jar \ |
| 385 |
src/zabbix_java/lib/logback.xml \ |
| 386 |
src/zabbix_java/lib/org-json-2010-12-28.jar \ |
| 387 |
src/zabbix_java/lib/slf4j-api-1.6.1.jar |
| 388 |
exeinto /${ZABBIXJAVA_BASE}/ |
| 389 |
src/zabbix_java/settings.sh \ |
| 390 |
src/zabbix_java/startup.sh \ |
| 391 |
src/zabbix_java/shutdown.sh |
| 392 |
fowners -R zabbix:zabbix /${ZABBIXJAVA_BASE} |
| 393 |
fi |
| 394 |
|
| 395 |
} |