source: trunk/dports/net/nedi/Portfile

Last change on this file was 151873, checked in by mojca@…, 13 months ago

nedi: switch to perl5.24 (#52081)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.0 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 151873 2016-08-23 12:45:27Z ryandesign@macports.org $
3
4PortSystem          1.0
5PortGroup           perl5 1.0
6
7name                nedi
8version             1.0.9
9revision            3
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.24
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    copy {*}[glob ${worksrcpath}/*] ${destroot}${nedidir}
66}
67
68post-destroot {
69
70# Fix general paths
71    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
119pre-activate {
120    # nedi < 1.0.9 installed this symlink directly, bypassing the destroot.
121    # Remove it if found to prevent activation failure.
122    set f /Library/LaunchDaemons/org.macports.nedisyslog.plist
123    if {![catch {file type ${f}}] && [registry_file_registered ${f}] == "0"} {
124        if {[catch {delete ${f}}]} {
125            ui_warn "Cannot delete ${f}; please remove it manually"
126        }
127    }
128}
129
130notes \
131  "**** To complete the NeDi OS X installation ****
132
133
1341) Setup MySQL (for new installs)
135-----------------------------------------------
136-Configure MySQL:
137        sudo -u mysql ${prefix}/lib/mysql5/bin/mysql_install_db
138
139-Start MySQL and set it to run at system boot:
140    sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
141
142-Set the root MySQL password (replace <mypassword> with your chosen password):
143    sudo ${prefix}/lib/mysql5/bin/mysqladmin -u root password <mypassword>
144
145
1462) Install PHP5 with SNMP support and MacPorts Apache
147------------------------------------------------
148    sudo port install php5 +apache2 +mysql5 +snmp
149
150    sudo ${prefix}/apache2/bin/apxs -a -e -n \"php5\" libphp5.so
151
152NOTE: Check to make sure the PHP variable \"mysql.default_socket\" is set to path
153 ${prefix}/var/run/mysql5/mysqld.sock by viewing the output of this terminal command:
154        php -i
155
156
1573) Turn on MacPorts Apache
158------------------------------------------------
159-Turn off Apple's built-in Apache (Personal Web Sharing in System Preferences).  Then execute
160   these commands:
161    cd ${prefix}/apache2/conf
162    sudo cp httpd.conf.sample httpd.conf
163
164-Edit your httpd.conf
165   Change the user/group variables in the Apache httpd.conf to be the Unix user/group that
166     you'll use to run the NeDi executable
167
168   Add an alias statement:
169    Alias /nedi \"${prefix}/share/nedi/html\"
170
171-Start Apache and set it to run at system boot:
172    sudo launchctl load -w /Library/LaunchdDaemons/org.macports.apache2.plist
173
174
1754) Configure NeDi, initialize NeDi database, and Login to NeDi
176-----------------------------------------------
177-Set NeDi owner: sudo chown -R <nedi-user>:<nedi-group> ${nedidir}
178
179-Edit nedi.conf Backend/Authen/Device Access sections: sudo pico ${nedidir}/nedi.conf
180    Leave nedi.conf permissions at 600 to protect your network passwords!
181
182backend     MSQ
183dbpass      <nedidb-password>
184authuser    mysql
185
186comm <my-community-string> (community string of your Cisco devices)
187<usr> <pass> <enablepass> (user/pass of your Cisco devices)
188
189-Initialize the NeDi database:
190    cd ${nedidir}
191    sudo ./nedi.pl -i
192    When prompted for \"MySQL admin user:\" and enter 'root' and then MySQL root password.
193
194-Verify the NeDi DB:
195        mysql -u root -p
196        mysql> use nedi;
197        mysql> show tables;
198        mysql> exit;
199
200-Login to the NeDi web interface: http://localhost/nedi
201    Initial user/pass is 'admin'/'admin'
202
203
2045) Discover Your Network with NeDi
205-----------------------------------------------
206-Edit nedi.conf Device Acc. variables: sudo pico ${nedidir}/nedi.conf
207
208comm <my-community-string>
209<usr>  <pass>  <enablepass>
210
211-Make any other desired changes in nedi.conf
212
213-Start NeDi data collection:
214    cd ${nedidir}
215    sudo -u <nedi-user> nedi.pl -pr (options shown set CDP and routing tables for discovery)
216
217-Put a command in the crontab to discover your network at regular intervals.
218    A typical interval is 1 hour; to get accurate NeDi rrdtool graphs at
219    NeDi's default settings you must run NeDi at 1 hour intervals.
220    Otherwise, you must adjust NeDi's default rrdtool settings.  To run
221    NeDi every hour, the cron entry is:
222
2230 * * * * cd ${nedidir} ; ./nedi.pl -pr >> /dev/null 2>&1
224
225
2266) Set NeDi to receive device alerts, syslogs, and SNMP traps.  (optional)
227-----------------------------------------------
228-To enable NeDi alerts
229
230    sudo launchctl load -w /Library/LaunchDaemons/org.macports.nedimonitor.plist
231
232-To enable the NeDi syslog daemon:
233
234    sudo launchctl load -w /Library/LaunchDaemons/org.macports.nedisyslog.plist"
235
236livecheck.type      regex
237livecheck.url       http://www.nedi.ch/download/
238livecheck.regex     "current\.*${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
Note: See TracBrowser for help on using the repository browser.