Ticket #4111: Portfile.2

File Portfile.2, 7.1 KB (added by dports@…, 19 years ago)

Revised NRG Portfile

Line 
1# $Id: Portfile,v 1.4 2004/12/03 19:41:51 jberry Exp $
2
3PortSystem      1.0
4
5name                            nrg   
6version                         0.99.24
7
8categories                      net
9maintainers                     dports@mac.com
10platforms                       darwin
11
12description                     Network Resource Grapher
13
14long_description                NRG is an RRDtool front-end tool to monitor traffic and load \
15                                on network links or any other resource utilization source.  It \
16                                automatically creates and maintains web pages and RRDtool databases, \
17                                while providing short and long-term graph web pages just like MRTG.
18
19homepage                        http://nrg.hep.wisc.edu/
20                                       
21master_sites                    ftp://nrg.hep.wisc.edu/pub/src/nrg/ \
22                                ftp://nrg.hep.wisc.edu/pub/src/nrg/old-versions
23
24checksums                       md5 09a1125c7b9430c260f902ce20bd9d3e
25
26depends_lib                     port:rrdtool
27
28patchfiles                      patch-nrg-discover-netdev.in.diff \
29                                patch-nrg-discover-tcp.in.diff \
30                                patch-roverpingd-receive.c.diff
31
32configure.args                  --build=powerpc-unknown-freebsd \
33                                --prefix=${prefix}/var/${name} \
34                                --bindir=${prefix}/bin \
35                                --sysconfdir=${prefix}/etc/${name} \
36                                --datadir=${prefix}/share \
37                                CFLAGS="-D__FreeBSD__"
38
39build.target                    pingd
40destroot.target                 install.pingd install
41
42# Maintain empty directories
43destroot.keepdirs ${destroot}${prefix}/var/${name}/archive
44
45post-patch {
46
47### NET-SNMP Bugs ###
48
49        reinplace "s|@SNMPWALK@|@SNMPWALK@ -v1|g" \
50                "${worksrcpath}/discoverers/nrg-discover-errors.in"
51
52        reinplace "s|@SNMPGET@|@SNMPGET@ -v1|g" \
53                ${worksrcpath}/discoverers/nrg-discover-errors.in \
54                ${worksrcpath}/discoverers/nrg-discover-netdev.in
55
56        reinplace "s|\$args \$host \$comm_str|\$args -c \$comm_str \$host|g" \
57                ${worksrcpath}/discoverers/nrg-discover-errors.in \
58                ${worksrcpath}/discoverers/nrg-discover-snmpd.in \
59                ${worksrcpath}/discoverers/nrg-discover-netdev.in
60
61        reinplace "s|/usr/bin/snmpget|/usr/bin/snmpget -v1|g" \
62                ${worksrcpath}/discoverers/nrg-discover-netdev.in \
63                ${worksrcpath}/discoverers/nrg-discover-snmpd.in
64
65        reinplace "s|/usr/bin/snmpwalk|/usr/bin/snmpwalk -v1|g" \
66                ${worksrcpath}/discoverers/nrg-discover-snmpd.in
67
68        reinplace "s|\$snmp_args \$system -c \$passwd|\$snmp_args -c \$passwd \$system|g" \
69                "${worksrcpath}/etc/run-star-tail.pl.in"
70
71### Misc bugs ###
72
73        reinplace "s|-idx||g" \
74                "${worksrcpath}/examples/Site.mconf"
75
76        reinplace "s|/usr/local/nrg-test|@prefix@|g" \
77                "${worksrcpath}/examples/Default.conf.in"
78
79        reinplace "s|*ping-data|*ping-latency|g" \
80                "${worksrcpath}/examples/Default.conf.in"
81
82        reinplace "s|\$target-\$host-ping-data|\$target-\$host-ping-latency|g" \
83                "${worksrcpath}/templates/discover-pingd.tm"
84
85### roverpingd fix ###
86
87        reinplace "s|<malloc.h>|<stdlib.h>|g" \
88                ${worksrcpath}/roverpingd/send.c \
89                ${worksrcpath}/roverpingd/pingd.c \
90                ${worksrcpath}/roverpingd/read_list.c
91
92        reinplace "s|<values.h>|<limits.h>|g" \
93                "${worksrcpath}/roverpingd/write_stats.c"
94
95        reinplace "s|MAXINT|INT_MAX|g" \
96                "${worksrcpath}/roverpingd/write_stats.c"
97       
98#### Fix paths ####
99
100        reinplace "s|@bindir@/rrdtool|${prefix}/bin/rrdtool|g" \
101                "${worksrcpath}/etc/run-star-head.pl.in"
102
103        eval reinplace "s|@prefix@|${prefix}|g" [glob ${worksrcpath}/templates/*.in]
104
105        reinplace "s|@prefix@/bin|@bindir@|g" ${worksrcpath}/examples/NRG.mconf.in
106
107        reinplace "s|/usr/local/web/html|/Library/WebServer/Documents|g" \
108                ${worksrcpath}/examples/Makefile.ops.in ${worksrcpath}/examples/Site.mconf
109
110        reinplace "s|Somesite's NRG Home Page|NRG Home Page|g" \
111                "${worksrcpath}/examples/Makefile.ops.in"
112
113        reinplace "s|@prefix@/etc|@sysconfdir@|g" \
114                ${worksrcpath}/discoverers/nrg-discover-pingd.in \
115                ${worksrcpath}/collectors/nrg-pingdstat.in \
116                ${worksrcpath}/roverpingd/pingd.h.in
117
118        eval reinplace "s|@prefix@/bin|@bindir@|g" \
119                [glob ${worksrcpath}/discoverers/*.in]
120
121        reinplace "s|exec_prefix = @prefix@|exec_prefix = ${destroot}@prefix@|g" \
122                ${worksrcpath}/Makefile.in
123
124        reinplace "s|prefix = @prefix@|prefix = ${destroot}@prefix@|g" \
125                ${worksrcpath}/Makefile.in
126
127        reinplace "s|BIN_DIR = @bindir@|BIN_DIR = ${destroot}@bindir@|g" \
128                ${worksrcpath}/Makefile.in
129
130        reinplace "s|ETC_DIR = \${prefix}/etc|ETC_DIR = ${destroot}@sysconfdir@|g" \
131                ${worksrcpath}/Makefile.in
132
133        reinplace "s|TEMPLATE_DIR = \${prefix}/templates|TEMPLATE_DIR = ${destroot}@prefix@/templates|g" \
134                ${worksrcpath}/Makefile.in
135
136        reinplace "s|EXAMPLE_DIR = \${prefix}/examples|EXAMPLE_DIR = ${destroot}@datadir@/doc/nrg/examples|g" \
137                ${worksrcpath}/Makefile.in
138
139        reinplace "s|HTML_DIR = \${prefix}/html|HTML_DIR = ${destroot}@datadir@/doc/nrg/html|g" \
140                ${worksrcpath}/Makefile.in
141
142        reinplace "s|ARCHIVE_DIR = \${prefix}/archive|ARCHIVE_DIR = ${destroot}@prefix@/archive|g" \
143                ${worksrcpath}/Makefile.in
144
145        reinplace "s|CONTRIB_DIR = \${prefix}/contrib|CONTRIB_DIR = ${destroot}@datadir@/doc/nrg/contrib|g" \
146                ${worksrcpath}/Makefile.in
147
148}
149
150post-destroot {
151
152# Copy roverpingd.init to contrib
153xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}/contrib
154xinstall -m 755 ${worksrcpath}/contrib/roverpingd.init ${destroot}${prefix}/share/doc/${name}/contrib
155
156# Install images to ./share/doc and in Apache doc root
157xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}/images
158eval xinstall -m 755 [glob ${worksrcpath}/images/*.*] ${destroot}${prefix}/share/doc/${name}/images
159
160xinstall -d 755 ${destroot}/Library/WebServer/Documents/${name}/icons
161eval xinstall -m 755 [glob ${worksrcpath}/images/*.*] ${destroot}/Library/WebServer/Documents/${name}/icons
162system "ln -s -f /Library/WebServer/Documents/nrg ${destroot}${prefix}/var/${name}/web"
163
164}
165
166post-activate {
167# Alert user that NRG data directory and symlinks were created and where in case they want to
168# change them, and give a few operating instructions
169
170ui_msg "\nThe NRG data directory was created in the Apache document root, NRG icons copied
171into ../nrg/icons, and the symlink ${prefix}/var/${name}/web -> /Library/WebServer/Documents/nrg
172created.  Now modify your httpd.conf file for NRG:
173
174Uncomment the lines:    AddHandler cgi-script .cgi
175                        LoadModule expires_module   libexec/httpd/mod_expires.so
176                        AddModule mod_expires.c
177
178Add the directives:     <Directory /Library/WebServer/Documents/nrg>
179                           Options ExecCGI
180                        </Directory>
181                       
182                        <Files \"*.gif\">
183                           ExpiresActive On
184                           ExpiresDefault M5
185                        </Files>
186
187NOTE: If /Library/WebServer/Documents is not your Apache document root create an nrg directory
188in the correct path, copy the icons to nrg/icons from ${prefix}/share/doc/nrg/images, set symlink
189${prefix}/var/nrg/web to point to it, and modify the NRG Makefile and Site.mconf files in
190${prefix}/var/${name} accordingly.
191
192
193To use NRG:  Set meta-configuration strings in the Site.mconf file according to the
194example meta-configuration strings in ${prefix}/share/doc/nrg/examples.  Then create rrdfiles
195and html graph pages (or update them after Site.mconf changes) with these two commands:
196
197        make rediscover
198        make notify
199
200Set ${prefix}/var/${name}/run-nrg in cron to set NRG to poll your devices every 5 minutes.
201
202Be sure to read the documentation in ${prefix}/share/doc/nrg/html for creating custom graphs
203or for more information.\n"
204}
205