Revision: 102400 https://trac.macports.org/changeset/102400 Author: eborisch@macports.org Date: 2013-02-01 12:36:09 -0800 (Fri, 01 Feb 2013) Log Message: ----------- zabbix2[-agent]: Split agent into subport. Portfile cleanup. Modified Paths: -------------- trunk/dports/net/zabbix2/Portfile trunk/dports/net/zabbix2/files/zabbix_server.init Removed Paths: ------------- trunk/dports/net/zabbix2/files/zabbix_agentd.init Modified: trunk/dports/net/zabbix2/Portfile =================================================================== --- trunk/dports/net/zabbix2/Portfile 2013-02-01 20:32:48 UTC (rev 102399) +++ trunk/dports/net/zabbix2/Portfile 2013-02-01 20:36:09 UTC (rev 102400) @@ -5,7 +5,7 @@ name zabbix2 version 2.0.4 -revision 0 +revision 1 categories net maintainers openmaintainer platforms darwin @@ -30,16 +30,17 @@ rmd160 f36277f1f10b569a9bea49d05d76e3caa9601f05 \ sha256 7554223a927229b6317d211d413826fb0b2a974f460a9db9075b376a241a0051 -depends_lib port:fping \ - port:curl \ - port:OpenIPMI +universal_variant no +depends_lib port:OpenIPMI + conflicts zabbix -configure.args --enable-server \ - --enable-agent \ - --with-net-snmp \ - --bindir=${prefix}/bin/zabbix \ +dist_subdir zabbix2 + +subport zabbix2-agent {} + +configure.args --bindir=${prefix}/bin/zabbix \ --sbindir=${prefix}/sbin/zabbix \ --libexecdir=${prefix}/libexec/zabbix \ --datadir=${prefix}/share/zabbix \ @@ -50,70 +51,79 @@ configure.ldflags-append -lresolv -if { [variant_isset agent_only] } { - startupitem.create yes - startupitem.start "${prefix}/share/zabbix/zabbix_agentd.init start" - startupitem.stop "${prefix}/share/zabbix/zabbix_agentd.init stop" -} else { - startupitem.create yes - startupitem.start "${prefix}/share/zabbix/zabbix_server.init start" - startupitem.stop "${prefix}/share/zabbix/zabbix_server.init stop" -} +startupitem.create yes -variant mysql5 conflicts pgsql81 pgsql82 pgsql83 pgsql84 sqlite3 \ - description {Use MySQL 5.x for server database} { - depends_lib-append path:bin/mysql_config5:mysql5 - configure.args-append --with-mysql=${prefix}/lib/mysql5/bin/mysql_config -} +if { ${subport} != ${name} } { + startupitem.name zabbix2-agentd + startupitem.executable \ + ${prefix}/sbin/zabbix/zabbix_agentd \ + -c ${prefix}/etc/zabbix/zabbix_agentd.conf + startupitem.pidfile clean /tmp/zabbix_agentd.pid -variant pgsql81 conflicts mysql5 pgsql82 pgsql83 pgsql84 sqlite3 \ - description {Use PostgreSQL 8.1.x for server database} { - depends_lib-append port:postgresql81 - configure.args-append --with-pgsql=${prefix}/lib/postgresql81/bin/pg_config -} + configure.args-append --enable-agent +} else { + depends_lib-append port:fping \ + port:curl -variant pgsql82 conflicts mysql5 pgsql81 pgsql83 pgsql84 sqlite3 \ - description {Use PostgreSQL 8.2.x for server database} { - depends_lib-append port:postgresql82 - configure.args-append --with-pgsql=${prefix}/lib/postgresql82/bin/pg_config -} + configure.args-append --enable-server \ + --with-net-snmp -variant pgsql83 conflicts mysql5 pgsql81 pgsql82 pgsql84 sqlite3 \ - description {Use PostgreSQL 8.3.x for server database} { - depends_lib-append port:postgresql83 - configure.args-append --with-pgsql=${prefix}/lib/postgresql83/bin/pg_config -} + startupitem.name zabbix2-server + startupitem.start "${prefix}/share/zabbix/zabbix_server.init start" + startupitem.stop "${prefix}/share/zabbix/zabbix_server.init stop" -variant pgsql84 conflicts mysql5 pgsql81 pgsql82 pgsql83 sqlite3 \ - description {Use PostgreSQL 8.4.x for server database} { - depends_lib-append port:postgresql84 - configure.args-append --with-pgsql=${prefix}/lib/postgresql84/bin/pg_config -} + array set DBLIST { + mysql5 {"MySQL 5.x" path:bin/mysql_config5:mysql5 \ + mysql=${prefix}/lib/mysql5/bin/mysql_config} + pgsql81 {"PostgreSQL 8.1.x" port:postgresql81 \ + pgsql=${prefix}/lib/postgresql81/bin/pg_config} + pgsql82 {"PostgreSQL 8.2.x" port:postgresql82 \ + pgsql=${prefix}/lib/postgresql82/bin/pg_config} + pgsql83 {"PostgreSQL 8.3.x" port:postgresql83 \ + pgsql=${prefix}/lib/postgresql83/bin/pg_config} + pgsql84 {"PostgreSQL 8.4.x" port:postgresql84 \ + pgsql=${prefix}/lib/postgresql84/bin/pg_config} + sqlite3 {"SQLite 3.x" port:sqlite3 \ + sqlite3=${prefix}} + } + set DBLIST_KEYS [lsort [array names DBLIST]] -variant sqlite3 conflicts mysql5 pgsql81 pgsql82 pgsql83 pgsql84 \ - description {Use SQLite 3.x for server database} { - depends_lib-append port:sqlite3 - configure.args-append --with-sqlite3=${prefix} -} + foreach dbitem $DBLIST_KEYS { + set this_key [lsearch $DBLIST_KEYS $dbitem] + set conf_list [lreplace $DBLIST_KEYS $this_key $this_key] + set prms $DBLIST($dbitem) -variant agent_only conflicts mysql5 pgsql81 pgsql82 pgsql83 pgsql84 sqlite3 \ - description {Do not install the Zabbix server} { - depends_lib-delete port:fping \ - port:curl + variant $dbitem \ + description "Use [lindex $prms 0] for server database" \ + conflicts $conf_list " + depends_lib-append [lindex $prms 1] + configure.args-append --with-[lindex $prms 2] + " + } - configure.args-delete --enable-server \ - --with-net-snmp -} + if {![variant_isset pgsql81] && + ![variant_isset pgsql82] && + ![variant_isset pgsql83] && + ![variant_isset pgsql84] && + ![variant_isset sqlite3]} { + default_variants +mysql5 + } -if {![variant_isset pgsql81] && ![variant_isset pgsql82] && ![variant_isset pgsql83] && ![variant_isset pgsql84] && ![variant_isset sqlite3] && ![variant_isset agent_only]} { - default_variants +mysql5 +# Notify anyone with +agent_only installed of new zabbix2-agent port + variant agent_only description {Old variant -- install zabbix2-agent} { + pre-fetch { + ui_error \ + "Variant 'zabbix2 +agent_only' replaced by port zabbix2-agent" + return -code error "+agent_only variant replaced by zabbix2-agent" + } + } } post-extract { - reinplace "s|#DBSocket=/tmp/mysql.sock|DBSocket=${prefix}/var/run/mysql5/mysqld.sock|g" \ + reinplace "s|# DBSocket=/tmp/mysql.sock|DBSocket=${prefix}/var/run/mysql5/mysqld.sock|" \ ${worksrcpath}/conf/zabbix_server.conf - reinplace "s|#FpingLocation=/usr/sbin/fping|FpingLocation=${prefix}/sbin/fping|g" \ + reinplace "s|#FpingLocation=/usr/sbin/fping|FpingLocation=${prefix}/sbin/fping|" \ ${worksrcpath}/conf/zabbix_server.conf } @@ -122,84 +132,68 @@ } post-destroot { - -if { [variant_isset agent_only] } { -# Don't install MySQL data and frontend stuff for agent_only - + if { ${name} != ${subport} } { + ####### AGENT ####### # Copy sample agent .conf files - xinstall -d -m 755 -d ${destroot}${prefix}/etc/zabbix - xinstall -m 755 ${worksrcpath}/conf/zabbix_agent.conf \ - ${destroot}${prefix}/etc/zabbix/zabbix_agent.conf.sample - xinstall -m 755 ${worksrcpath}/conf/zabbix_agentd.conf \ - ${destroot}${prefix}/etc/zabbix/zabbix_agentd.conf.sample + xinstall -d -m 755 -d ${destroot}${prefix}/etc/zabbix + xinstall -m 755 ${worksrcpath}/conf/zabbix_agent.conf \ + ${destroot}${prefix}/etc/zabbix/zabbix_agent.conf.sample + xinstall -m 755 ${worksrcpath}/conf/zabbix_agentd.conf \ + ${destroot}${prefix}/etc/zabbix/zabbix_agentd.conf.sample -# Copy a startup script for the agent - xinstall -d -m 755 -d ${destroot}${prefix}/share/zabbix - xinstall -m 755 ${portpath}/${filesdir}/zabbix_agentd.init \ - ${destroot}${prefix}/share/zabbix - reinplace "s|__PREFIX__|${prefix}|g" \ - ${destroot}${prefix}/share/zabbix/zabbix_agentd.init -} else { - +# Don't overwrite user settings on each install + delete ${destroot}${prefix}/etc/zabbix/zabbix_agentd.conf + delete ${destroot}${prefix}/etc/zabbix/zabbix_agent.conf + } else { + ####### SERVER ####### # Copy sample server and agent .conf files - xinstall -d -m 755 -d ${destroot}${prefix}/etc/zabbix - xinstall -m 755 ${worksrcpath}/conf/zabbix_agent.conf \ - ${destroot}${prefix}/etc/zabbix/zabbix_agent.conf.sample - xinstall -m 755 ${worksrcpath}/conf/zabbix_agentd.conf \ - ${destroot}${prefix}/etc/zabbix/zabbix_agentd.conf.sample - xinstall -m 755 ${worksrcpath}/conf/zabbix_server.conf \ - ${destroot}${prefix}/etc/zabbix/zabbix_server.conf.sample - delete ${destroot}${prefix}/etc/zabbix/zabbix_server.conf - delete ${destroot}${prefix}/etc/zabbix/zabbix_agentd.conf - delete ${destroot}${prefix}/etc/zabbix/zabbix_agent.conf + xinstall -d -m 755 -d ${destroot}${prefix}/etc/zabbix + xinstall -m 755 ${worksrcpath}/conf/zabbix_server.conf \ + ${destroot}${prefix}/etc/zabbix/zabbix_server.conf.sample +# Don't overwrite user settings on each install + delete ${destroot}${prefix}/etc/zabbix/zabbix_server.conf + # Copy database data and schemas - xinstall -d -m 755 -d ${destroot}${prefix}/share/zabbix/data - xinstall -d -m 755 -d ${destroot}${prefix}/share/zabbix/schema + xinstall -d -m 755 -d ${destroot}${prefix}/share/zabbix/data + xinstall -d -m 755 -d ${destroot}${prefix}/share/zabbix/schema - eval xinstall -m 755 ${worksrcpath}/database/mysql/data.sql \ - ${destroot}${prefix}/share/zabbix/data - eval xinstall -m 755 ${worksrcpath}/database/mysql/images.sql \ - ${destroot}${prefix}/share/zabbix/data - eval xinstall -m 755 ${worksrcpath}/database/mysql/schema.sql \ - ${destroot}${prefix}/share/zabbix/schema + eval xinstall -m 755 ${worksrcpath}/database/mysql/data.sql \ + ${destroot}${prefix}/share/zabbix/data + eval xinstall -m 755 ${worksrcpath}/database/mysql/images.sql \ + ${destroot}${prefix}/share/zabbix/data + eval xinstall -m 755 ${worksrcpath}/database/mysql/schema.sql \ + ${destroot}${prefix}/share/zabbix/schema - file copy ${worksrcpath}/upgrades \ - ${destroot}${prefix}/share/zabbix/ + file copy ${worksrcpath}/upgrades \ + ${destroot}${prefix}/share/zabbix/ # Copy the front end files + file mkdir ${destroot}${prefix}/share/zabbix/frontends/ + file copy ${worksrcpath}/frontends/php/ \ + ${destroot}${prefix}/share/zabbix/frontends/ - file mkdir ${destroot}${prefix}/share/zabbix/frontends/ - file copy ${worksrcpath}/frontends/php/ \ - ${destroot}${prefix}/share/zabbix/frontends/ - # Create a startup script for the server - xinstall -m 755 ${portpath}/${filesdir}/zabbix_server.init \ - ${destroot}${prefix}/share/zabbix - reinplace "s|__PREFIX__|${prefix}|g" \ - ${destroot}${prefix}/share/zabbix/zabbix_server.init +# This script has a delay built into it (waiting for DB to start) so we +# don't use a simple startupitem.executable approach + xinstall -m 755 ${portpath}/${filesdir}/zabbix_server.init \ + ${destroot}${prefix}/share/zabbix + reinplace "s|__PREFIX__|${prefix}|g" \ + ${destroot}${prefix}/share/zabbix/zabbix_server.init -# Create a startup script for the agent - xinstall -m 755 ${portpath}/${filesdir}/zabbix_agentd.init \ - ${destroot}${prefix}/share/zabbix - reinplace "s|__PREFIX__|${prefix}|g" \ - ${destroot}${prefix}/share/zabbix/zabbix_agentd.init - # Set permissions for etc (protect passwords) and the frontend - system "chmod 660 ${destroot}${prefix}/etc/zabbix/*" - system "chown zabbix:zabbix ${destroot}${prefix}/etc/zabbix/*" - system "chown -R www:www ${destroot}${prefix}/share/zabbix/frontends/*" + system "chmod 660 ${destroot}${prefix}/etc/zabbix/*" + system "chown zabbix:zabbix ${destroot}${prefix}/etc/zabbix/*" + system "chown -R www:www ${destroot}${prefix}/share/zabbix/frontends/*" -# End else clause - Done with server stuff + xinstall -d -m 755 -d \ + ${destroot}${prefix}/share/zabbix/zabbix_agent_win32 + xinstall -m 755 ${worksrcpath}/bin/win32/zabbix_agentd.exe \ + ${destroot}${prefix}/share/zabbix/zabbix_agent_win32 + } } -# Copy Win32 agent for normal and agent_only installs - xinstall -d -m 755 -d ${destroot}${prefix}/share/zabbix/zabbix_agent_win32 - xinstall -m 755 ${worksrcpath}/bin/win32/zabbix_agentd.exe \ - ${destroot}${prefix}/share/zabbix/zabbix_agent_win32 -} - -if {[variant_isset agent_only]} { +if { ${name} != ${subport} } { notes " #### #### #### ZABBIX2 agent installation section #### @@ -215,12 +209,8 @@ 2) Set zabbix_agentd to run at system boot - sudo port load zabbix2 + sudo port load zabbix2-agent - To start Zabbix manually, use: - ${prefix}/share/zabbix/zabbix_agentd.init start (stop|status) - - 3) A Win32 agent is in ${prefix}/share/zabbix/zabbix_agent_win32 for\ installation on Windows NT 4.0, Windows 2000, and Windows XP. @@ -286,8 +276,8 @@ To start Zabbix manually, use: ${prefix}/share/zabbix/zabbix_server.init start (stop|status) - Note: Your shared memory will likely need to be increased - (see http://support.apple.com/kb/HT4022) + !! Note: Your shared memory will likely need to be increased !! + !! (see http://support.apple.com/kb/HT4022) !! 7) A Win32 agent is in ${prefix}/share/zabbix/zabbix_agent_win32 for\ installation on Windows NT 4.0, Windows 2000, and Windows XP. See\ Deleted: trunk/dports/net/zabbix2/files/zabbix_agentd.init =================================================================== --- trunk/dports/net/zabbix2/files/zabbix_agentd.init 2013-02-01 20:32:48 UTC (rev 102399) +++ trunk/dports/net/zabbix2/files/zabbix_agentd.init 2013-02-01 20:36:09 UTC (rev 102400) @@ -1,26 +0,0 @@ -#!/bin/sh - -case "$1" in - start) - echo -n "Starting zabbix_agentd " - sudo -u zabbix __PREFIX__/sbin/zabbix/zabbix_agentd -c __PREFIX__/etc/zabbix/zabbix_agentd.conf - ;; - - stop) - echo -n "Shutting down zabbix_agentd" - pid=`ps axc|awk "{if (\\$5==\"zabbix_agent\") print \\$1}"` - /bin/kill $pid - rm /var/tmp/zabbix_agentd.pid - ;; - restart) - $0 stop - $0 start - ;; - status) - /bin/ps -ax |/usr/bin/grep zabbix_agentd - ;; - *) - echo "Usage: $0 {start|stop|restart|status}" - exit 1 -esac - Modified: trunk/dports/net/zabbix2/files/zabbix_server.init =================================================================== --- trunk/dports/net/zabbix2/files/zabbix_server.init 2013-02-01 20:32:48 UTC (rev 102399) +++ trunk/dports/net/zabbix2/files/zabbix_server.init 2013-02-01 20:36:09 UTC (rev 102400) @@ -11,7 +11,7 @@ echo -n "Shutting down zabbix_server" pid=`ps axc|awk "{if (\\$5==\"zabbix_server\") print \\$1}"` /bin/kill $pid - rm /var/tmp/zabbix_server.pid + rm /tmp/zabbix_server.pid ;; restart) $0 stop