summaryrefslogtreecommitdiff
blob: b932052e5cdc1fe4fe587fbff3b184d86e04e88e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/zabbix-server/zabbix-server-1.0.ebuild,v 1.2 2005/12/31 13:46:47 flameeyes Exp $

inherit eutils

MY_P=${PN//-server/}
DESCRIPTION="ZABBIX is software for monitoring of your applications, network and servers. Server part."

HOMEPAGE="http://zabbix.com/"
SRC_URI="mirror://sourceforge/zabbix/${MY_P}-${PV}.tar.gz"

LICENSE="GPL-2"
SLOT="0"

KEYWORDS="~x86 ~amd64"

IUSE="snmp mysql postgres"

DEPEND="snmp? ( net-analyzer/net-snmp )
	mysql? ( dev-db/mysql )
	postgres? ( dev-db/postgresql )"

# Run-time dependencies, same as DEPEND if RDEPEND isn't defined:"
RDEPEND="net-analyzer/fping"

S=${WORKDIR}/${MY_P}-${PV}

pkg_setup() {
	enewgroup zabbix
	enewuser zabbix -1 -1 /dev/null zabbix
}

src_unpack() {
	if ( use mysql && use postgres )
	then
	eerror "You can't use both database in zabbix. Select one database"
	die "Set both database"
	fi
	if (( ! use mysql ) && ( ! use postgres ))
	then
	eerror "Selected mysql or postgresql database"
	die "No select database"
	fi
	unpack ${A}
}

src_compile() {
	local myconf=""
	if use mysql; then
		myconf="--with-mysql"
		einfo "using mysql backend"
	fi
	if use postgres; then
		myconf="--with-pgsql"
		einfo "using postgresql backend"
	fi
	if use snmp; then
		myconf="${myconf} --with-net-snmp"
		einfo "using net-snmp for snmp request"
	fi
	./configure ${myconf} || die "econf failed"
	emake || die "emake failed"
}

src_install() {
	dodir /etc/zabbix /var/log/zabbix /var/run/zabbix /usr/share/zabbix/sripts /usr/share/zabbix/dbms
	keepdir /etc/zabbix /var/log/zabbix /var/run/zabbix
	insinto /etc/zabbix
	doins ${FILESDIR}/${PV}/zabbix_suckerd.conf ${FILESDIR}/${PV}/zabbix_trapper.conf ${FILESDIR}/${PV}/zabbix_trapperd.conf
	insinto /etc/conf.d
	doins ${FILESDIR}/${PV}/conf.d/zabbix-suckerd ${FILESDIR}/${PV}/conf.d/zabbix-trapperd
	exeinto /etc/init.d
	doexe ${FILESDIR}/${PV}/init.d/zabbix-suckerd ${FILESDIR}/${PV}/init.d/zabbix-trapperd
	fowners zabbix:zabbix /etc/zabbix /var/log/zabbix /var/run/zabbix /usr/share/zabbix/sripts /usr/share/zabbix/dbms /etc/zabbix/zabbix_suckerd.conf /etc/zabbix/zabbix_trapper.conf /etc/zabbix/zabbix_trapperd.conf
	fperms 0640 /etc/zabbix/zabbix_suckerd.conf /etc/zabbix/zabbix_trapper.conf /etc/zabbix/zabbix_trapperd.conf
	dosbin bin/zabbix_suckerd bin/zabbix_trapper bin/zabbix_trapperd
	fperms 0750 /var/log/zabbix /var/run/zabbix
	dodoc README INSTALL NEWS ChangeLog
	insinto /usr/share/doc/${P}
	doins doc/Zabbix\ Manual.pdf
	insinto /usr/share/zabbix/dbms
	doins create/data/data.sql
	if use mysql; then
		doins create/mysql/schema.sql
	fi
	if use postgres; then
		doins create/postgresql/schema.sql
	fi
}


pkg_postinst(){
	if ( use mysql ); then
		einfo "You need configure mysql for zabbix."
		einfo "For more info read Zabbix Manual (/usr/share/doc/${P}/Zabbix Manual.pdf)"
	fi
	if ( use postgres ); then
		einfo "You need configure postgresql for zabbix."
		einfo "For more info read Zabbix Manual (/usr/share/doc/${P}/Zabbix Manual.pdf)"
	fi

}