source: trunk/dports/net/nedi/Portfile @ 103734

Last change on this file since 103734 was 103734, checked in by markd@…, 6 years ago

Fix broken extract with extract.mkdir and fix broken reinplace paths.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.6 KB
Line 
1# $Id: Portfile 103734 2013-03-06 06:44:59Z markd@macports.org $
2
3PortSystem      1.0
4
5name                    nedi
6version                 1.0.7
7revision                3
8categories              net
9maintainers             markd
10platforms               darwin
11
12description             Network Discovery Suite
13
14long_description        A low noise network discovery, management, and inventory \
15                        system for Cisco networks with a user friendly web interface.
16
17homepage                http://www.nedi.ch/
18master_sites            http://www.nedi.ch/pub
19
20extract.mkdir           yes
21extract.suffix          .tgz
22checksums               md5 7eb73bfc687c8efbd833b1f8f3fbd749 \
23                        rmd160 3b7895f80697f6f4a0b53e348874a8c4044e6ed4
24
25depends_lib             port:perl5.12 \
26                        path:bin/mysql_config5:mysql5 \
27                        port:p5.12-net-snmp \
28                        port:p5.12-net-ssh-perl \
29                        port:p5.12-net-telnet \
30                        port:p5.12-net-telnet-cisco \
31                        port:p5.12-libwww-perl \
32                        port:p5.12-algorithm-diff \
33                        port:p5.12-dbi \
34                        port:p5.12-dbd-mysql \
35                        port:rrdtool \
36                        port:fping
37
38
39# Set some useful variables
40set nedidir ${prefix}/share/${name}
41set rrdbin ${prefix}/bin/rrdtool
42set rrdfiles ${nedidir}/rrd
43set fpingpath ${prefix}/sbin
44set cacticlidir ${prefix}/share/cacti/cli
45
46startupitem.create      yes
47startupitem.name        nedimonitor
48startupitem.executable  ${nedidir}/moni.pl
49
50use_configure           no
51build {}
52
53destroot {
54        file mkdir ${destroot}${nedidir}
55        system "cp -R ${worksrcpath}/* ${destroot}${nedidir}"
56}
57
58post-destroot {
59# Fix general paths
60       eval reinplace "s|/usr/bin/perl|${prefix}/bin/perl5.12|g" \
61                [glob ${destroot}${nedidir}/*.pl] \
62                [glob ${destroot}${nedidir}/html/inc/*.pl] \
63                [glob ${destroot}${nedidir}/contrib/*.pl]
64
65        reinplace "s|netstat|/usr/sbin/netstat|g" \
66                ${destroot}${nedidir}/inc/libmisc.pm
67
68        reinplace "s|/etc/nedi.conf|${nedidir}/nedi.conf|g" \
69                ${destroot}${nedidir}/html/inc/libmisc.php
70
71# Fix rrdcmd location in nedi.conf
72        reinplace "s|rrdtool|${rrdbin}|g" \
73                ${destroot}${nedidir}/nedi.conf
74
75# Fix fping path
76        reinplace "s|/usr/local/sbin|${fpingpath}|g" \
77                ${destroot}${nedidir}/html/Nodes-Toolbox.php
78
79# Fix Cacti paths in nedi.conf
80        reinplace "s|/usr/bin/php /var/www/html/cacti/cli|${prefix}/bin/php ${cacticlidir}|g" \
81                ${destroot}${nedidir}/nedi.conf
82
83# Create directory for rrd files
84        xinstall -m 755 -d ${destroot}${rrdfiles}
85
86# Keep these empty directories
87        destroot.keepdirs \
88                ${destroot}${nedidir}/db/cfg \
89                ${destroot}${nedidir}/html/log \
90                ${destroot}${rrdfiles}
91
92# Rename nedi.conf to nedi.conf.sample so port upgrades don't overwrite an installed nedi.conf
93# Also set permissions on nedi.conf because it has passwords.
94        file rename ${destroot}${nedidir}/nedi.conf \
95                ${destroot}${nedidir}/nedi.conf.sample
96                system "chmod 600 ${destroot}${nedidir}/nedi.conf.sample"
97}
98
99pre-install {
100# MacPorts can create only one startupitem per portfile.  So copy nedisyslog.plist
101# from filespath and link it into /Library/LaunchDaemons as startupitem's do.
102
103        xinstall -m 755 -d ${destroot}${prefix}/etc/LaunchDaemons/org.macports.nedisyslog/
104        xinstall -m 755 ${filespath}/org.macports.nedisyslog.plist \
105                ${destroot}${prefix}/etc/LaunchDaemons/org.macports.nedisyslog/
106        system "cd /Library/LaunchDaemons && ln -sf \
107                ${prefix}/etc/LaunchDaemons/org.macports.nedisyslog/org.macports.nedisyslog.plist"
108}
109
110notes \
111  "**** To complete the NeDi OS X installation ****
112
113
1141) Setup MySQL (for new installs)
115-----------------------------------------------
116-Configure MySQL:
117        sudo -u mysql ${prefix}/lib/mysql5/bin/mysql_install_db
118
119-Start MySQL and set it to run at system boot:
120        sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
121
122-Set the root MySQL password (replace <mypassword> with your chosen password):
123        sudo ${prefix}/lib/mysql5/bin/mysqladmin -u root password <mypassword>
124
125
1262) Install PHP5 with SNMP support and MacPorts Apache
127------------------------------------------------
128        sudo port install php5 +apache2 +mysql5 +snmp
129
130        sudo ${prefix}/apache2/bin/apxs -a -e -n \"php5\" libphp5.so
131
132NOTE: Check to make sure the PHP variable \"mysql.default_socket\" is set to path
133 ${prefix}/var/run/mysql5/mysqld.sock by viewing the output of this terminal command:
134        php -i
135
136
1373) Turn on MacPorts Apache
138------------------------------------------------
139-Turn off Apple's built-in Apache (Personal Web Sharing in System Preferences).  Then execute
140   these commands:
141        cd ${prefix}/apache2/conf
142        sudo cp httpd.conf.sample httpd.conf
143
144-Edit your httpd.conf
145   Change the user/group variables in the Apache httpd.conf to be the Unix user/group that
146     you'll use to run the NeDi executable
147
148   Add an alias statement:
149        Alias /nedi \"${prefix}/share/nedi/html\"
150
151-Start Apache and set it to run at system boot:
152        sudo launchctl load -w /Library/LaunchdDaemons/org.macports.apache2.plist
153
154
1554) Configure NeDi, initialize NeDi database, and Login to NeDi
156-----------------------------------------------
157-Set NeDi owner: sudo chown -R <nedi-user>:<nedi-group> ${nedidir}
158
159-Edit nedi.conf Backend/Authen/Device Access sections: sudo pico ${nedidir}/nedi.conf
160        Leave nedi.conf permissions at 600 to protect your network passwords!
161
162backend         MSQ
163dbpass          <nedidb-password>
164authuser        mysql
165
166comm <my-community-string> (community string of your Cisco devices)
167<usr> <pass> <enablepass> (user/pass of your Cisco devices)
168
169-Initialize the NeDi database:
170        cd ${nedidir}
171        sudo ./nedi.pl -i
172        When prompted for \"MySQL admin user:\" and enter 'root' and then MySQL root password.
173
174-Verify the NeDi DB:
175        mysql -u root -p
176        mysql> use nedi;
177        mysql> show tables;
178        mysql> exit;
179
180-Login to the NeDi web interface: http://localhost/nedi
181        Initial user/pass is 'admin'/'admin'
182
183
1845) Discover Your Network with NeDi
185-----------------------------------------------
186-Edit nedi.conf Device Acc. variables: sudo pico ${nedidir}/nedi.conf
187
188comm <my-community-string>
189<usr>  <pass>  <enablepass>
190
191-Make any other desired changes in nedi.conf
192
193-Start NeDi data collection:
194        cd ${nedidir}
195        sudo -u <nedi-user> nedi.pl -pr (options shown set CDP and routing tables for discovery)
196
197-Put a command in the crontab to discover your network at regular intervals.
198        A typical interval is 1 hour; to get accurate NeDi rrdtool graphs at
199        NeDi's default settings you must run NeDi at 1 hour intervals.
200        Otherwise, you must adjust NeDi's default rrdtool settings.  To run
201        NeDi every hour, the cron entry is:
202
2030 * * * * cd ${nedidir} ; ./nedi.pl -pr >> /dev/null 2>&1
204
205
2066) Set NeDi to receive device alerts, syslogs, and SNMP traps.  (optional)
207-----------------------------------------------
208-To enable NeDi alerts
209
210        sudo launchctl load -w /Library/LaunchDaemons/org.macports.nedimonitor.plist
211
212-To enable the NeDi syslog daemon:
213
214        sudo launchctl load -w /Library/LaunchDaemons/org.macports.nedisyslog.plist"
Note: See TracBrowser for help on using the repository browser.