archrelease: copy trunk to extra-x86_64
[arch-packages.git] / zabbix / trunk / PKGBUILD
blob36db270832347bfe791b8d3e26a9c1543b648c1c
1 # Maintainer: BartÅ‚omiej Piotrowski <bpiotrowski@archlinux.org>
2 # Maintainer: Florian Pritz <bluewind@xinu.at>
4 pkgbase=zabbix
5 pkgname=(zabbix-server zabbix-agent{,2} zabbix-proxy zabbix-frontend-php)
6 pkgver=6.4.2
7 pkgrel=1
8 arch=(x86_64)
9 url='https://www.zabbix.com/'
10 license=(GPL)
11 makedepends=(postgresql-libs libxml2 unixodbc net-snmp mariadb-libs libldap libevent go pkgconfig pcre2)
12 source=("https://cdn.zabbix.com/zabbix/sources/stable/${pkgver%.*}/zabbix-${pkgver}.tar.gz"
13         zabbix-agent.{service,sysusers,tmpfiles}
14         zabbix-agent2.service
15         zabbix-server{-mysql,-pgsql}.service zabbix-server.{sysusers,tmpfiles}
16         zabbix-proxy{-sqlite,-mysql,-pgsql}.service zabbix-proxy.{sysusers,tmpfiles})
18 sha512sums=('72b8842444aade42519d78856231024c1587ad9076ef21597a2dde580a49b99ea884a62508ebb1c08d883430b911a54d8a5f8421bee0d9e99b3610342191632f'
19             '8c1fa2676bc0ef91bc39ec5f97b4d3ba5c365d063420455a3785121a54e120bc5afeacde42a48f4509c115f940dcc3b6c2f43044a7fbfb421182fc93b22a2444'
20             '3ab3ac1acc7e35c8896157aef601ebc30815237ac5252cbd0c1ecb26eeaf9eccf5c49938ae8c85bb79a6f95f607f082f6b80ed660829599ec03aa626cca6d3dc'
21             'ca6b4779de23829dfdd80ee21e924fbe4e2754f4e693bed4b1a2aa846cd87d150e399b1169d7fe58d30c50ed837c1b8254e580de420267d0a1834d6dc409c43d'
22             'c57dfcc13b290f4120d1185339bd2d6b1ea7a2ca0c98dca8632d4fd8fe462a42cb35e8a88895eb8ee390c55cf0ffb90b544f23fefbf059b49c06e5373d0b8af2'
23             'b35155a5d151eb7258bca62d53e7099a05605e58adac9d1510e12c2219abc22f931e92ea5d36bf86900e30982e893e429235d983a7823610d76c15082c373d1f'
24             'ac968d9954e5d9523eb7a9b8dcbcef40d4b47c1db3b2ff86d5fbc3f1871fcd03aff14f5b0cfeeeb494fdeb2d95e2e32b8622297c714a90d22c68ab3b3b914475'
25             '4254d3b13ff0d19a8e207f709c10ea59dbb6d4f333d862b1611a0fa4ced199e9a32313e88d8abadc129c1e4001b182c0545bcc84117d218116a8c524de88850e'
26             'b6d548a26f845ef1a39724e3273aa521715272e20a0038144f86d377a26dfec6e3e129404cfda77632cad2f5cd6bab4a33f70a26c8c67b0d0b2abb3678ad2d83'
27             '7b5829caa77c6b5da8c2195ab840f0020f722a94f01a437324afdbe2a4372a594dcca6d63d2fdda5cfad81353ab4e4e0b2c6b67436203266dd44740a5e03b58e'
28             '94701f34fe5df4859c6a4d0459c16062374e8f89f4f51c414e71c9c2db14f61e087721e68dddb3e8d88bf1c097477c1a21e27ba4705fd07d88c60adb41acc1be'
29             'ce026b748df9b7597452a69c6cb04244a95bf99b00ea795d96d7d4ca5a68190af1b2dbf141dfd8e63bb4405131de81d8aa8a831ddde2595f1b859026b9fb0faa'
30             '7c1072a8cd5837095f857b50124cb45d1bdbddbce108f6f067a35c3c9ebb1ad0502ef617dfa10f9c843631220177a6286a97b1c2a46539200be72fa83cb23b99'
31             '64042ddf511b56b2a5a311e34643f4e049c09d909ea65b7343a8a9637f33dc59f2b1342201290ca0774cbcbf616096b3696982047fb622b7d51afb5eceb298dd')
33 prepare() {
34   cd $pkgbase-$pkgver
35   sed -i \
36     -e '/^LogFile=.*/d' \
37     -e 's/# LogType=file/LogType=system/' \
38     conf/zabbix_{agentd,proxy,server}.conf
40   autoreconf -fi
43 build() {
44   export GOPATH="$srcdir"/go
45   export AGENT_LDFLAGS="${LDFLAGS}"
47   _configure_flags=(
48     --disable-static
49     --prefix=/usr
50     --infodir=/usr/share/info
51     --mandir=/usr/share/man
52     --sysconfdir=/etc/zabbix
53     --enable-agent
54     --enable-agent2
55     --enable-ipv6
56     --with-ldap
57     --with-libcurl
58     --with-libxml2
59     --with-net-snmp
60     --with-openssl
61         --with-libpcre2
62     --with-ssh2
63     --with-unixodbc
64   )
66   cd $pkgbase-$pkgver
68   # Make copies since `make clean` removes the files and they cannot be rebuilt easily
69   for db in postgresql mysql sqlite3; do
70           mkdir -p ../copies/database/$db
71           cp database/$db/*.sql ../copies/database/$db/
72   done
74   for db in postgresql mysql; do
75     ./configure ${_configure_flags[@]} --enable-server --with-$db
76     make clean
77     make
78     mv src/zabbix_server/zabbix_server{,_$db}
79   done
81   for db in postgresql mysql sqlite3; do
82     ./configure ${_configure_flags[@]} --enable-proxy --with-$db
83     make clean
84     make
85     mv src/zabbix_proxy/zabbix_proxy{,_$db}
86   done
89 package_zabbix-server() {
90   pkgdesc='Monitoring software for networks and applications'
91   depends=(net-snmp curl libxml2 unixodbc libldap libevent pcre2)
92   optdepends=('postgresql-libs: for PostgreSQL support'
93               'mariadb-libs: for MariaDB support')
94   backup=(etc/zabbix/zabbix_server.conf)
95   install=zabbix-server.install
97   cd $pkgbase-$pkgver
99   for db in postgresql mysql; do
100     install -Dm755 src/zabbix_server/zabbix_server_$db \
101       "$pkgdir/usr/bin/zabbix_server_$db"
103     install -d "$pkgdir/usr/share/$pkgname/$db"
104     install -m644 ../copies/database/$db/*.sql -t "$pkgdir/usr/share/$pkgname/$db"
105   done
106   install -Dm755 src/zabbix_get/zabbix_get "$pkgdir/usr/bin/zabbix_get"
108   install -Dm644 man/zabbix_server.man "$pkgdir/usr/share/man/man8/zabbix_server.8"
109   install -Dm644 man/zabbix_get.man "$pkgdir/usr/share/man/man1/zabbix_get.1"
111   install -Dm644 conf/zabbix_server.conf "$pkgdir/etc/zabbix/zabbix_server.conf"
112   chown 170:170 "$pkgdir/etc/zabbix/zabbix_server.conf"
114   install -Dm644 "$srcdir/zabbix-server-pgsql.service" \
115     "$pkgdir/usr/lib/systemd/system/zabbix-server-pgsql.service"
116   install -Dm644 "$srcdir/zabbix-server-mysql.service" \
117     "$pkgdir/usr/lib/systemd/system/zabbix-server-mysql.service"
119   install -Dm644 "$srcdir/zabbix-server.sysusers" \
120         "$pkgdir/usr/lib/sysusers.d/zabbix-server.conf"
121   install -Dm644 "$srcdir/zabbix-server.tmpfiles" \
122         "$pkgdir/usr/lib/tmpfiles.d/zabbix-server.conf"
124   # Fix socket paths to avoid 10 day cleanup in /tmp
125   echo "d /run/$pkgname 750 $pkgname $pkgname" >> "$pkgdir/usr/lib/tmpfiles.d/$pkgname.conf"
126   sed -i \
127     -e "s/# SocketDir=\/tmp/SocketDir=\/run\/$pkgname/" \
128     "$pkgdir/etc/zabbix/"*.conf
131 package_zabbix-agent() {
132   pkgdesc='Monitoring agent for Zabbix'
133   depends=(curl pcre2)
134   backup=(etc/zabbix/zabbix_agentd.conf)
136   cd $pkgbase-$pkgver
137   install -Dm755 src/zabbix_agent/zabbix_agentd "$pkgdir/usr/bin/zabbix_agentd"
138   install -Dm755 src/zabbix_sender/zabbix_sender "$pkgdir/usr/bin/zabbix_sender"
140   install -Dm644 conf/zabbix_agentd.conf "$pkgdir/etc/zabbix/zabbix_agentd.conf"
141   chown 172:172 "$pkgdir/etc/zabbix/zabbix_agentd.conf"
143   install -Dm644 conf/zabbix_agentd/userparameter_examples.conf \
144         "$pkgdir/usr/share/zabbix-agent/userparameter_examples.conf"
145   install -Dm644 conf/zabbix_agentd/userparameter_mysql.conf \
146         "$pkgdir/usr/share/zabbix-agent/userparameter_mysql.conf"
148   install -Dm644 man/zabbix_agentd.man \
149         "$pkgdir/usr/share/man/man8/zabbix_agentd.8"
150   install -Dm644 man/zabbix_sender.man \
151         "$pkgdir/usr/share/man/man1/zabbix_sender.1"
153   install -Dm644 "$srcdir/zabbix-agent.service" \
154         "$pkgdir/usr/lib/systemd/system/zabbix-agent.service"
155   install -Dm644 "$srcdir/zabbix-agent.sysusers" \
156         "$pkgdir/usr/lib/sysusers.d/zabbix-agent.conf"
157   install -Dm644 "$srcdir/zabbix-agent.tmpfiles" \
158         "$pkgdir/usr/lib/tmpfiles.d/zabbix-agent.conf"
161 package_zabbix-agent2() {
162   pkgdesc='Experimental monitoring agent for Zabbix (Agent 2)'
163   depends=(zabbix-agent)
164   backup=(etc/zabbix/zabbix_agent2.conf)
166   cd $pkgbase-$pkgver
167   install -Dm755 src/go/bin/zabbix_agent2 "$pkgdir/usr/bin/zabbix_agent2"
168   install -Dm644 src/go/conf/zabbix_agent2.conf "$pkgdir/etc/zabbix/zabbix_agent2.conf"
169   chown 172:172 "$pkgdir/etc/zabbix/zabbix_agent2.conf"
170   mkdir -p "$pkgdir/etc/zabbix/zabbix_agent2.d/plugins.d/"
171   chown 172:172 "$pkgdir/etc/zabbix/zabbix_agent2.d/plugins.d/"
173   install -Dm644 man/zabbix_agent2.man \
174         "$pkgdir/usr/share/man/man8/zabbix_agent2.8"
176   install -Dm644 "$srcdir/zabbix-agent2.service" \
177         "$pkgdir/usr/lib/systemd/system/zabbix-agent2.service"
180 package_zabbix-proxy() {
181   pkgdesc='Data collecting proxy for Zabbix'
182   depends=(net-snmp curl libxml2 sqlite unixodbc libldap pcre2 libevent)
183   optdepends=('mariadb-libs: for MariaDB support'
184               'postgresql-libs: for PostgreSQL support')
185   backup=(etc/zabbix/zabbix_proxy.conf)
187   cd $pkgbase-$pkgver
188   for db in postgresql mysql sqlite3; do
189     install -Dm755 src/zabbix_proxy/zabbix_proxy_$db \
190       "$pkgdir/usr/bin/zabbix_proxy_$db"
192     install -d "$pkgdir/usr/share/$pkgname/$db"
193     install -m644 ../copies/database/$db/schema.sql -t "$pkgdir/usr/share/$pkgname/$db"
194   done
195   install -Dm644 conf/zabbix_proxy.conf "$pkgdir/etc/zabbix/zabbix_proxy.conf"
196   chown 171:171 "$pkgdir/etc/zabbix/zabbix_proxy.conf"
198   install -Dm644 "$srcdir/zabbix-proxy-sqlite.service" \
199     "$pkgdir/usr/lib/systemd/system/zabbix-proxy-sqlite.service"
200   install -Dm644 "$srcdir/zabbix-proxy-pgsql.service" \
201     "$pkgdir/usr/lib/systemd/system/zabbix-proxy-pgsql.service"
202   install -Dm644 "$srcdir/zabbix-proxy-mysql.service" \
203     "$pkgdir/usr/lib/systemd/system/zabbix-proxy-mysql.service"
205   install -Dm644 "$srcdir/zabbix-proxy.sysusers" \
206         "$pkgdir/usr/lib/sysusers.d/zabbix-proxy.conf"
207   install -Dm644 "$srcdir/zabbix-proxy.tmpfiles" \
208         "$pkgdir/usr/lib/tmpfiles.d/zabbix-proxy.conf"
210   # Fix socket paths to avoid 10 day cleanup in /tmp
211   echo "d /run/$pkgname 750 $pkgname $pkgname" >> "$pkgdir/usr/lib/tmpfiles.d/$pkgname.conf"
212   sed -i \
213     -e "s/# SocketDir=\/tmp/SocketDir=\/run\/$pkgname/" \
214     "$pkgdir/etc/zabbix/"*.conf
217 package_zabbix-frontend-php() {
218   pkgdesc='PHP frontend for Zabbix'
219   depends=(zabbix-server php php-gd)
221   cd $pkgbase-$pkgver
222   install -d "$pkgdir/usr/share/webapps/zabbix"
223   cp -a ui/* "$pkgdir/usr/share/webapps/zabbix"
224   chown 33:33 ${pkgdir}/usr/share/webapps/zabbix/conf/ # write access for http user