Ticket #43256: patch-cacti-Portfile.diff

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

    old new  
    11# $Id: Portfile 111384 2013-09-19 21:52:20Z markd@macports.org $
    22
    3 PortSystem      1.0
     3PortSystem          1.0
    44
    5 name                    cacti
    6 version                 0.8.8b
    7 categories              net
    8 license                 GPL-2+
    9 maintainers             markd openmaintainer
    10 platforms               darwin
    11 supported_archs noarch
     5name                cacti
     6version             0.8.8b
     7revision            1
     8categories          net
     9license             GPL-2+
     10maintainers         markd openmaintainer
     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
    2122
    22 checksums               md5 acb40deae073ca22e5c01a8e3ba389fb \
    23                         rmd160 a2c88961565c6b5d593b4f2603514139800c9145
     23checksums           md5 acb40deae073ca22e5c01a8e3ba389fb \
     24                    rmd160 a2c88961565c6b5d593b4f2603514139800c9145
    2425
    25 depends_lib             path:bin/mysql_config5:mysql5 \
    26                         port:rrdtool
     26depends_lib         port:rrdtool
     27
     28## http://bugs.cacti.net/view.php?id=2261
     29patchfiles          patch-cacti-r7304.diff patch-cacti-r7331.diff
    2730
    2831use_configure   no
    2932build {}
    3033
    31 set cactiversion 0.8.8a
    3234set cactidir ${prefix}/share/cacti
    3335
     36post-patch {
     37    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
     38}
     39post-configure {
     40    addgroup cactiuser
     41    add_users cactiuser gid=[existsgroup cactiuser] home=${cactidir} shell=/sbin/nologin realname=Cacti\ user
     42}
     43
    3444destroot {
    3545# Copy Cacti files
    36         file mkdir ${destroot}${cactidir}
    37         system "cp -R ${worksrcpath}/* ${destroot}${cactidir}"
     46    xinstall -d ${destroot}${cactidir}
     47    system "cp -R ${worksrcpath}/* ${destroot}${cactidir}"
     48    xinstall -d ${destroot}${prefix}/Library/LaunchAgents/
     49    copy ${filespath}/org.macports.${name}.plist ${destroot}${prefix}/Library/LaunchAgents/
     50    reinplace "s|%%PREFIX%%|${prefix}|g;s|%%CACTIDIR%%|${cactidir}|g" ${destroot}${prefix}/Library/LaunchAgents/org.macports.${name}.plist
     51    xinstall -d ${destroot}${prefix}/share/examples/${name}
     52    move ${destroot}${cactidir}/include/config.php ${destroot}${prefix}/share/examples/${name}/
     53    move ${destroot}${cactidir}/include/global.php ${destroot}${prefix}/share/examples/${name}/
     54    copy ${filespath}/nginx-cacti.conf ${destroot}${prefix}/share/examples/${name}/
     55    reinplace "s|%%PREFIX%%|${prefix}|g" ${destroot}${prefix}/share/examples/${name}/nginx-cacti.conf
     56    copy ${filespath}/mp-cacti.conf ${destroot}${prefix}/share/examples/${name}/
     57    reinplace "s|%%PREFIX%%|${prefix}|g" ${destroot}${prefix}/share/examples/${name}/mp-cacti.conf
     58    xinstall -d -m 755 -o cactiuser ${destroot}${prefix}/var/log/${name}
     59
     60    destroot.keepdirs ${destroot}${prefix}/var/log/${name}
     61}
     62
     63post-activate {
     64    if ![file exists ${cactidir}/include/config.php ] {
     65        copy ${prefix}/share/examples/${name}/config.php ${cactidir}/include/
     66    }
     67    if ![file exists ${cactidir}/include/global.php ] {
     68        copy ${prefix}/share/examples/${name}/global.php ${cactidir}/include/
     69    }
     70    if { ! [file exists ${prefix}/etc/nginx/nginx-cacti.conf ] && [file exists ${prefix}/etc/nginx] } {
     71        copy ${prefix}/share/examples/${name}/nginx-cacti.conf ${prefix}/etc/nginx/nginx-cacti.conf
     72    }
    3873}
    3974
    4075
     
    4479The full documentation may be found at http://www.cacti.net/documentation.php.
    4580
    4681
    47 1) Install PHP and MySQL 5 (not covered).  These instructions assume MySQL 5 was
    48    installed from MacPorts.
     821) Install PHP and MySQL 5 (not covered). You can choose appropriate MySQL with variants.
    4983
    5084   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
     85   ${prefix}/var/run/mysql*/mysqld.sock by viewing the output of this terminal command:
     86        $ php -i
    5387
    5488   If not, locate the php.ini file for your version of PHP and type the path there.
    5589
    5690
    57 2) Set Cacti permissions.
    58    sudo chown -R <cacti-user>:<cacti-group> ${prefix}/share/${name}/
     912) Set Cacti permissions for the scheduled task
     92        $ sudo chown -R cactiuser:cactiuser ${cactidir}/rra/ ${cactidir}/log/
    5993
    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
    64 
    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.
     943) prepare MySQL for Cacti.
    7395
    7496   Create a cacti MySQL user and cacti database.
    75         mysql5 -u root -p (login with root password set above when prompted)
     97    mysql5 -u root -p (login with root password set above when prompted)
    7698        mysql> GRANT ALL ON cacti.* to cacti@localhost;
    7799        mysql> SET PASSWORD FOR cacti@localhost = PASSWORD('<my-cactidb-pwd>');
    78100        mysql> flush privileges;
    79         mysql> create database cacti;
    80         mysql> exit;
     101    mysql> create database cacti;
     102    mysql> exit;
    81103
    82104   Import the cacti database.
    83         sudo cat ${cactidir}/cacti.sql | mysql5 -u root -p cacti (cacti is the db name)
     105    cat ${cactidir}/cacti.sql | mysql5 -u root -p cacti (cacti is the db name)
    84106
    85107   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 
     108    mysql5 -u cacti -p cacti
     109    mysql> show tables;
     110    mysql> exit;
     111
     112
     1134) If not existing, edit ${cactidir}/include/config.php to match your MySQL information and url path.
     114
     115    \$database_type = \"mysql\";
     116    \$database_default = \"cacti\";
     117    \$database_hostname = \"localhost\";
     118    \$database_username = \"cacti\";
     119    \$database_password = \"<my-cactidb-pwd>\";
     120
     121   If using socket file, remember to check php.ini as said in 1)
     122
     1235) Include in your webserver
     124   If Apache, Place a symlink for Cacti inside your Apache document root.
     125        # ln -s ${cactidir}  <Apache-docroot>/cacti
     126   If Nginx, include appropriate config. Example is included and copied
     127   in ${prefix}/etc/nginx if existing
     128
     129
     1306) Add poller.php scheduled task. A default plist has been installed to use w php55.
     131   Adjust depending on your setup
     132        # ln -s ${prefix}/Library/LaunchAgents/org.macports.${name}.plist /Library/LaunchAgents/
     133        # launchctl load -w /Library/LaunchAgents/org.macports.${name}.plist
     134   Poller log files are ${prefix}/var/log/cacti/poller*.log
     135   You can enable log rotation by using template for system newsyslog
     136        # cp ${prefix}/share/examples/${name}/mp-cacti.conf /private/etc/newsyslog.d/
    112137
    1131387) If you wish to use Cacti plugins, you must perform these additional steps.
    114139
    115140   a) Download the Cacti plugin(s) you want to use and copy the unzipped directory to ${cactidir}/plugins/
    116141      For example:
    117         ${cactidir}/plugins/weathermap/
     142    ${cactidir}/plugins/weathermap/
    118143
    119144   b) In the Cacti web GUI, go to Configuration -> Plugin Management and you should see your plugin(s) listed.
    120145      Under 'Actions', click the the install icon to install each plugin.
     
    124149
    125150
    1261518) 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 
     152    The default user/password is admin/admin.  Select 'New Install', enter
     153    the paths for SNMP / RRDtool / PHP (adjusted to macports), and click 'Finish'.
     154    You may now use Cacti at http://localhost/cacti/index.php.
    138155
    1391569) Create interface traffic graphs
    140157   a) Devices -> Add
     
    148165        -Select a graph type from the menu in the bottom right and click the 'Create' button beside it
    149166
    150167   c) Place some or all a device's graphs on a graph tree from the Devices or Graph Management section
     168
     16910) If you want to use snmp on your mac, you can either use
     170   * Apple default SNMP
     171       # /usr/bin/snmpconf -g basic_setup
     172       $ sudo launchctl load -w /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist
     173   * Macports
     174       $ sudo port install net-snmp +server
     175       # ${prefix}/bin/snmpconf -g basic_setup
     176       # mv snmpd.conf ${prefix}/etc/
     177       $ sudo port load net-snmp
    151178"
     179
     180if {![variant_isset mysql5] && ![variant_isset mysql51] && ![variant_isset mysql55] && ![variant_isset mariadb] && ![variant_isset percona]} {
     181    default_variants +mysql56
     182}
     183
     184default_variants-append      +superlinks
     185
     186## http://wotsit.thingy.com/haj/cacti/superlinks-plugin.html
     187variant superlinks description { plugin superlinks } {
     188    distfiles-append    http://wotsit.thingy.com/haj/cacti/superlinks-0.8.zip
     189#    post-patch {
     190#        system "cd ${worksrcpath}/plugins && unzip ${distpath}/superlinks-0.8.zip"
     191#    }
     192}
     193
     194## http://www.network-weathermap.com/manual/latest/pages/cacti-plugin.html
     195variant weathermap description { plugin weathermap } {
     196    depends_lib-append   port:pcre port:gd
     197    distfiles-append     http://www.network-weathermap.com/files/php-weathermap-0.97c.zip
     198
     199    destroot-append {
     200        ## unpack in cactidir/plugins/weathermap
     201        ## chown -R cactiuser cactidir/plugins/weathermap/output
     202    }
     203
     204notes-append "
     205As a reminder, you will need php*-pcre php*-gd corresponding to your PHP release target.
     206You will need to enable the plugin in ${cactidir}/includes/config.php. Add the following line:
     207    \$plugins\[\] = 'weathermap';
     208"
     209}
     210
     211## http://forums.cacti.net/viewtopic.php?p=173542#p173542
     212variant advancedping description { template advancedping } {
     213    depends_run-append   port:fping
     214    distfiles-append http://forums.cacti.net/download/file.php?id=18479 \
     215        http://forums.cacti.net/download/file.php?id=18480
     216
     217    reinplace "s|/usr/sbin/fping|${prefix}/sbin/fping|g" ss_fping.php
     218}
     219
     220## include Mac template ?
     221
     222## cpu snmp removed by apple. no but some random conditions can happen, it seems
     223## http://macosx.com/forums/mac-os-x-system-mac-software/273289-net-snmp-cpu-stats.html
     224
     225variant mysql5 \
     226    conflicts mysql51 mysql55 mysql56 mariadb percona \
     227    description "Enable MySQL 5.1 support" {
     228
     229    depends_lib-append          port:mysql5
     230}
     231
     232variant mysql51 \
     233    conflicts mysql5 mysql55 mysql56 mariadb percona \
     234    description "Enable MySQL 5.1 support" {
     235
     236    depends_lib-append          port:mysql51
     237}
     238
     239variant mysql55 \
     240    conflicts mysql5 mysql51 mysql56 mariadb percona \
     241    description "Enable MySQL 5.5 support" {
     242
     243    depends_lib-append          port:mysql55
     244}
     245
     246variant mysql56 \
     247    conflicts mysql5 mysql51 mysql55 mariadb percona \
     248    description "Enable MySQL 5.6 support" {
     249
     250    depends_lib-append          port:mysql56
     251}
     252
     253variant mariadb \
     254    conflicts mysql5 mysql51 mysql55 mysql56 percona \
     255    description "Enable MariaDB (MySQL) support" {
     256
     257    depends_lib-append          port:mariadb
     258}
     259
     260variant percona \
     261    conflicts mysql5 mysql51 mysql55 mysql56 mariadb \
     262    description "Enable Percona (MySQL) support" {
     263        depends_lib-append          port:percona
     264}
     265