source: trunk/dports/net/zabbix/Portfile @ 136553

Last change on this file since 136553 was 136553, checked in by ryandesign@…, 4 years ago

zabbix: use expand operator instead of eval

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.2 KB
Line 
1# $Id: Portfile 136553 2015-05-21 19:40:16Z ryandesign@macports.org $
2
3PortSystem      1.0
4
5name                    zabbix
6version                 1.8.2
7categories              net
8license                 GPL-2+
9maintainers             nomaintainer
10platforms               darwin
11
12description             An open source application and network monitor
13
14long_description        ${description}
15
16homepage                http://www.zabbix.com/
17master_sites            sourceforge
18checksums               md5 fa4be4fa7ac20a33cc0aa5c27b827746
19patchfiles      patch-src-zabbix_server-poller-checks_snmp.c.diff
20depends_lib             port:fping \
21                        port:curl \
22                        port:openssl
23
24configure.args          --enable-server \
25                        --enable-agent \
26                        --with-net-snmp \
27                        --bindir=${prefix}/bin/zabbix \
28                        --sbindir=${prefix}/sbin/zabbix \
29                        --libexecdir=${prefix}/libexec/zabbix \
30                        --datadir=${prefix}/share/zabbix \
31                        --sysconfdir=${prefix}/etc/zabbix \
32                        --localstatedir=${prefix}/var/zabbix
33
34configure.ldflags-append        -lresolv
35
36if { [variant_isset agent_only] } {
37        startupitem.create      yes
38        startupitem.start       "${prefix}/share/zabbix/zabbix_agentd.init start"
39        startupitem.stop        "${prefix}/share/zabbix/zabbix_agentd.init stop"
40} else {
41        startupitem.create      yes
42        startupitem.start       "${prefix}/share/zabbix/zabbix_server.init start"
43        startupitem.stop        "${prefix}/share/zabbix/zabbix_server.init stop"
44}
45
46variant mysql5 conflicts pgsql81 pgsql82 pgsql83 pgsql84 sqlite3 \
47        description {Use MySQL 5.x for server database} {
48        depends_lib-append      path:bin/mysql_config5:mysql5
49        configure.args-append   --with-mysql=${prefix}/lib/mysql5/bin/mysql_config
50}
51
52variant pgsql81 conflicts mysql5 pgsql82 pgsql83 pgsql84 sqlite3 \
53        description {Use PostgreSQL 8.1.x for server database} {
54        depends_lib-append      port:postgresql81
55        configure.args-append   --with-pgsql=${prefix}/lib/postgresql81/bin/pg_config
56}
57
58variant pgsql82 conflicts mysql5 pgsql81 pgsql83 pgsql84 sqlite3 \
59        description {Use PostgreSQL 8.2.x for server database} {
60        depends_lib-append      port:postgresql82
61        configure.args-append   --with-pgsql=${prefix}/lib/postgresql82/bin/pg_config
62}
63
64variant pgsql83 conflicts mysql5 pgsql81 pgsql82 pgsql84 sqlite3 \
65        description {Use PostgreSQL 8.3.x for server database} {
66        depends_lib-append      port:postgresql83
67        configure.args-append   --with-pgsql=${prefix}/lib/postgresql83/bin/pg_config
68}
69
70variant pgsql84 conflicts mysql5 pgsql81 pgsql82 pgsql83 sqlite3 \
71        description {Use PostgreSQL 8.4.x for server database} {
72        depends_lib-append      port:postgresql84
73        configure.args-append   --with-pgsql=${prefix}/lib/postgresql84/bin/pg_config
74}
75
76variant sqlite3 conflicts mysql5 pgsql81 pgsql82 pgsql83 pgsql84 \
77        description {Use SQLite 3.x for server database} {
78        depends_lib-append      port:sqlite3
79        configure.args-append   --with-sqlite3=${prefix}
80}
81
82variant agent_only conflicts mysql5 pgsql81 pgsql82 pgsql83 pgsql84 sqlite3 \
83        description {Do not install the Zabbix server} {
84        depends_lib-delete      port:fping \
85                                port:curl \
86                                port:openssl
87
88        configure.args-delete   --enable-server \
89                                --with-net-snmp
90}
91
92if {![variant_isset pgsql81] && ![variant_isset pgsql82] && ![variant_isset pgsql83] && ![variant_isset pgsql84] && ![variant_isset sqlite3] && ![variant_isset agent_only]} {
93        default_variants +mysql5
94}
95
96post-patch {
97        reinplace "s|#DBSocket=/tmp/mysql.sock|DBSocket=${prefix}/var/run/mysql5/mysqld.sock|g" \
98                ${worksrcpath}/misc/conf/zabbix_server.conf
99
100        reinplace "s|#FpingLocation=/usr/sbin/fping|FpingLocation=${prefix}/sbin/fping|g" \
101                ${worksrcpath}/misc/conf/zabbix_server.conf
102}
103
104pre-destroot {
105        adduser zabbix
106        addgroup zabbix
107}
108
109post-destroot {
110
111if { [variant_isset agent_only] } {
112# Don't install MySQL data and frontend stuff for agent_only
113
114# Copy sample agent .conf files
115        xinstall -d -m 755 -d ${destroot}${prefix}/etc/zabbix
116        xinstall -m 755  ${worksrcpath}/misc/conf/zabbix_agent.conf \
117                ${destroot}${prefix}/etc/zabbix/zabbix_agent.conf.sample
118        xinstall -m 755  ${worksrcpath}/misc/conf/zabbix_agentd.conf \
119                ${destroot}${prefix}/etc/zabbix/zabbix_agentd.conf.sample
120
121# Copy a startup script for the agent
122                xinstall -d -m 755 -d ${destroot}${prefix}/share/zabbix
123                xinstall -m 755 ${portpath}/${filesdir}/zabbix_agentd.init \
124                        ${destroot}${prefix}/share/zabbix
125                reinplace "s|__PREFIX__|${prefix}|g" \
126                ${destroot}${prefix}/share/zabbix/zabbix_agentd.init
127} else {
128
129# Copy sample server and agent .conf files
130        xinstall -d -m 755 -d ${destroot}${prefix}/etc/zabbix
131        xinstall -m 755 ${worksrcpath}/misc/conf/zabbix_agent.conf \
132                ${destroot}${prefix}/etc/zabbix/zabbix_agent.conf.sample
133        xinstall -m 755 ${worksrcpath}/misc/conf/zabbix_agentd.conf \
134                ${destroot}${prefix}/etc/zabbix/zabbix_agentd.conf.sample
135        xinstall -m 755 ${worksrcpath}/misc/conf/zabbix_server.conf \
136                ${destroot}${prefix}/etc/zabbix/zabbix_server.conf.sample
137
138# Copy database data and schemas
139        xinstall -d -m 755 -d ${destroot}${prefix}/share/zabbix/data
140        xinstall -d -m 755 -d ${destroot}${prefix}/share/zabbix/schema
141
142        xinstall -m 755 {*}[glob ${worksrcpath}/create/data/*.*] \
143                ${destroot}${prefix}/share/zabbix/data
144        xinstall -m 755 {*}[glob ${worksrcpath}/create/schema/*] \
145                ${destroot}${prefix}/share/zabbix/schema
146
147# Copy the front end files
148
149        file mkdir ${destroot}${prefix}/share/zabbix/frontends/
150        file copy ${worksrcpath}/frontends/php/ \
151                ${destroot}${prefix}/share/zabbix/frontends/
152
153# Create a startup script for the server
154                xinstall -m 755 ${portpath}/${filesdir}/zabbix_server.init \
155                        ${destroot}${prefix}/share/zabbix
156                reinplace "s|__PREFIX__|${prefix}|g" \
157                ${destroot}${prefix}/share/zabbix/zabbix_server.init
158
159# Create a startup script for the agent
160                xinstall -m 755 ${portpath}/${filesdir}/zabbix_agentd.init \
161                        ${destroot}${prefix}/share/zabbix
162                reinplace "s|__PREFIX__|${prefix}|g" \
163            ${destroot}${prefix}/share/zabbix/zabbix_agentd.init
164
165# Set permissions for etc (protect passwords) and the frontend
166                system "chmod 660 ${destroot}${prefix}/etc/zabbix/*"
167                system "chown zabbix:zabbix ${destroot}${prefix}/etc/zabbix/*"
168                system "chown -R www:www ${destroot}${prefix}/share/zabbix/frontends/*"
169
170# End else clause - Done with server stuff
171}
172
173# Copy Win32 agent for normal and agent_only installs
174                xinstall -d -m 755 -d ${destroot}${prefix}/share/zabbix/zabbix_agent_win32
175                xinstall -m 755 ${worksrcpath}/bin/win32/zabbix_agentd.exe \
176                        ${destroot}${prefix}/share/zabbix/zabbix_agent_win32
177}
178
179
180notes "
181#### ZABBIX agent installation section (steps 1 - 3 only) ####
182
1831) Edit the sample .conf file ${prefix}/etc/zabbix/zabbix_agentd.conf (rename & omit .sample)
184
185   Set the following variable to the ip address of your ZABBIX server to\
186   allow it access to the agent.
187
188        Server=x.x.x.x
189
190
1912) Set zabbix_agentd to run at system boot
192
193        sudo launchctl load -w /Library/LaunchDaemons/org.macports.zabbix.plist
194
195   To start Zabbix manually, use: ${prefix}/share/zabbix/zabbix_agentd.init start (stop|status)
196
197
1983) A Win32 agent is in ${prefix}/share/zabbix/zabbix_agent_win32 for\
199   installation on Windows NT 4.0, Windows 2000, and Windows XP.
200
201
202#### End ZABBIX agent installation section ####
203####                                       ####
204
205
206####                                          ####
207#### Begin ZABBIX server installation section ####
208
209
2101) Setup MySQL, i.e. via MacPorts:
211
212        sudo port install mysql5-server
213
214
2152) Setup the ZABBIX MySQL database
216
217-Create the ZABBIX database
218        mysql5 -u root -p (enter password at prompt)
219        mysql> create database zabbix character set utf8;
220        mysql> quit;
221
222-Import the ZABBIX Schema
223        cd ${prefix}/share/zabbix/schema
224        cat mysql.sql | mysql5 -u root -p zabbix
225        cd ${prefix}/share/zabbix/data
226        cat data.sql | mysql5 -u root -p zabbix
227        cat images_mysql.sql | mysql5 -u root -p zabbix
228
229-Create a MySQL 'zabbix' user and password
230        mysql5 -u root -p
231        mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '<zabbix-mysql-password>';
232        mysql> grant all privileges on zabbix.* to zabbix identified by '<zabbix-mysql-password>';
233        mysql> quit;
234
235
2363) Edit the sample .conf file ${prefix}/etc/zabbix/zabbix_server.conf (rename & omit .sample)
237
238   Modify these variables at the very least:
239
240        DBName=zabbix
241        DBUser=zabbix
242        DBPassword=<zabbix-mysql-password>
243
244
2454) Install PHP 5, i.e. via MacPorts:
246
247        sudo port install php5 php5-gd php5-mbstring php5-mysql php5-sockets
248
249
2505) Set a symbolic link in your Apache document root pointing to the PHP frontend files
251
252        sudo ln -s ${prefix}/share/zabbix/frontends/php <Apache-docroot>/zabbix
253
254
2556) Set zabbix_server to run at system boot, then start it
256
257        sudo launchctl load -w /Library/LaunchDaemons/org.macports.zabbix.plist
258
259   To start Zabbix manually, use: ${prefix}/share/zabbix/zabbix_server.init start (stop|status)
260
261        Note: Eventually your shared memory has to be increased (see http://www.zabbix.org/forum/showthread.php?p=64232)!
262
263
2647) A Win32 agent is in ${prefix}/share/zabbix/zabbix_agent_win32 for\
265   installation on Windows NT 4.0, Windows 2000, and Windows XP.  See\
266   the ReadMe.txt for instructions.
267
268
2698) Open http://localhost/zabbix/ in your browser and walk through the setup, then login with default user 'Admin' and password 'zabbix'.
270
271
2729) Read the fine manual at http://www.zabbix.com/documentation/
273"
Note: See TracBrowser for help on using the repository browser.