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

Last change on this file since 143393 was 143393, checked in by mojca@…, 3 years ago

nedi: switch to perl5.22 using the perl portgroup (#48365, untested)

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