Ticket #4111: Portfile.5

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

Revised NRG Portfile - I mean it now

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|@prefix@/bin|@bindir@|g" \
101                ${worksrcpath}/etc/run-star-head.pl.in \
102                ${worksrcpath}/examples/NRG.mconf.in
103
104        eval reinplace "s|@prefix@/bin|@bindir@|g" \
105                [glob ${worksrcpath}/discoverers/*.in]
106
107        reinplace "s|@prefix@/etc|@sysconfdir@|g" \
108                ${worksrcpath}/discoverers/nrg-discover-pingd.in \
109                ${worksrcpath}/collectors/nrg-pingdstat.in \
110                ${worksrcpath}/roverpingd/pingd.h.in
111
112        eval reinplace "s|@prefix@|${prefix}|g" [glob ${worksrcpath}/templates/*.in]
113
114        reinplace "s|/usr/local/web/html|/Library/WebServer/Documents|g" \
115                ${worksrcpath}/examples/Makefile.ops.in ${worksrcpath}/examples/Site.mconf
116
117        reinplace "s|Somesite's NRG Home Page|NRG Home Page|g" \
118                "${worksrcpath}/examples/Makefile.ops.in"
119
120        reinplace "s|exec_prefix = @prefix@|exec_prefix = ${destroot}@prefix@|g" \
121                ${worksrcpath}/Makefile.in
122
123        reinplace "s|prefix = @prefix@|prefix = ${destroot}@prefix@|g" \
124                ${worksrcpath}/Makefile.in
125
126        reinplace "s|BIN_DIR = @bindir@|BIN_DIR = ${destroot}@bindir@|g" \
127                ${worksrcpath}/Makefile.in
128
129        reinplace "s|ETC_DIR = \${prefix}/etc|ETC_DIR = ${destroot}@sysconfdir@|g" \
130                ${worksrcpath}/Makefile.in
131
132        reinplace "s|TEMPLATE_DIR = \${prefix}/templates|TEMPLATE_DIR = ${destroot}@prefix@/templates|g" \
133                ${worksrcpath}/Makefile.in
134
135        reinplace "s|EXAMPLE_DIR = \${prefix}/examples|EXAMPLE_DIR = ${destroot}@datadir@/doc/nrg/examples|g" \
136                ${worksrcpath}/Makefile.in
137
138        reinplace "s|HTML_DIR = \${prefix}/html|HTML_DIR = ${destroot}@datadir@/doc/nrg/html|g" \
139                ${worksrcpath}/Makefile.in
140
141        reinplace "s|ARCHIVE_DIR = \${prefix}/archive|ARCHIVE_DIR = ${destroot}@prefix@/archive|g" \
142                ${worksrcpath}/Makefile.in
143
144        reinplace "s|CONTRIB_DIR = \${prefix}/contrib|CONTRIB_DIR = ${destroot}@datadir@/doc/nrg/contrib|g" \
145                ${worksrcpath}/Makefile.in
146
147}
148
149post-destroot {
150
151# Copy roverpingd.init to contrib
152xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}/contrib
153xinstall -m 755 ${worksrcpath}/contrib/roverpingd.init ${destroot}${prefix}/share/doc/${name}/contrib
154
155# Install images to ./share/doc and in Apache doc root
156xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}/images
157eval xinstall -m 755 [glob ${worksrcpath}/images/*.*] ${destroot}${prefix}/share/doc/${name}/images
158
159xinstall -d 755 ${destroot}/Library/WebServer/Documents/${name}/icons
160eval xinstall -m 755 [glob ${worksrcpath}/images/*.*] ${destroot}/Library/WebServer/Documents/${name}/icons
161system "ln -s -f /Library/WebServer/Documents/nrg ${destroot}${prefix}/var/${name}/web"
162
163}
164
165post-activate {
166# Alert user that NRG data directory and symlinks were created and where in case they want to
167# change them, and give a few operating instructions
168
169ui_msg "\nThe NRG data directory was created in the Apache document root, NRG icons
170copied into ../nrg/icons, and symlink ${prefix}/var/${name}/web ->
171/Library/WebServer/Documents/nrg created.  Now modify your httpd.conf file
172for NRG:
173
174Uncomment lines:   AddHandler cgi-script .cgi
175                   LoadModule expires_module   libexec/httpd/mod_expires.so
176                   AddModule mod_expires.c
177
178Add 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
188an nrg directory in the correct path, copy the icons to nrg/icons from
189${prefix}/share/doc/nrg/images, set symlink ${prefix}/var/nrg/web to point
190to it, and modify the NRG Makefile and Site.mconf files in
191${prefix}/var/${name} accordingly.
192
193
194To use NRG:
195
1961) Set meta-configuration strings in the Site.mconf file according to the
197   example meta-configuration strings in ${prefix}/share/doc/nrg/examples.
198
1992) Have NRG generate rrdfiles and html graph pages (or update them after
200   Site.mconf changes) with these commands:
201
202        cd ${prefix}/var/${name}
203        make rediscover
204        make notify
205
2063) Set ${prefix}/var/${name}/run-nrg in cron to set NRG to poll your devices
207   every 5 minutes.
208
209Be sure to read the documentation in ${prefix}/share/doc/${name}/html for
210creating custom graphs or for more information.\n"
211}
212