source: trunk/dports/net/zabbix2/Portfile

Last change on this file was 148042, checked in by eborisch@…, 15 months ago

zabbix2: Update to 2.4.8.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 14.8 KB
Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2# $Id: Portfile 148042 2016-04-25 15:16:01Z ryandesign@macports.org $
3
4PortSystem          1.0
5
6name                zabbix2
7version             2.4.8
8revision            0
9categories          net
10maintainers         eborisch openmaintainer
11platforms           darwin
12
13license             GPL-2
14
15description         An open source application and network monitor
16
17long_description    Zabbix is the ultimate open source availability and \
18                    performance monitoring solution. Zabbix offers advanced \
19                    monitoring, alerting, and visualization features today \
20                    which are missing in other monitoring systems, even some \
21                    of the best commercial ones.
22
23distname            zabbix-${version}
24livecheck.name      zabbix
25livecheck.regex     "Stable\/(2\[0-9.\]+)\/"
26livecheck.url \
27    http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/
28homepage            http://www.zabbix.com/
29master_sites \
30    sourceforge:project/zabbix/ZABBIX%20Latest%20Stable/${version} \
31    sourceforge:project/zabbix/ZABBIX%20Release%20Candidates/${version}
32dist_subdir         zabbix2
33
34checksums \
35    rmd160  0078605b890a2aefa575cdf6f7d13d7191099033 \
36    sha256  073f7498ff7c07e51f3395dbd850b375144d6a41388409d898bb2826b0a3e1f0
37
38universal_variant   no
39
40conflicts           zabbix
41
42subport             zabbix2-agent {}
43
44configure.args      --bindir=${prefix}/bin/zabbix \
45                    --sbindir=${prefix}/sbin/zabbix \
46                    --libexecdir=${prefix}/libexec/zabbix \
47                    --datadir=${prefix}/share/zabbix \
48                    --sysconfdir=${prefix}/etc/zabbix \
49                    --localstatedir=${prefix}/var/zabbix
50
51configure.ldflags-append    -lresolv
52
53startupitem.create      yes
54
55depends_lib-append      port:libiconv
56
57if { ${name} ne ${subport} } {
58    startupitem.name        zabbix2-agentd
59    startupitem.executable  \
60        ${prefix}/sbin/zabbix/zabbix_agentd \
61        -c ${prefix}/etc/zabbix/zabbix_agentd.conf
62    startupitem.pidfile     clean /tmp/zabbix_agentd.pid
63
64    configure.args-append   --enable-agent
65} else {
66    depends_lib-append      port:curl \
67                            port:libssh2 \
68                            port:net-snmp \
69                            port:OpenIPMI
70    depends_run-append      port:fping \
71                            port:apache2
72
73    foreach php {php56 php70} {
74        eval [subst {
75            variant ${php} description "Use ${php}" {
76                depends_run-append      port:${php} \
77                                        port:${php}-apache2handler \
78                                        port:${php}-gd \
79                                        port:${php}-gettext \
80                                        port:${php}-mbstring \
81                                        port:${php}-sockets
82            }
83        }]
84    }
85
86    if {![variant_isset php56] &&
87        ![variant_isset php70]} {
88        default_variants    +php56
89    }
90
91    configure.args-append   --enable-server \
92                            --with-libcurl=${prefix}/bin/curl-config \
93                            --with-net-snmp \
94                            --with-openipmi=${prefix} \
95                            --with-ssh2=${prefix}
96
97    startupitem.name        zabbix2-server
98    startupitem.start       "${prefix}/share/zabbix/zabbix_server.init start"
99    startupitem.stop        "${prefix}/share/zabbix/zabbix_server.init stop"
100
101    variant full_server description {
102        Adds dependencies a complete server are installed.
103    } {
104    }
105
106    # Items are "display name" "port name" "config arg" "php interface"
107    array set DBLIST {
108        mysql5  {"MySQL 5.x"            mysql5 \
109                 mysql=${prefix}/lib/mysql5/bin/mysql_config mysql}
110        mysql51 {"MySQL 5.1"            mysql51 \
111                 mysql=${prefix}/lib/mysql51/bin/mysql_config mysql}
112        mysql55 {"MySQL 5.5"            mysql55 \
113                 mysql=${prefix}/lib/mysql55/bin/mysql_config mysql}
114        mysql56 {"MySQL 5.6"            mysql56 \
115                 mysql=${prefix}/lib/mysql56/bin/mysql_config mysql}
116        mariadb {"MariaDB"              mariadb \
117                 mysql=${prefix}/lib/mariadb/bin/mysql_config mysql}
118        percona {"Percona"              percona \
119                 mysql=${prefix}/lib/percona/bin/mysql_config mysql}
120        pgsql84 {"PostgreSQL 8.4.x"     postgresql84 \
121                 postgresql=${prefix}/lib/postgresql84/bin/pg_config postgresql}
122        pgsql95 {"PostgreSQL 9.5.x"     postgresql95 \
123                 postgresql=${prefix}/lib/postgresql95/bin/pg_config postgresql}
124        sqlite3 {"SQLite 3.x"           sqlite3 \
125                 sqlite3=${prefix} sqlite}
126    }
127
128    set DBLIST_KEYS [lsort [array names DBLIST]]
129   
130    foreach dbitem $DBLIST_KEYS {
131        set this_key [lsearch -exact $DBLIST_KEYS $dbitem]
132        set conf_list [lreplace $DBLIST_KEYS $this_key $this_key]
133        set prms $DBLIST($dbitem)
134       
135        set variant_line {variant $dbitem description \
136          "Use [lindex ${prms} 0] for server database" }
137
138        foreach over ${conf_list} {
139            append variant_line " conflicts ${over}"
140        }
141
142        append variant_line { "
143            set ::ZDB               [lindex ${prms} 1]
144            set ::MYSQL_MODE        [string equal [lindex ${prms} 3] mysql]
145            depends_lib-append      port:[lindex ${prms} 1]
146            configure.args-append   --with-[lindex ${prms} 2]
147
148            if {[variant_isset php56]} {
149                depends_run-append port:php56-[lindex ${prms} 3] }
150
151            if {[variant_isset php70]} {
152                depends_run-append port:php70-[lindex ${prms} 3] }
153
154            if {[string compare ${dbitem} sqlite3] && \
155                 [variant_isset full_server]} {
156                depends_run-append \
157                    port:[lindex ${prms} 1]-server
158            }
159        " }
160
161        eval $variant_line
162    }
163
164    if {![variant_isset mysql51] &&
165        ![variant_isset mysql55] &&
166        ![variant_isset mysql56] &&
167        ![variant_isset mariadb] &&
168        ![variant_isset percona] &&
169        ![variant_isset pgsql84] &&
170        ![variant_isset pgsql95] &&
171        ![variant_isset sqlite3]} {
172        default_variants            +mysql5
173    }
174
175    variant date_slash description {
176        Draw month/day rather than day.month on line graphs.
177    } {}
178}
179
180post-extract {
181    if { ${name} == ${subport} } {
182        if { ${MYSQL_MODE} == 1 &&
183             [variant_isset full_server] } {
184                set repstr "s|# DBSocket=/tmp/mysql.sock|"
185                append repstr "DBSocket=${prefix}/var/run/${ZDB}/mysqld.sock|"
186            reinplace ${repstr} ${worksrcpath}/conf/zabbix_server.conf
187        }
188
189        if {[variant_isset date_slash]} {
190            reinplace -E {s|[[:<:]]d\.m[[:>:]]|m/d|g} \
191                frontends/php/include/classes/graphdraw/CLineGraphDraw.php
192        }
193    }
194    set repstr "s|# FpingLocation=/usr/sbin/fping|"
195    append repstr "FpingLocation=${prefix}/sbin/fping|"
196    reinplace ${repstr} ${worksrcpath}/conf/zabbix_server.conf
197}
198
199add_users zabbix group=zabbix
200
201post-destroot {
202    if { ${name} ne ${subport} } {
203     ####### AGENT #######
204# Copy sample agent .conf files
205        xinstall -d -m 755 -d ${destroot}${prefix}/etc/zabbix
206        xinstall -m 755  ${worksrcpath}/conf/zabbix_agent.conf \
207            ${destroot}${prefix}/etc/zabbix/zabbix_agent.conf.sample
208        xinstall -m 755  ${worksrcpath}/conf/zabbix_agentd.conf \
209            ${destroot}${prefix}/etc/zabbix/zabbix_agentd.conf.sample
210
211# Don't overwrite user settings on each install
212        delete ${destroot}${prefix}/etc/zabbix/zabbix_agentd.conf
213        delete ${destroot}${prefix}/etc/zabbix/zabbix_agent.conf
214    } else {
215     ####### SERVER #######
216# Copy sample server and agent .conf files
217        xinstall -d -m 755 -d ${destroot}${prefix}/etc/zabbix
218        xinstall -m 755 ${worksrcpath}/conf/zabbix_server.conf \
219            ${destroot}${prefix}/etc/zabbix/zabbix_server.conf.sample
220
221# Don't overwrite user settings on each install
222        delete ${destroot}${prefix}/etc/zabbix/zabbix_server.conf
223
224# Copy database data and schemas
225        xinstall -d -m 755 -d ${destroot}${prefix}/share/zabbix/data
226        xinstall -d -m 755 -d ${destroot}${prefix}/share/zabbix/schema
227
228        eval xinstall -m 755 ${worksrcpath}/database/mysql/data.sql \
229            ${destroot}${prefix}/share/zabbix/data
230        eval xinstall -m 755 ${worksrcpath}/database/mysql/images.sql \
231            ${destroot}${prefix}/share/zabbix/data
232        eval xinstall -m 755 ${worksrcpath}/database/mysql/schema.sql \
233            ${destroot}${prefix}/share/zabbix/schema
234
235        file copy ${worksrcpath}/upgrades \
236            ${destroot}${prefix}/share/zabbix/
237
238# Copy the front end files
239        file mkdir ${destroot}${prefix}/share/zabbix/frontends/
240        file copy ${worksrcpath}/frontends/php/ \
241            ${destroot}${prefix}/share/zabbix/frontends/
242
243# Create a startup script for the server
244# This script has a delay built into it (waiting for DB to start) so we
245# don't use a simple startupitem.executable approach
246        if { ${MYSQL_MODE} == 1 } {
247            xinstall -m 755 ${portpath}/${filesdir}/zabbix_server.init.mysql \
248                ${destroot}${prefix}/share/zabbix/zabbix_server.init
249            reinplace "s|__VER__|${ZDB}|g" \
250                ${destroot}${prefix}/share/zabbix/zabbix_server.init
251            if {[variant_isset full_server]} {
252                reinplace "s/^#%#//" \
253                    ${destroot}${prefix}/share/zabbix/zabbix_server.init
254            }
255        } else {
256            xinstall -m 755 ${portpath}/${filesdir}/zabbix_server.init \
257                ${destroot}${prefix}/share/zabbix
258        }
259        reinplace "s|__PREFIX__|${prefix}|g" \
260            ${destroot}${prefix}/share/zabbix/zabbix_server.init
261
262# Set permissions for etc (protect passwords) and the frontend
263        system "chmod 660 ${destroot}${prefix}/etc/zabbix/*"
264        system "chown zabbix:zabbix ${destroot}${prefix}/etc/zabbix/*"
265        system "chown -R www:www ${destroot}${prefix}/share/zabbix/frontends/*"
266
267        xinstall -d -m 755 -d \
268            ${destroot}${prefix}/share/zabbix/zabbix_agent_win32
269        xinstall -m 755 ${worksrcpath}/bin/win32/zabbix_agentd.exe \
270            ${destroot}${prefix}/share/zabbix/zabbix_agent_win32
271    }
272}
273
274if { ${name} ne ${subport} } {
275    notes "
276####                                        ####
277#### ZABBIX2 agent installation section     ####
278
2791) Edit the sample .conf file ${prefix}/etc/zabbix/zabbix_agentd.conf.sample
280   (rename & omit .sample)
281
282   Set the following variable to the ip address of your ZABBIX server to\
283   allow it access to the agent.
284
285    Server=x.x.x.x
286
287
2882) Set zabbix_agentd to run at system boot
289
290     sudo port load zabbix2-agent
291
2923) A Win32 agent is in ${prefix}/share/zabbix/zabbix_agent_win32 for\
293   installation on Windows NT 4.0, Windows 2000, and Windows XP.
294
295#### End ZABBIX2 agent installation section ####
296####                                        ####
297"
298} else {
299    notes "
300####                                                 ####
301#### Begin ZABBIX2 local server installation section ####
302
303 (Installing with +full_server will add all of the dependants; configuration
304  will still be required.)
305
3061) Setup MySQL, i.e. via MacPorts: (for local MySQL server)
307
308    sudo port install mysql5-server
309
310
3112) Setup the ZABBIX MySQL database
312
313 For other databases, follow documentation from
314 https://www.zabbix.com/documentation/2.4/manual/appendix/install/db_scripts
315
316-Create the ZABBIX database
317    mysql5 -u root -p (enter password at prompt)
318    mysql> create database zabbix character set utf8;
319    mysql> quit;
320
321-Import the ZABBIX Schema
322    cd ${prefix}/share/zabbix/schema
323    cat mysql.sql | mysql5 -u root -p zabbix
324    cd ${prefix}/share/zabbix/data
325    cat images.sql | mysql5 -u root -p zabbix
326    cat data.sql | mysql5 -u root -p zabbix
327
328-Create a MySQL 'zabbix' user and password
329    mysql5 -u root -p
330    mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '<zabbix-mysql-password>';
331    mysql> grant all privileges on zabbix.* to zabbix identified by '<zabbix-mysql-password>';
332    mysql> quit;
333
334
3353) Edit the sample .conf file ${prefix}/etc/zabbix/zabbix_server.conf
336   (rename & omit .sample)
337
338   Modify these variables at the very least:
339
340    DBName=zabbix
341    DBUser=zabbix
342    DBPassword=<zabbix-mysql-password>
343    DBSocket=<location for your active mysql5\[15\] server socket>
344      Typically ${prefix}/var/run/mysql\[51|55\]/mysqld.sock
345
346
3474) Set a symbolic link in your Apache document root pointing to the PHP
348   frontend files. Note that the phpNN variants only add the dependencies; it
349   is up to you to enable your desired version in httpd.conf.
350
351    sudo ln -s ${prefix}/share/zabbix/frontends/php <Apache-docroot>/zabbix
352
353
3545) Set zabbix_server to run at system boot, then start it
355
356    sudo port load zabbix2
357
358   To start Zabbix manually, use:
359    ${prefix}/share/zabbix/zabbix_server.init start (stop|status)
360
361 !! Note: Your shared memory will likely need to be increased  !!
362 !!       (see http://support.apple.com/kb/HT4022)             !!
363
364
3656) A Win32 agent is in ${prefix}/share/zabbix/zabbix_agent_win32 for\
366   installation on Windows NT 4.0, Windows 2000, and Windows XP.  See\
367   the ReadMe.txt for instructions.
368
369
3707) Open http://localhost/zabbix/ in your browser and walk through the setup,
371   then login with default user 'Admin' and password 'zabbix'.
372
373
3748) Read the fine manual at http://www.zabbix.com/documentation/
375
376
377#### End ZABBIX2 local server installation section   ####
378####                                                 ####
379
380
381!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
382!! ZABBIX -> ZABBIX2 Server Upgrade process !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
383!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
384!!  0) BACK UP YOUR DATABASE                                              !!
385!!                                                                        !!
386!!  1) Be sure to use 'sudo port unload zabbix' to stop the background    !!
387!!     server before deactivating zabbix, and then use                    !!
388!!     'sudo port load zabbix2' **AFTER UPGRADING THE DATABASE** as       !!
389!!     described below.                                                   !!
390!!                                                                        !!
391!!  2) For upgrading from 1.8 (zabbix -> zabbix2), upgrade scripts are    !!
392!!     located in ${prefix}/share/zabbix/upgrades                        !!
393!!                                                                        !!
394!!  For upgrade procedure, please see                                     !!
395!!    http://www.zabbix.com/documentation/2.0/manual/installation/upgrade !!
396!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
397!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
398"
399}
Note: See TracBrowser for help on using the repository browser.