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

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

rewrite mysql5 dependency so mysql5-devel can satisfy it

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.1 KB
Line 
1# $Id: Portfile 58230 2009-09-24 16:45:22Z ryandesign@macports.org $
2
3PortSystem      1.0
4
5name                    zabbix
6version                 1.6.2
7categories              net
8maintainers             markd openmaintainer
9platforms               darwin
10
11description             An open source application and network monitor
12
13long_description        ${description}
14
15homepage                http://www.zabbix.com
16master_sites            sourceforge
17checksums               md5 33da3661868a04042c596a819896446f
18patchfiles              patch-include-common.h
19default_variants        +server
20depends_lib             path:bin/mysql_config5:mysql5 \
21                                port:fping
22
23configure.pre_args     --prefix=${prefix}
24
25configure.args          --enable-server \
26                        --enable-agent \
27                        --with-net-snmp \
28                        --bindir=${prefix}/bin/zabbix \
29                        --sbindir=${prefix}/sbin/zabbix \
30                        --libexecdir=${prefix}/libexec/zabbix \
31                        --datadir=${prefix}/share/zabbix \
32                        --sysconfdir=${prefix}/etc/zabbix \
33                        --localstatedir=${prefix}/var/zabbix \
34                        --mandir=${prefix}/man \
35                        --with-mysql=${prefix}/lib/mysql5/bin/mysql_config
36
37configure.ldflags-append        -lresolv
38
39if { [variant_isset agent_only] } {
40        startupitem.create      yes
41        startupitem.start       "${prefix}/share/zabbix/zabbix_agentd.init start"
42        startupitem.stop        "${prefix}/share/zabbix/zabbix_agentd.init stop"
43} else {
44        startupitem.create      yes
45        startupitem.start       "${prefix}/share/zabbix/zabbix_server.init start"
46        startupitem.stop        "${prefix}/share/zabbix/zabbix_server.init stop"
47}
48
49variant server  \
50    description {Dummy variant} {
51# This variant doesn't do anything in this port.  Its only purpose is to trigger the server
52# variant in the mysql5 port.
53}
54
55variant pgsql81 \
56        description {Use PostgreSQL 8.1.x for server database} {
57        depends_lib-delete      path:bin/mysql_config5:mysql5
58        depends_lib-append      port:postgresql81
59        configure.args-delete   --with-mysql=${prefix}/lib/mysql5/bin/mysql_config
60        configure.args-append   --with-pgsql=${prefix}/lib/postgresql81/bin/pg_config
61}
62
63variant pgsql82 \
64        description {Use PostgreSQL 8.2.x for server database} {
65        depends_lib-delete      path:bin/mysql_config5:mysql5
66        depends_lib-append      port:postgresql82
67        configure.args-delete   --with-mysql=${prefix}/lib/mysql5/bin/mysql_config
68        configure.args-append   --with-pgsql=${prefix}/lib/postgresql82/bin/pg_config
69}
70
71variant pgsql83 \
72        description {Use PostgreSQL 8.3.x for server database} {
73        depends_lib-delete      path:bin/mysql_config5:mysql5
74        depends_lib-append      port:postgresql83
75        configure.args-delete   --with-mysql=${prefix}/lib/mysql5/bin/mysql_config
76        configure.args-append   --with-pgsql=${prefix}/lib/postgresql83/bin/pg_config
77}
78
79variant sqlite3 \
80        description {Use SQLite3 for server database} {
81        depends_lib-delete      path:bin/mysql_config5:mysql5
82        depends_lib-append      port:sqlite3
83        configure.args-delete   --with-mysql=${prefix}/lib/mysql5/bin/mysql_config
84        configure.args-append   --with-sqlite3=${prefix}/lib
85}
86
87variant agent_only \
88        description {Do not install the Zabbix server} {
89        depends_lib-delete      path:bin/mysql_config5:mysql5 \
90                                port:fping
91
92        configure.args-delete   --enable-server \
93                                --with-mysql=${prefix}/lib/mysql5/bin/mysql_config \
94                                --with-net-snmp
95}
96
97build {}
98
99post-patch {
100        reinplace "s|#DBSocket=/tmp/mysql.sock|DBSocket=${prefix}/var/run/mysql5/mysqld.sock|g" \
101                ${worksrcpath}/misc/conf/zabbix_server.conf
102
103        reinplace "s|#FpingLocation=/usr/sbin/fping|FpingLocation=${prefix}/sbin/fping|g" \
104                ${worksrcpath}/misc/conf/zabbix_server.conf
105}
106
107pre-destroot {
108        adduser zabbix
109        addgroup zabbix
110}
111
112post-destroot {
113
114if { [variant_isset agent_only] } {
115# Don't install MySQL data and frontend stuff for agent_only
116
117# Copy sample agent .conf files
118        xinstall -d -m 755 -d ${destroot}${prefix}/etc/zabbix
119        xinstall -m 755  ${worksrcpath}/misc/conf/zabbix_agent.conf \
120                ${destroot}${prefix}/etc/zabbix/zabbix_agent.conf.sample
121        xinstall -m 755  ${worksrcpath}/misc/conf/zabbix_agentd.conf \
122                ${destroot}${prefix}/etc/zabbix/zabbix_agentd.conf.sample
123
124# Copy a startup script for the agent
125                xinstall -d -m 755 -d ${destroot}${prefix}/share/zabbix
126                xinstall -m 755 ${portpath}/${filesdir}/zabbix_agentd.init \
127                        ${destroot}${prefix}/share/zabbix
128                reinplace "s|__PREFIX__|${prefix}|g" \
129                ${destroot}${prefix}/share/zabbix/zabbix_agentd.init
130} else {
131
132# Copy sample server and agent .conf files
133        xinstall -d -m 755 -d ${destroot}${prefix}/etc/zabbix
134        xinstall -m 755 ${worksrcpath}/misc/conf/zabbix_agent.conf \
135                ${destroot}${prefix}/etc/zabbix/zabbix_agent.conf.sample
136        xinstall -m 755 ${worksrcpath}/misc/conf/zabbix_agentd.conf \
137                ${destroot}${prefix}/etc/zabbix/zabbix_agentd.conf.sample
138        xinstall -m 755 ${worksrcpath}/misc/conf/zabbix_server.conf \
139                ${destroot}${prefix}/etc/zabbix/zabbix_server.conf.sample
140
141# Copy database data and schemas
142        xinstall -d -m 755 -d ${destroot}${prefix}/share/zabbix/data
143        xinstall -d -m 755 -d ${destroot}${prefix}/share/zabbix/schema
144
145        eval xinstall -m 755 [glob ${worksrcpath}/create/data/*.*] \
146                ${destroot}${prefix}/share/zabbix/data
147        eval xinstall -m 755 [glob ${worksrcpath}/create/schema/*] \
148                ${destroot}${prefix}/share/zabbix/schema
149
150# Copy the front end files
151
152        file mkdir ${destroot}${prefix}/share/zabbix/frontends/
153        file copy ${worksrcpath}/frontends/php/ \
154                ${destroot}${prefix}/share/zabbix/frontends/
155
156# Create a startup script for the server
157                xinstall -m 755 ${portpath}/${filesdir}/zabbix_server.init \
158                        ${destroot}${prefix}/share/zabbix
159                reinplace "s|__PREFIX__|${prefix}|g" \
160                ${destroot}${prefix}/share/zabbix/zabbix_server.init
161
162# Create a startup script for the agent
163                xinstall -m 755 ${portpath}/${filesdir}/zabbix_agentd.init \
164                        ${destroot}${prefix}/share/zabbix
165                reinplace "s|__PREFIX__|${prefix}|g" \
166            ${destroot}${prefix}/share/zabbix/zabbix_agentd.init
167
168# Set permissions for etc (protect passwords) and the frontend
169                system "chmod 660 ${destroot}${prefix}/etc/zabbix/*"
170                system "chown zabbix:zabbix ${destroot}${prefix}/etc/zabbix/*"
171                system "chown -R www:www ${destroot}${prefix}/share/zabbix/frontends/*"
172
173# End else clause - Done with server stuff
174}
175
176# Copy Win32 agent for normal and agent_only installs
177                xinstall -d -m 755 -d ${destroot}${prefix}/share/zabbix/zabbix_agent_win32
178                xinstall -m 755 ${worksrcpath}/bin/win32/zabbix_agentd.exe \
179                        ${destroot}${prefix}/share/zabbix/zabbix_agent_win32
180}
181
182post-activate {
183
184if { [variant_isset agent_only] } {
185
186ui_msg "\n#### To complete the ZABBIX agent installation ####
187
188
1891) Edit the sample .conf file ${prefix}/etc/zabbix/zabbix_agentd.conf (rename & omit .sample)
190
191   Set the following variable to the ip address of your ZABBIX server to
192   allow it access to the agent.
193
194        Server=x.x.x.x
195
196
1972) Set zabbix_agentd to run at system boot
198
199        OS X 10.4 and up - Run launchctl so ZABBIX will start at system boot
200        sudo launchctl load -w /Library/LaunchDaemons/org.macports.zabbix.plist
201
202        OS X 10.3 and previous - A startup item was created in /Library/StartupItems
203        Add \"ZABBIX=-YES-\" to the /etc/hostconfig file to run ZABBIX at system boot
204
205   To start Zabbix manually, use: ${prefix}/share/zabbix/zabbix_agentd.init start (stop|status)
206
207
2083) A Win32 agent is in ${prefix}/share/zabbix/zabbix_agent_win32 for
209   installation on Windows NT 4.0, Windows 2000, and Windows XP.
210
211
212\n"
213
214} else {
215
216ui_msg "\n#### To complete the ZABBIX installation ####
217
218
2191) Setup MySQL (for new MySQL installs)
220
221-Configure MySQL:
222        sudo -u mysql ${prefix}/lib/mysql5/bin/mysql_install_db
223
224-Start MySQL and set it to run at system boot:
225        sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
226
227   NOTE: MySQL must have been installed with the +server variant in order to
228      use launchctl.
229
230-Set a root MySQL password
231   Follow the instructions that were given after you executed 'mysql_install_db' above
232
233
2342) Setup the ZABBIX MySQL database
235
236-Create the ZABBIX database
237        mysql5 -u root -p (enter password at prompt)
238        mysql> create database zabbix;
239        mysql> exit;
240
241-Import the ZABBIX Schema
242        cd ${prefix}/share/zabbix/schema
243        cat mysql.sql | mysql5 -u root -p zabbix
244        cd ${prefix}/share/zabbix/data
245        cat data.sql | mysql5 -u root -p zabbix
246        cat images_mysql.sql | mysql5 -u root -p zabbix
247
248-Create a MySQL 'zabbix' user and password
249        mysql5 -u root -p
250        mysql> grant SELECT, INSERT, UPDATE, DELETE, CREATE on zabbix.* to zabbix@localhost;
251        mysql> grant SELECT, INSERT, UPDATE, DELETE, CREATE on zabbix.* to zabbix;
252        mysql> set PASSWORD FOR zabbix@localhost = OLD_PASSWORD('zabbix-db-password');
253
254NOTE: ZABBIX uses MySQL old-style password hashes so the OLD_PASSWORD keyword is necessary
255
2563) Edit the sample .conf file ${prefix}/etc/zabbix/zabbix_server.conf (rename & omit .sample)
257
258   Modify these variables at the very least:
259
260        DBName=zabbix
261        DBUser=zabbix
262        DBPassword=<zabbix-mysql-password>
263
264
2654) Install PHP 4 or 5 (not covered)
266
267   Set mysql.default_socket path to ${prefix}/var/run/mysql5/mysqld.sock in this PHP file:
268
269        ./phpx/lib/php.ini (in /usr/local, ${prefix}, or /Library depending on PHP package)
270
271   Modify the variables below in this Zabbix file:
272        ${prefix}/share/zabbix/frontends/php/include/db.inc.php
273
274        \$DB_USER        =\"zabbix\";
275        \$DB_PASSWORD    =\"mysql-zabbix-password\";
276
277
2785) Set a symbolic link in your Apache document root pointing to the PHP frontend files
279
280        sudo ln -s ${prefix}/share/zabbix/frontends/php <Apache-docroot>/zabbix
281
282
2836) Set zabbix_server to run at system boot, then start it
284
285   OS X 10.4 - Run launchctl so ZABBIX will start at system boot
286        sudo launchctl load -w /Library/LaunchDaemons/org.macports.zabbix.plist
287
288   OS X 10.3 and previous - A startup item was created in /Library/StartupItems
289        Add \"ZABBIX=-YES-\" to the /etc/hostconfig file to run ZABBIX at system boot
290
291   ${prefix}/share/zabbix/zabbix_server.init start (stop|status)
292
293
2947) A Win32 agent is in ${prefix}/share/zabbix/zabbix_agent_win32 for
295   installation on Windows NT 4.0, Windows 2000, and Windows XP.  See
296   the ReadMe.txt for instructions.
297
298
2998) Login at http://localhost/zabbix with default user 'admin' with no password, then
300   be sure to read the manual: http://www.zabbix.com/manual/v1.1/index.php
301
302\n"
303# End else clause
304
305}
306}
307
Note: See TracBrowser for help on using the repository browser.