| 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-1.8.11-r1.ebuild,v 1.3 2012/06/12 03:55:18 zmedico 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 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 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 ) |
| 28 |
sqlite? ( =dev-db/sqlite-3* ) |
| 29 |
postgres? ( dev-db/postgresql-base ) |
| 30 |
oracle? ( dev-db/oracle-instantclient-basic ) |
| 31 |
jabber? ( dev-libs/iksemel ) |
| 32 |
curl? ( net-misc/curl ) |
| 33 |
openipmi? ( sys-libs/openipmi ) |
| 34 |
ssh? ( net-libs/libssh2 ) |
| 35 |
odbc? ( |
| 36 |
iodbc? ( dev-db/libiodbc ) |
| 37 |
!iodbc? ( dev-db/unixODBC ) |
| 38 |
)" |
| 39 |
|
| 40 |
RDEPEND="${COMMON_DEPEND} |
| 41 |
proxy? ( net-analyzer/fping ) |
| 42 |
server? ( net-analyzer/fping |
| 43 |
app-admin/webapp-config ) |
| 44 |
frontend? ( dev-lang/php[bcmath,ctype,sockets,gd,truetype,xml,session] |
| 45 |
media-libs/gd[png] |
| 46 |
app-admin/webapp-config )" |
| 47 |
DEPEND="${COMMON_DEPEND} |
| 48 |
virtual/pkgconfig" |
| 49 |
|
| 50 |
use frontend && need_php_httpd |
| 51 |
|
| 52 |
src_prepare() { |
| 53 |
eautoreconf |
| 54 |
} |
| 55 |
|
| 56 |
pkg_setup() { |
| 57 |
if use server || use proxy ; then |
| 58 |
local dbnum dbtypes="mysql oracle postgres sqlite" dbtype |
| 59 |
declare -i dbnum=0 |
| 60 |
for dbtype in ${dbtypes}; do |
| 61 |
use ${dbtype} && let dbnum++ |
| 62 |
done |
| 63 |
if [ ${dbnum} -gt 1 ]; then |
| 64 |
eerror |
| 65 |
eerror "You can't use more than one database type in Zabbix." |
| 66 |
eerror "Select exactly one database type out of these: ${dbtypes}" |
| 67 |
eerror |
| 68 |
die "Multiple database types selected." |
| 69 |
elif [ ${dbnum} -lt 1 ]; then |
| 70 |
eerror |
| 71 |
eerror "Select exactly one database type out of these: ${dbtypes}" |
| 72 |
eerror |
| 73 |
die "No database type selected." |
| 74 |
fi |
| 75 |
if use oracle; then |
| 76 |
if [ -z "${ORACLE_HOME}" ]; then |
| 77 |
eerror |
| 78 |
eerror "The environment variable ORACLE_HOME must be set" |
| 79 |
eerror "and point to the correct location." |
| 80 |
eerror "It looks like you don't have Oracle installed." |
| 81 |
eerror |
| 82 |
die "Environment variable ORACLE_HOME is not set" |
| 83 |
fi |
| 84 |
if has_version 'dev-db/oracle-instantclient-basic'; then |
| 85 |
ewarn |
| 86 |
ewarn "Please ensure you have a full install of the Oracle client." |
| 87 |
ewarn "dev-db/oracle-instantclient* is NOT sufficient." |
| 88 |
ewarn |
| 89 |
fi |
| 90 |
fi |
| 91 |
fi |
| 92 |
|
| 93 |
if use frontend; then |
| 94 |
webapp_pkg_setup |
| 95 |
fi |
| 96 |
|
| 97 |
enewgroup zabbix |
| 98 |
enewuser zabbix -1 -1 /var/lib/zabbix/home zabbix |
| 99 |
} |
| 100 |
|
| 101 |
pkg_postinst() { |
| 102 |
if use server || use proxy ; then |
| 103 |
elog |
| 104 |
elog "You need to configure your database for Zabbix." |
| 105 |
elog |
| 106 |
elog "Have a look at /usr/share/zabbix/database for" |
| 107 |
elog "database creation and upgrades." |
| 108 |
elog |
| 109 |
elog "For more info read the Zabbix manual at" |
| 110 |
elog "http://www.zabbix.com/documentation.php" |
| 111 |
elog |
| 112 |
|
| 113 |
zabbix_homedir=$(egethome zabbix) |
| 114 |
if [ -n "${zabbix_homedir}" ] && \ |
| 115 |
[ "${zabbix_homedir}" != "/var/lib/zabbix/home" ]; then |
| 116 |
ewarn |
| 117 |
ewarn "The user 'zabbix' should have his homedir changed" |
| 118 |
ewarn "to /var/lib/zabbix/home if you want to use" |
| 119 |
ewarn "custom alert scripts." |
| 120 |
ewarn |
| 121 |
ewarn "A real homedir might be needed for configfiles" |
| 122 |
ewarn "for custom alert scripts (e.g. ~/.sendxmpprc when" |
| 123 |
ewarn "using sendxmpp for Jabber alerts)." |
| 124 |
ewarn |
| 125 |
ewarn "To change the homedir use:" |
| 126 |
ewarn " usermod -d /var/lib/zabbix/home zabbix" |
| 127 |
ewarn |
| 128 |
fi |
| 129 |
fi |
| 130 |
|
| 131 |
if use server; then |
| 132 |
elog |
| 133 |
elog "For distributed monitoring you have to run:" |
| 134 |
elog |
| 135 |
elog "zabbix_server -n <nodeid>" |
| 136 |
elog |
| 137 |
elog "This will convert database data for use with Node ID" |
| 138 |
elog "and also adds a local node." |
| 139 |
elog |
| 140 |
fi |
| 141 |
|
| 142 |
elog "--" |
| 143 |
elog |
| 144 |
elog "Add these lines in the /etc/services :" |
| 145 |
elog |
| 146 |
elog "zabbix-agent 10050/tcp Zabbix Agent" |
| 147 |
elog "zabbix-agent 10050/udp Zabbix Agent" |
| 148 |
elog "zabbix-trapper 10051/tcp Zabbix Trapper" |
| 149 |
elog "zabbix-trapper 10051/udp Zabbix Trapper" |
| 150 |
elog |
| 151 |
|
| 152 |
# repeat fowners/fperms functionality from src_install() |
| 153 |
# here to catch wrong permissions on existing files in |
| 154 |
# the live filesystem (yeah, that sucks). |
| 155 |
chown -R zabbix:zabbix \ |
| 156 |
"${ROOT}"/etc/zabbix \ |
| 157 |
"${ROOT}"/var/lib/zabbix \ |
| 158 |
"${ROOT}"/var/lib/zabbix/home \ |
| 159 |
"${ROOT}"/var/lib/zabbix/scripts \ |
| 160 |
"${ROOT}"/var/log/zabbix \ |
| 161 |
"${ROOT}"/var/run/zabbix |
| 162 |
chmod 0750 \ |
| 163 |
"${ROOT}"/etc/zabbix \ |
| 164 |
"${ROOT}"/var/lib/zabbix \ |
| 165 |
"${ROOT}"/var/lib/zabbix/home \ |
| 166 |
"${ROOT}"/var/lib/zabbix/scripts \ |
| 167 |
"${ROOT}"/var/log/zabbix \ |
| 168 |
"${ROOT}"/var/run/zabbix |
| 169 |
|
| 170 |
chmod 0640 \ |
| 171 |
"${ROOT}"/etc/zabbix/zabbix_* |
| 172 |
|
| 173 |
if use server || use proxy ; then |
| 174 |
# check for fping |
| 175 |
fping_perms=$(stat -c %a /usr/sbin/fping 2>/dev/null) |
| 176 |
case "${fping_perms}" in |
| 177 |
4[157][157][157]) |
| 178 |
;; |
| 179 |
*) |
| 180 |
ewarn |
| 181 |
ewarn "If you want to use the checks 'icmpping' and 'icmppingsec'," |
| 182 |
ewarn "you have to make /usr/sbin/fping setuid root and executable" |
| 183 |
ewarn "by everyone. Run the following command to fix it:" |
| 184 |
ewarn |
| 185 |
ewarn " chmod u=rwsx,g=rx,o=rx /usr/sbin/fping" |
| 186 |
ewarn |
| 187 |
ewarn "Please be aware that this might impose a security risk," |
| 188 |
ewarn "depending on the code quality of fping." |
| 189 |
ewarn |
| 190 |
ebeep 3 |
| 191 |
epause 5 |
| 192 |
;; |
| 193 |
esac |
| 194 |
fi |
| 195 |
} |
| 196 |
|
| 197 |
src_configure() { |
| 198 |
|
| 199 |
local myconf |
| 200 |
|
| 201 |
if use odbc && use iodbc ; then |
| 202 |
myconf="${myconf} --with-iodbc --without-unixodbc" |
| 203 |
elif use odbc && ! use iodbc; then |
| 204 |
myconf="${myconf} --with-unixodbc --without-iodbc" |
| 205 |
else |
| 206 |
myconf="${myconf} --without-unixodbc --without-iodbc" |
| 207 |
fi |
| 208 |
|
| 209 |
econf \ |
| 210 |
$myconf \ |
| 211 |
$(use_enable server) \ |
| 212 |
$(use_enable proxy) \ |
| 213 |
$(use_enable agent) \ |
| 214 |
$(use_enable ipv6) \ |
| 215 |
$(use_enable static) \ |
| 216 |
$(use_with ldap) \ |
| 217 |
$(use_with snmp net-snmp) \ |
| 218 |
$(use_with mysql) \ |
| 219 |
$(use_with postgres pgsql) \ |
| 220 |
$(use_with oracle) \ |
| 221 |
$(use_with sqlite sqlite3) \ |
| 222 |
$(use_with jabber) \ |
| 223 |
$(use_with curl libcurl) \ |
| 224 |
$(use_with openipmi openipmi) \ |
| 225 |
$(use_with ssh ssh2) \ |
| 226 |
|| die "econf failed" |
| 227 |
} |
| 228 |
|
| 229 |
src_install() { |
| 230 |
dodir \ |
| 231 |
/etc/zabbix \ |
| 232 |
/var/lib/zabbix \ |
| 233 |
/var/lib/zabbix/home \ |
| 234 |
/var/lib/zabbix/scripts \ |
| 235 |
/var/log/zabbix \ |
| 236 |
/var/run/zabbix |
| 237 |
|
| 238 |
keepdir \ |
| 239 |
/etc/zabbix \ |
| 240 |
/var/lib/zabbix \ |
| 241 |
/var/lib/zabbix/home \ |
| 242 |
/var/lib/zabbix/scripts \ |
| 243 |
/var/log/zabbix \ |
| 244 |
/var/run/zabbix |
| 245 |
|
| 246 |
if use server; then |
| 247 |
insinto /etc/zabbix |
| 248 |
doins \ |
| 249 |
"${FILESDIR}/1.6.6"/zabbix_server.conf \ |
| 250 |
"${FILESDIR}/1.6.6"/zabbix_trapper.conf |
| 251 |
doinitd \ |
| 252 |
"${FILESDIR}/1.6.6"/init.d/zabbix-server |
| 253 |
dosbin \ |
| 254 |
src/zabbix_server/zabbix_server |
| 255 |
dodir \ |
| 256 |
/usr/share/zabbix/database |
| 257 |
insinto /usr/share/zabbix/database |
| 258 |
doins -r \ |
| 259 |
upgrades \ |
| 260 |
create |
| 261 |
fowners zabbix:zabbix \ |
| 262 |
/etc/zabbix/zabbix_server.conf \ |
| 263 |
/etc/zabbix/zabbix_trapper.conf |
| 264 |
fperms 0640 \ |
| 265 |
/etc/zabbix/zabbix_server.conf \ |
| 266 |
/etc/zabbix/zabbix_trapper.conf |
| 267 |
fi |
| 268 |
|
| 269 |
if use proxy; then |
| 270 |
doinitd \ |
| 271 |
"${FILESDIR}/1.6.6"/init.d/zabbix-proxy |
| 272 |
dosbin \ |
| 273 |
src/zabbix_proxy/zabbix_proxy |
| 274 |
insinto /etc/zabbix |
| 275 |
doins \ |
| 276 |
"${FILESDIR}/1.6.6"/zabbix_proxy.conf |
| 277 |
dodir \ |
| 278 |
/usr/share/zabbix/database |
| 279 |
insinto /usr/share/zabbix/database |
| 280 |
doins -r \ |
| 281 |
upgrades \ |
| 282 |
create |
| 283 |
fi |
| 284 |
|
| 285 |
if use agent; then |
| 286 |
insinto /etc/zabbix |
| 287 |
doins \ |
| 288 |
"${FILESDIR}/1.6.6"/zabbix_agent.conf \ |
| 289 |
"${FILESDIR}/1.6.6"/zabbix_agentd.conf |
| 290 |
doinitd \ |
| 291 |
"${FILESDIR}/1.6.6"/init.d/zabbix-agentd |
| 292 |
dosbin \ |
| 293 |
src/zabbix_agent/zabbix_agent \ |
| 294 |
src/zabbix_agent/zabbix_agentd |
| 295 |
dobin \ |
| 296 |
src/zabbix_sender/zabbix_sender \ |
| 297 |
src/zabbix_get/zabbix_get |
| 298 |
fowners zabbix:zabbix \ |
| 299 |
/etc/zabbix/zabbix_agent.conf \ |
| 300 |
/etc/zabbix/zabbix_agentd.conf |
| 301 |
fperms 0640 \ |
| 302 |
/etc/zabbix/zabbix_agent.conf \ |
| 303 |
/etc/zabbix/zabbix_agentd.conf |
| 304 |
fi |
| 305 |
|
| 306 |
fowners zabbix:zabbix \ |
| 307 |
/etc/zabbix \ |
| 308 |
/var/lib/zabbix \ |
| 309 |
/var/lib/zabbix/home \ |
| 310 |
/var/lib/zabbix/scripts \ |
| 311 |
/var/log/zabbix \ |
| 312 |
/var/run/zabbix |
| 313 |
fperms 0750 \ |
| 314 |
/etc/zabbix \ |
| 315 |
/var/lib/zabbix \ |
| 316 |
/var/lib/zabbix/home \ |
| 317 |
/var/lib/zabbix/scripts \ |
| 318 |
/var/log/zabbix \ |
| 319 |
/var/run/zabbix |
| 320 |
|
| 321 |
dodoc README INSTALL NEWS ChangeLog |
| 322 |
|
| 323 |
if use frontend; then |
| 324 |
webapp_src_preinst |
| 325 |
cp -R frontends/php/* "${D}/${MY_HTDOCSDIR}" |
| 326 |
webapp_postinst_txt en "${FILESDIR}/"1.6.6/postinstall-en.txt |
| 327 |
webapp_configfile \ |
| 328 |
"${MY_HTDOCSDIR}"/include/db.inc.php \ |
| 329 |
"${MY_HTDOCSDIR}"/include/config.inc.php |
| 330 |
webapp_src_install |
| 331 |
fi |
| 332 |
} |