aboutsummaryrefslogtreecommitdiffstats
path: root/community/zabbix/APKBUILD
blob: 0f7b19098a4f05befc9cdf56f9433ac45c62c5f3 (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# Contributor: Łukasz Jendrysik <scadu@yandex.com>
# Contributor: Jeff Bilyk <jbilyk at gmail>
# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=zabbix
pkgver=4.4.1
pkgrel=1
pkgdesc="Enterprise-class open source distributed monitoring"
url="http://www.zabbix.com"
arch="all"
license="GPL-2.0-or-later"
depends="fping"
_php=php7
_php_depends="$_php $_php-gd $_php-curl $_php-bcmath $_php-sockets
 $_php-iconv $_php-xmlreader $_php-xmlwriter $_php-ctype
	$_php-gettext $_php-session $_php-simplexml $_php-json"
makedepends="postgresql-dev curl-dev net-snmp-dev libevent-dev pcre-dev
	sqlite-dev mariadb-connector-c-dev curl-dev openipmi-dev unixodbc-dev
	libxml2-dev autoconf automake libssh2-dev gnutls-dev
	$_php_depends"
install="$pkgname.pre-install"
pkgusers="zabbix"
pkggroups="zabbix"
options="!check" # no tests available
subpackages="$pkgname-doc $pkgname-agent $pkgname-pgsql $pkgname-mysql $pkgname-sqlite
	$pkgname-webif::noarch $pkgname-utils $pkgname-setup::noarch
	$pkgname-openrc $pkgname-agent-openrc:agent_openrc"
source="https://downloads.sourceforge.net/zabbix/zabbix-$pkgver.tar.gz
	zabbix-server.initd
	zabbix-server.confd
	zabbix-agentd.initd
	zabbix-agent2.initd
	zabbix-proxy.initd

	zabbix-getloadavg.patch
	automake.patch
	musl-fix-includes.patch
	zabbix_server.conf.patch
	zabbix_agent2.conf.patch
	zabbix_agent2-uname-linux.patch
	"

# Agent2 does not build on x86 atm
case $CARCH in
x86|armv7|armhf)
	_build_agent2=false;;
*)
	subpackages="$subpackages $pkgname-agent2 $pkgname-agent2-openrc:agent2_openrc"
	makedepends="$makedepends go"
	_build_agent2=true;;
esac

# security fixes:
#   3.0.4-r0:
#   - CVE N/A ZBX-11023

prepare() {
	default_prepare
	autoreconf -fvi

	# Fix config file locations
	for file in server agentd proxy; do
		sed -i "$builddir"/conf/zabbix_$file.conf \
			-e 's|SNMPTrapperFile=/tmp|SNMPTrapperFile=/var/log/zabbix|' \
			-e 's|PidFile=/tmp|PidFile=/var/run/zabbix|' \
			-e 's|LogFile=/tmp|LogFile=/var/log/zabbix|'
	done
}

build() {
	# set default configure flags
	_configure="--prefix=/usr \
			--sysconfdir=/etc/zabbix \
			--mandir=/usr/share/man \
			--infodir=/usr/share/info \
			--enable-agent \
			--enable-proxy \
			--enable-ipv6 \
			--with-net-snmp \
			--with-libcurl \
			--with-libxml2 \
			--with-openipmi \
			--with-unixodbc \
			--with-ssh2 \
			--with-gnutls
			"

	if $_build_agent2; then
		_configure="$_configure --enable-agent2"
	fi

	export GOPATH="$builddir"
	# pass --export-dynamic to the linker
	# to make zabbix loadable modules work
	LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
	# we run build for each db type
	# make sure prepare is same for each db
	for db in postgresql mysql sqlite3; do
		cd "$srcdir"
		msg "Building for $db"
		cp -r "$pkgname-$pkgver" "$pkgname-$pkgver-$db"
	cd "$builddir-$db"
		case $db in
			sqlite3)
				./configure \
					--build=$CBUILD	\
					--host=$CHOST \
					--with-$db \
					$_configure
			;;
			*)
				./configure \
					--build=$CBUILD \
					--host=$CHOST \
					--enable-server \
					--with-$db \
					$_configure
			;;
		esac
		make
	done
}

package() {
	# doing manual install
	components="agentd proxy server";
	if $_build_agent2; then
		msg2 "Packaging agen2"
		components="$components agent2"
	fi

	for i in $components; do
		install -D -m755 "$builddir"/man/zabbix_$i.man \
			"$pkgdir"/usr/share/man/man8/zabbix_$i.8
	done
	for i in get sender; do
		install -D -m755 "$builddir"/man/zabbix_$i.man \
			"$pkgdir"/usr/share/man/man1/zabbix_$i.1
	done
	install -d -m0750 -o zabbix -g zabbix \
		"$pkgdir"/var/run/zabbix "$pkgdir"/var/log/zabbix
	install -D -m0644 "$builddir"/conf/zabbix_server.conf \
		"$pkgdir"/etc/zabbix/zabbix_server.conf
	for i in server proxy; do
		install -D -m0755 "$srcdir"/zabbix-$i.initd \
			"$pkgdir"/etc/init.d/zabbix-$i
	done
	install -D -m0644 "$srcdir"/zabbix-server.confd \
		"$pkgdir"/etc/conf.d/zabbix-server
}

setup() {
	pkgdesc="Zabbix images and sql files"
	depends=
	mkdir -p "$subpkgdir"/usr/share/zabbix
	cp -r "$builddir"/database "$subpkgdir"/usr/share/zabbix/
}

_do_db() {
	pkgdesc="Zabbix server with $1 database support"
	depends="$pkgname $2"
	local i=
	mkdir -p "$subpkgdir"/usr/sbin
	if [ "$1" != "sqlite3" ]; then
		cp "$builddir-$1"/src/zabbix_server/zabbix_server \
			"$subpkgdir"/usr/sbin
	fi
	cp "$builddir-$1"/src/zabbix_proxy/zabbix_proxy	\
		"$subpkgdir"/usr/sbin
	install	-D -m0644 "$builddir"/conf/zabbix_proxy.conf \
		"$pkgdir"/etc/zabbix/zabbix_proxy.conf
	cd "$builddir"
	for i in upgrades/dbpatches/*/"$1"; do
		[ -e $i ] || continue
		mkdir -p "$subpkgdir"/usr/share/zabbix/${i%/*}
		cp "$i" "$subpkgdir"/usr/share/zabbix/$i
	done
	return 0
}

pgsql() { _do_db postgresql "!$pkgname-mysql !$pkgname-sqlite";}
mysql() { _do_db mysql "!$pkgname-pgsql !$pkgname-sqlite";}
sqlite() { _do_db sqlite3 "!$pkgname-pgsql !$pkgname-mysql";}

utils() {
	pkgdesc="Zabbix client utilities"
	depends=
	mkdir -p "$subpkgdir"/usr/bin
	cp "$builddir-postgresql"/src/zabbix_get/zabbix_get \
		"$subpkgdir"/usr/bin
	cp "$builddir-postgresql"/src/zabbix_sender/zabbix_sender \
			"$subpkgdir"/usr/bin
}

webif() {
	pkgdesc="Zabbix web-interface"
	depends="$_php_depends"
	_wwwdir="$subpkgdir"/usr/share/webapps/zabbix
	mkdir -p $_wwwdir
	cp -r "$builddir"/frontends/php/* "$_wwwdir"
}

agent() {
	pkgdesc="Zabbix Network Monitoring Agent"
	depends=
	install="$subpkgname.pre-install"

	install -d -m0750 -o zabbix -g zabbix \
		"$subpkgdir"/var/run/zabbix "$subpkgdir"/var/log/zabbix
	mkdir -p "$subpkgdir"/usr/sbin
	cp "$builddir-postgresql"/src/zabbix_agent/zabbix_agentd \
		"$subpkgdir"/usr/sbin

	install -D -m0644 "$builddir"/conf/zabbix_agentd.conf \
		"$subpkgdir"/etc/zabbix/zabbix_agentd.conf
}

agent_openrc() {
	pkgdesc="Zabbix Network Monitoring Agent (OpenRC init scripts)"
	depends=openrc
	install_if="openrc $pkgname-agent=$pkgver-r$pkgrel"

	install -D -m0755 "$srcdir"/zabbix-agentd.initd \
		"$subpkgdir"/etc/init.d/zabbix-agentd
}

agent2() {
	pkgdesc="Zabbix Network Monitoring Agent (version 2)"
	depends=
	install="$subpkgname.pre-install"

	install -d -m0750 -o zabbix -g zabbix \
		"$subpkgdir"/var/run/zabbix "$subpkgdir"/var/log/zabbix
	mkdir -p "$subpkgdir"/usr/sbin
	cp "$builddir-postgresql"/go/src/zabbix/cmd/zabbix_agent2/zabbix_agent2 \
		"$subpkgdir"/usr/sbin

	install -D -m0644 "$builddir"/go/src/zabbix/conf/zabbix_agent2.conf \
		"$subpkgdir"/etc/zabbix/zabbix_agent2.conf
}

agent2_openrc() {
	pkgdesc="Zabbix Network Monitoring Agent 2 (OpenRC init scripts)"
	depends=openrc
	install_if="openrc $pkgname-agent2=$pkgver-r$pkgrel"

	install -D -m0755 "$srcdir"/zabbix-agent2.initd \
		"$subpkgdir"/etc/init.d/zabbix-agent2
}

sha512sums="8ea542a6af31dad20180899b68a47adb0fd0f2e07f9abef8892d59ec3a58ea01862d3c336be327912ffa50473c3cd4cc7bf311ed51d85898972ae3fe4c2167ce  zabbix-4.4.1.tar.gz
9998ee172a28002d98bacc3f76038ff52b8cf2b206e101418d76b4ca3de94afaf92cb4f7a6235ecf177f74beb9dd3ea1f3983c4f164b4f60bb601acba65aa175  zabbix-server.initd
9c06527bf653c40585fa7eeb3f7a0b2fc454031d24cd0d1633aed87b78a681c5227a193c5b9fcfcea0839135874e27ba7dd9b198573f905f680a2856f79e9512  zabbix-server.confd
0d50795233ee469e36e9788f8685b16207a37f8a9370e6591688906176e7cb8387ce06f132d7e582a1757fdea7c584a70ccfac39a604da315d71121fa629cbb7  zabbix-agentd.initd
fad1bbe50ae42e02b73bcae8f7d91c7e18fb387eba551f9216c844c298003290aaec3bc17239590210cc100d6f39e25a5bba539e99df605de9a98abf5418be66  zabbix-agent2.initd
a26e7ac422ff60a4b8eed3603022c3a1bde640870bb9286ab061c3cb5c2fd7e91ddb317cb3d1cf61034adda0a080fc212ad416c9e2853a1deb03c5279753f4e2  zabbix-proxy.initd
9fc413b11a01c8202c7ee1c7950d6ca3de2d2d6cd01bea994cd4bc412533b53c4e4b1f58fc3c8df16ea70902053e278e2c5dcc936ce3e0a686a6eac62310ef53  zabbix-getloadavg.patch
7f70dfd602aa164ec8cc65ebb7e8274c685975f6aea9051933928051b8d9b6e368e5a673a07e7084a2105468c5085d72fa7b9f934460f10648d594f28f031a91  automake.patch
72709df7624d99b2eaab8d91d95167580e80da10b3ac65b7f27f12d858f0d051d4f9143bcabceae2bfd51aeb7c4ca93e2b74670637ec0925b026e3c52475d52b  musl-fix-includes.patch
183e2d99800d8eebb932cb31c5a3e8742ce6a15e87aec50dc49d9c20b35840eb7ede9920aa62d2c7a5e3f584f5c3df398aa08e93f98fa537a3ba6db63b472a1f  zabbix_server.conf.patch
4478e52d044d6cd888084d2cdfc77883ae7c90f3494b52a511445776a2a851d6bc25ed7d7a196e35b826ba10b3dcca2f762adc7c52727b07254d02aaa04d319b  zabbix_agent2.conf.patch
e04fc508ab91effea43b0f631051dd8f63b219d72002e39117b58af286bd6f451702f84a7a1083d7dab6fa294725b390e2f515ca1432a241a321a763570f5d1a  zabbix_agent2-uname-linux.patch"