Ticket #43232: Portfile

File Portfile, 8.3 KB (added by jul_bsd@…, 10 years ago)

bug "Portfile: extra characters after close-brace"

Line 
1# $Id: Portfile 111384 2013-09-19 21:52:20Z markd@macports.org $
2
3PortSystem          1.0
4
5name                cacti
6version             0.8.8b
7revision            1
8categories          net
9license             GPL-2+
10maintainers         markd openmaintainer
11platforms           darwin
12supported_archs     noarch
13
14description         Cacti is a complete RRDtool network graphing solution.
15
16long_description    Cacti is a complete network graphing solution designed \
17                        to harness the power of RRDtool's data storage and \
18                        graphing functions.
19
20homepage            http://www.cacti.net
21master_sites        http://www.cacti.net/downloads
22
23checksums           md5 acb40deae073ca22e5c01a8e3ba389fb \
24                    rmd160 a2c88961565c6b5d593b4f2603514139800c9145
25
26depends_lib         path:bin/mysql_config5:mysql5 port:rrdtool
27
28## http://bugs.cacti.net/view.php?id=2261
29patchfiles          patch-cacti-r7304.diff patch-cacti-r7331.diff
30
31use_configure   no
32build {}
33
34set cactidir ${prefix}/share/cacti
35
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
44destroot {
45# Copy Cacti files
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    copy ${filespath}/nginx-cacti.conf ${destroot}${prefix}/share/examples/${name}/
54    reinplace "s|%%PREFIX%%|${prefix}|g" ${destroot}${prefix}/share/examples/${name}/nginx-cacti.conf
55    copy ${filespath}/mp-cacti.conf ${destroot}${prefix}/share/examples/${name}/
56    reinplace "s|%%PREFIX%%|${prefix}|g" ${destroot}${prefix}/share/examples/${name}/mp-cacti.conf
57    xinstall -d -m 755 -o cactiuser ${destroot}${prefix}/var/log/${name}
58
59    destroot.keepdirs ${destroot}${prefix}/var/log/${name}
60}
61
62post-activate {
63    if ![file exists ${cactidir}/include/config.php ] {
64        copy ${prefix}/share/examples/${name}/config.php ${cactidir}/include/
65    }
66    if { ! [file exists ${prefix}/etc/nginx/nginx-cacti.conf ] && [file exists ${prefix}/etc/nginx] } {
67        copy ${prefix}/share/examples/${name}/nginx-cacti.conf ${prefix}/etc/nginx/nginx-cacti.conf
68    }
69}
70
71
72notes "
73**** To complete the Cacti installation ****
74
75The full documentation may be found at http://www.cacti.net/documentation.php.
76
77
781) Install PHP and MySQL 5 (not covered).  These instructions assume MySQL 5 was
79   installed from MacPorts.
80
81   Check to make sure the PHP variable \"mysql.default_socket\" is set to path
82   ${prefix}/var/run/mysql5/mysqld.sock by viewing the output of this terminal command:
83        $ php -i
84
85   If not, locate the php.ini file for your version of PHP and type the path there.
86
87
882) Set Cacti permissions for the scheduled task
89        $ sudo chown -R cactiuser:cactiuser ${cactidir}/rra/ ${cactidir}/log/
90
913) prepare MySQL for Cacti.
92
93   Create a cacti MySQL user and cacti database.
94    mysql5 -u root -p (login with root password set above when prompted)
95        mysql> GRANT ALL ON cacti.* to cacti@localhost;
96        mysql> SET PASSWORD FOR cacti@localhost = PASSWORD('<my-cactidb-pwd>');
97        mysql> flush privileges;
98    mysql> create database cacti;
99    mysql> exit;
100
101   Import the cacti database.
102    cat ${cactidir}/cacti.sql | mysql5 -u root -p cacti (cacti is the db name)
103
104   Verify the Cacti Database.
105    mysql5 -u cacti -p cacti
106    mysql> show tables;
107    mysql> exit;
108
109
1104) If not existing, edit ${cactidir}/include/config.php to match your MySQL information and url path.
111
112    \$database_type = \"mysql\";
113    \$database_default = \"cacti\";
114    \$database_hostname = \"localhost\";
115    \$database_username = \"cacti\";
116    \$database_password = \"<my-cactidb-pwd>\";
117
118   If using socket file, remember to check php.ini as said in 1)
119
1205) Include in your webserver
121   If Apache, Place a symlink for Cacti inside your Apache document root.
122        # ln -s ${cactidir}  <Apache-docroot>/cacti
123   If Nginx, include appropriate config. Example is included and copied
124   in ${prefix}/etc/nginx if existing
125
126
1276) Add poller.php scheduled task. A default plist has been installed to use w php55.
128   Adjust depending on your setup
129        # ln -s ${prefix}/Library/LaunchAgents/org.macports.${name}.plist /Library/LaunchAgents/
130        # launchctl load -w /Library/LaunchAgents/org.macports.${name}.plist
131   Poller log files are ${prefix}/var/log/cacti/poller*.log
132   You can enable log rotation by using template for system newsyslog
133        # cp ${prefix}/share/examples/${name}/mp-cacti.conf /private/etc/newsyslog.d/
134
1357) If you wish to use Cacti plugins, you must perform these additional steps.
136
137   a) Download the Cacti plugin(s) you want to use and copy the unzipped directory to ${cactidir}/plugins/
138      For example:
139    ${cactidir}/plugins/weathermap/
140
141   b) In the Cacti web GUI, go to Configuration -> Plugin Management and you should see your plugin(s) listed.
142      Under 'Actions', click the the install icon to install each plugin.
143
144   c) Ensure that your Cacti user has permissions to manage the plugins
145      User Management - select a Cacti user and set Configure/Manage or View options as desired
146
147
1488) Go to http://localhost/cacti/install/index.php.
149    The default user/password is admin/admin.  Select 'New Install', enter
150    the paths for SNMP / RRDtool / PHP (adjusted to macports), and click 'Finish'.
151    You may now use Cacti at http://localhost/cacti/index.php.
152
1539) Create interface traffic graphs
154   a) Devices -> Add
155        -Fill out form for the switch or router
156        -Make sure to include the SNMP community string of the device
157        -Click the 'Create' button to add device
158
159   b) In the devices pane, click on the newly added device to open the edit pane
160        -Click 'Create Graphs for this Host' link
161        -An SNMP query is made and interfaces listed; check the interface(s) to be graphed
162        -Select a graph type from the menu in the bottom right and click the 'Create' button beside it
163
164   c) Place some or all a device's graphs on a graph tree from the Devices or Graph Management section
165
16610) If you want to use snmp on your mac, you can either use
167   * Apple default SNMP
168       # /usr/bin/snmpconf -g basic_setup
169       $ sudo launchctl load -w /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist
170   * Macports
171       $ sudo port install net-snmp +server
172       # ${prefix}/bin/snmpconf -g basic_setup
173       # mv snmpd.conf ${prefix}/etc/
174       $ sudo port load net-snmp
175"
176
177## http://wotsit.thingy.com/haj/cacti/superlinks-plugin.html
178variant superlinks description { plugin superlinks } {
179    distfiles-append    http://wotsit.thingy.com/haj/cacti/superlinks-0.8.zip
180}
181
182## http://www.network-weathermap.com/manual/latest/pages/cacti-plugin.html
183variant weathermap description { plugin weathermap } {
184    depends_lib-append   port:pcre port:gd
185    distfiles-append     http://www.network-weathermap.com/files/php-weathermap-0.97c.zip
186
187    destroot-append {
188        ## unpack in cactidir/plugins/weathermap
189        ## chown -R cactiuser cactidir/plugins/weathermap/output
190    }
191
192notes-append "
193As a reminder, you will need php*-pcre php*-gd corresponding to your PHP release target.
194You will need to enable the plugin in ${cactidir}/includes/config.php. Add the following line:
195    \$plugins\[\] = 'weathermap';
196"
197}
198
199## http://forums.cacti.net/viewtopic.php?p=173542#p173542
200variant advancedping description { template advancedping } {
201    depends_run-append   port:fping
202    distfiles-append http://forums.cacti.net/download/file.php?id=18479 \
203        http://forums.cacti.net/download/file.php?id=18480
204
205    reinplace "s|/usr/sbin/fping|${prefix}/sbin/fping|g" ss_fping.php
206}
207
208## include Mac template ?
209
210## cpu snmp removed by apple. no but some random conditions can happen, it seems
211## http://macosx.com/forums/mac-os-x-system-mac-software/273289-net-snmp-cpu-stats.html
212