Ticket #43232: patch-cacti-Portfile.diff

File patch-cacti-Portfile.diff, 13.3 KB (added by jul_bsd@…, 10 years ago)
  • net/cacti/Portfile

    old new  
    1 # $Id: Portfile 125738 2014-09-25 14:43:03Z mf2k@macports.org $
     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 111384 2013-09-19 21:52:20Z markd@macports.org $
    23
    3 PortSystem      1.0
     4PortSystem          1.0
    45
    5 name                    cacti
    6 version                 0.8.8b
    7 categories              net
    8 license                 GPL-2+
    9 maintainers             nomaintainer
    10 platforms               darwin
    11 supported_archs noarch
     6name                cacti
     7version             0.8.8c
     8categories          net
     9license             GPL-2+
     10maintainers         nomaintainer
     11platforms           darwin
     12supported_archs     noarch
    1213
    13 description             Cacti is a complete RRDtool network graphing solution.
     14description         Cacti is a complete RRDtool network graphing solution.
    1415
    15 long_description        Cacti is a complete network graphing solution designed \
     16long_description    Cacti is a complete network graphing solution designed \
    1617                        to harness the power of RRDtool's data storage and \
    1718                        graphing functions.
    1819
    19 homepage                http://www.cacti.net
    20 master_sites            http://www.cacti.net/downloads
     20homepage            http://www.cacti.net
     21master_sites        http://www.cacti.net/downloads:c
     22distfiles           ${distname}${extract.suffix}:c
     23
     24checksums           ${distname}${extract.suffix} \
     25                    rmd160  591d08d27824444b68e4f517eb52be8bd08fc5f4 \
     26                    sha256  f9b17ed37eac1cdd9ea43d04a09592773216682c5fe7754f9dfcbd5727e70c79 \
    2127
    22 checksums               md5 acb40deae073ca22e5c01a8e3ba389fb \
    23                         rmd160 a2c88961565c6b5d593b4f2603514139800c9145
     28depends_lib         port:rrdtool
    2429
    25 depends_lib             path:bin/mysql_config5:mysql5 \
    26                         port:rrdtool
     30## http://bugs.cacti.net/view.php?id=2261
     31patchfiles          patch-cacti-r7304.diff patch-cacti-r7331.diff
    2732
    2833use_configure   no
    2934build {}
    3035
    31 set cactiversion 0.8.8a
    3236set cactidir ${prefix}/share/cacti
    3337
     38post-patch {
     39    reinplace "s|/usr/local/bin/rrdtool|${prefix}/bin/rrdtool|g;s|/usr/bin/php|${prefix}/bin/php55|;s|/usr/bin/snmp|${prefix}/bin/snmp|g" ${worksrcpath}/install/index.php
     40}
     41#post-configure {
     42#    addgroup cactiuser
     43#    add_users cactiuser gid=[existsgroup cactiuser] home=${cactidir} shell=/sbin/nologin realname=Cacti\ user
     44#}
     45add_users cactiuser group=cactiuser home=${cactidir} shell=/sbin/nologin realname=Cacti\ user
     46
     47destroot.asroot yes
    3448destroot {
    3549# Copy Cacti files
    36         file mkdir ${destroot}${cactidir}
    37         system "cp -R ${worksrcpath}/* ${destroot}${cactidir}"
     50    xinstall -d ${destroot}${cactidir}
     51    system "cp -R ${worksrcpath}/* ${destroot}${cactidir}"
     52    xinstall -d ${destroot}${prefix}/Library/LaunchDaemons/
     53    copy ${filespath}/org.macports.${name}.plist ${destroot}${prefix}/Library/LaunchDaemons/
     54    reinplace "s|%%PREFIX%%|${prefix}|g;s|%%CACTIDIR%%|${cactidir}|g" ${destroot}${prefix}/Library/LaunchDaemons/org.macports.${name}.plist
     55    xinstall -d ${destroot}${prefix}/share/examples/${name}
     56    move ${destroot}${cactidir}/include/config.php ${destroot}${prefix}/share/examples/${name}/
     57    move ${destroot}${cactidir}/include/global.php ${destroot}${prefix}/share/examples/${name}/
     58    copy ${filespath}/nginx-cacti.conf ${destroot}${prefix}/share/examples/${name}/
     59    reinplace "s|%%PREFIX%%|${prefix}|g" ${destroot}${prefix}/share/examples/${name}/nginx-cacti.conf
     60    copy ${filespath}/mp-cacti.conf ${destroot}${prefix}/share/examples/${name}/
     61    reinplace "s|%%PREFIX%%|${prefix}|g" ${destroot}${prefix}/share/examples/${name}/mp-cacti.conf
     62    xinstall -d -m 755 -o cactiuser ${destroot}${prefix}/var/log/${name}
     63
     64    destroot.keepdirs ${destroot}${prefix}/var/log/${name}
     65}
     66
     67post-activate {
     68    if ![file exists ${cactidir}/include/config.php ] {
     69        copy ${prefix}/share/examples/${name}/config.php ${cactidir}/include/
     70    }
     71    if ![file exists ${cactidir}/include/global.php ] {
     72        copy ${prefix}/share/examples/${name}/global.php ${cactidir}/include/
     73    }
     74    if { ! [file exists ${prefix}/etc/nginx/nginx-cacti.conf ] && [file exists ${prefix}/etc/nginx] } {
     75        copy ${prefix}/share/examples/${name}/nginx-cacti.conf ${prefix}/etc/nginx/nginx-cacti.conf
     76    }
    3877}
    3978
    4079
     
    4483The full documentation may be found at http://www.cacti.net/documentation.php.
    4584
    4685
    47 1) Install PHP and MySQL 5 (not covered).  These instructions assume MySQL 5 was
    48    installed from MacPorts.
     861) Install PHP and MySQL 5 (not covered). You can choose appropriate MySQL with variants.
    4987
    5088   Check to make sure the PHP variable \"mysql.default_socket\" is set to path
    51    ${prefix}/var/run/mysql5/mysqld.sock by viewing the output of this terminal command:
    52         php -i
     89   ${prefix}/var/run/mysql*/mysqld.sock by viewing the output of this terminal command:
     90        $ php -i
    5391
    5492   If not, locate the php.ini file for your version of PHP and type the path there.
    5593
    5694
    57 2) Set Cacti permissions.
    58    sudo chown -R <cacti-user>:<cacti-group> ${prefix}/share/${name}/
    59 
    60 
    61 3) Setup MySQL and prepare it for Cacti.
    62    Configure MySQL (new MySQL installs)
    63         sudo -u mysql ${prefix}/lib/mysql5/bin/mysql_install_db
     952) Set Cacti permissions for the scheduled task
     96        $ sudo chown -R cactiuser:cactiuser ${cactidir}/rra/ ${cactidir}/log/
    6497
    65   Start MySQL:
    66         sudo ${prefix}/share/mysql5/mysql/mysql.server start
    67 
    68    Set MySQL to start at system boot
    69         sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
    70 
    71    Set a root MySQL password.
    72         Follow the instructions that were given after you executed 'mysql_install_db' above.
     983) prepare MySQL for Cacti.
    7399
    74100   Create a cacti MySQL user and cacti database.
    75         mysql5 -u root -p (login with root password set above when prompted)
     101    mysql5 -u root -p (login with root password set above when prompted)
    76102        mysql> GRANT ALL ON cacti.* to cacti@localhost;
    77103        mysql> SET PASSWORD FOR cacti@localhost = PASSWORD('<my-cactidb-pwd>');
    78104        mysql> flush privileges;
    79         mysql> create database cacti;
    80         mysql> exit;
     105    mysql> create database cacti;
     106    mysql> exit;
    81107
    82108   Import the cacti database.
    83         sudo cat ${cactidir}/cacti.sql | mysql5 -u root -p cacti (cacti is the db name)
     109    cat ${cactidir}/cacti.sql | mysql5 -u root -p cacti (cacti is the db name)
    84110
    85111   Verify the Cacti Database.
    86         mysql5 -u root -p
    87         mysql> use cacti;
    88         mysql> show tables;
    89         mysql> exit;
    90 
    91 
    92 4) Edit ${cactidir}/include/config.php to match your MySQL information and url path.
    93 
    94         \$database_type = \"mysql\";
    95         \$database_default = \"cacti\";
    96         \$database_hostname = \"localhost\";
    97         \$database_username = \"cacti\";
    98         \$database_password = \"<my-cactidb-pwd>\";
    99 
    100 
    101 5) Place a symlink for Cacti inside your Apache document root.
    102 
    103         ln -s ${cactidir}  <Apache-docroot>/cacti
    104 
    105 
    106 6) Edit the Cacti user's crontab file.
    107         sudo -u <cactiuser> crontab -e
    108 
    109   Insert the crontab entry below:
    110         */5 * * * * ${prefix}/bin/php ${cactidir}/poller.php > /dev/null 2>&1
    111 
     112    mysql5 -u cacti -p cacti
     113    mysql> show tables;
     114    mysql> exit;
     115
     116
     1174) If not existing, edit ${cactidir}/include/config.php to match your MySQL information and url path.
     118
     119    \$database_type = \"mysql\";
     120    \$database_default = \"cacti\";
     121    \$database_hostname = \"localhost\";
     122    \$database_username = \"cacti\";
     123    \$database_password = \"<my-cactidb-pwd>\";
     124
     125   If using socket file, remember to check php.ini as said in 1)
     126
     1275) Include in your webserver
     128   If Apache, Place a symlink for Cacti inside your Apache document root.
     129        # ln -s ${cactidir}  <Apache-docroot>/cacti
     130   If Nginx, include appropriate config. Example is included and copied
     131   in ${prefix}/etc/nginx if existing
     132
     133
     1346) Add poller.php scheduled task. A default plist has been installed to use w php55.
     135   Adjust depending on your setup
     136        # ln -s ${prefix}/Library/LaunchDaemons/org.macports.${name}.plist /Library/LaunchDaemons/
     137        # launchctl load -w /Library/LaunchDaemons/org.macports.${name}.plist
     138   Poller log files are ${prefix}/var/log/cacti/poller*.log
     139   You can enable log rotation by using template for system newsyslog
     140        # cp ${prefix}/share/examples/${name}/mp-cacti.conf /private/etc/newsyslog.d/
    112141
    1131427) If you wish to use Cacti plugins, you must perform these additional steps.
    114143
    115144   a) Download the Cacti plugin(s) you want to use and copy the unzipped directory to ${cactidir}/plugins/
    116145      For example:
    117         ${cactidir}/plugins/weathermap/
     146    ${cactidir}/plugins/weathermap/
    118147
    119148   b) In the Cacti web GUI, go to Configuration -> Plugin Management and you should see your plugin(s) listed.
    120149      Under 'Actions', click the the install icon to install each plugin.
     
    124153
    125154
    1261558) Go to http://localhost/cacti/install/index.php.
    127         The default user/password is admin/admin.  Select 'New Install', enter
    128         the paths for SNMP / RRDtool / PHP (see below), and click 'Finish'.
    129         You may now use Cacti at http://localhost/cacti/index.php.
    130 
    131 Verify paths:
    132         snmpwalk binary path: /usr/bin/snmpwalk
    133         snmpget binary path: /usr/bin/snmpget
    134 
    135         RRDtool binary path: ${prefix}/bin/rrdtool
    136         PHP binary path: ${prefix}/bin/php (if not using MacPorts PHP, use appropriate path)
    137 
     156    The default user/password is admin/admin.  Select 'New Install', enter
     157    the paths for SNMP / RRDtool / PHP (adjusted to macports), and click 'Finish'.
     158    You may now use Cacti at http://localhost/cacti/index.php.
    138159
    1391609) Create interface traffic graphs
    140161   a) Devices -> Add
     
    148169        -Select a graph type from the menu in the bottom right and click the 'Create' button beside it
    149170
    150171   c) Place some or all a device's graphs on a graph tree from the Devices or Graph Management section
     172
     17310) If you want to use snmp on your mac, you can either use
     174   * Apple default SNMP
     175       # /usr/bin/snmpconf -g basic_setup
     176       $ sudo launchctl load -w /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist
     177   * Macports
     178       $ sudo port install net-snmp +server
     179       # ${prefix}/bin/snmpconf -g basic_setup
     180       # mv snmpd.conf ${prefix}/etc/
     181       $ sudo port load net-snmp
     182
     183"
     184
     185if {![variant_isset mysql5] && ![variant_isset mysql51] && ![variant_isset mysql55] && ![variant_isset mariadb] && ![variant_isset percona]} {
     186    default_variants +mysql56
     187}
     188
     189default_variants-append      +superlinks
     190
     191## http://wotsit.thingy.com/haj/cacti/superlinks-plugin.html
     192variant superlinks description { plugin superlinks } {
     193    master_sites-append        http://wotsit.thingy.com/haj/cacti/:superlinks
     194    distfiles-append           superlinks-0.8.zip:superlinks
     195    checksums-append           superlinks-0.8.zip \
     196                    rmd160  880c639db183f1813d37dacec9f89c4dde988d5d \
     197                    sha256  424b8e828306af0646f571aec92dad9c9b9910e49009d08634c41fbf6ff03597
     198
     199    post-extract {
     200        system -W ${worksrcpath}/plugins "unzip ${distpath}/superlinks-0.8.zip"
     201    }
     202}
     203
     204## http://www.network-weathermap.com/manual/latest/pages/cacti-plugin.html
     205variant weathermap description { plugin weathermap } {
     206    depends_lib-append   port:pcre port:gd
     207    master_files-append     http://www.network-weathermap.com/files/:w
     208    distfiles-append     php-weathermap-0.97c.zip:w
     209
     210    post-extract {
     211        system -W ${worksrcpath}/plugins "unzip ${distpath}/php-weathermap-0.97c.zip"
     212    }
     213    destroot-append {
     214        ## unpack in cactidir/plugins/weathermap
     215        ## chown -R cactiuser cactidir/plugins/weathermap/output
     216    }
     217
     218notes-append "
     219As a reminder, you will need php*-pcre php*-gd corresponding to your PHP release target.
     220You will need to enable the plugin in ${cactidir}/includes/config.php. Add the following line:
     221    \$plugins\[\] = 'weathermap';
    151222"
     223}
     224
     225## http://forums.cacti.net/viewtopic.php?p=173542#p173542
     226variant advancedping description { template advancedping } {
     227    depends_run-append   port:fping
     228    distfiles-append http://forums.cacti.net/download/file.php?id=18479 \
     229        http://forums.cacti.net/download/file.php?id=18480
     230
     231    reinplace "s|/usr/sbin/fping|${prefix}/sbin/fping|g" ss_fping.php
     232}
     233
     234## include Mac template ?
     235
     236## cpu snmp removed by apple. no but some random conditions can happen, it seems
     237## http://macosx.com/forums/mac-os-x-system-mac-software/273289-net-snmp-cpu-stats.html
     238
     239variant mysql5 \
     240    conflicts mysql51 mysql55 mysql56 mariadb percona \
     241    description "Enable MySQL 5.1 support" {
     242
     243    depends_lib-append          port:mysql5
     244}
     245
     246variant mysql51 \
     247    conflicts mysql5 mysql55 mysql56 mariadb percona \
     248    description "Enable MySQL 5.1 support" {
     249
     250    depends_lib-append          port:mysql51
     251}
     252
     253variant mysql55 \
     254    conflicts mysql5 mysql51 mysql56 mariadb percona \
     255    description "Enable MySQL 5.5 support" {
     256
     257    depends_lib-append          port:mysql55
     258}
     259
     260variant mysql56 \
     261    conflicts mysql5 mysql51 mysql55 mariadb percona \
     262    description "Enable MySQL 5.6 support" {
     263
     264    depends_lib-append          port:mysql56
     265}
     266
     267variant mariadb \
     268    conflicts mysql5 mysql51 mysql55 mysql56 percona \
     269    description "Enable MariaDB (MySQL) support" {
     270
     271    depends_lib-append          port:mariadb
     272}
     273
     274variant percona \
     275    conflicts mysql5 mysql51 mysql55 mysql56 mariadb \
     276    description "Enable Percona (MySQL) support" {
     277        depends_lib-append          port:percona
     278}
     279
     280livecheck.type     regex
     281livecheck.url       ${homepage}
     282livecheck.regex     "\">(\\d+(?:\\.\\d+\\w*)*)</a></strong></span>"