# $Id: Portfile,v 1.14 2006/05/19 16:33:23 markd Exp $
PortSystem      1.0

name                    moodss
version                 21.2
revision		7
categories              net
maintainers             markd@opendarwin.org

description             Modular Object Oriented Dynamic Spreadsheet - A graphical \
			monitoring application that supports external modules \
			including Nagios plugins.  It supports SNMP when used with \
			the Scotty Tcl extensions package.

long_description        ${description}
homepage                http://moodss.sourceforge.net/
platforms               darwin
master_sites            sourceforge
checksums               md5 8e48defc0f98a1346292d31ab9d226c2
use_bzip2		yes

depends_lib             port:tcl \
			port:tk \
			port:tktable \
			port:blt \
			port:scotty \
			port:sqlite3

patchfiles		patch-Makefile

variant nagios_plugins {
	depends_lib-append      port:nagios-plugins
}

variant mysqltcl {
        depends_lib-append      port:mysqltcl
}

variant rproject {                    
        depends_lib-append      port:r
}

use_configure		no

set moodssdir ${prefix}/share/moodss

post-patch {
# Set install paths for DarwinPorts
	reinplace "s|__DESTROOT__|${destroot}|g" \
                "${worksrcpath}/Makefile"
	reinplace "s|__PREFIX__|${prefix}|g" \
                "${worksrcpath}/Makefile"

# Set the location of the moomps resource file to where the moomps port puts it
        reinplace "s|/etc/moomps/rc|${prefix}/etc/moomps/rc|g" \
                "${worksrcpath}/global.tcl"

# Set default Nagios plugin path for DP's nagios-plugins port
#   When plugin path is set, '/<plugin_path>/check_' may be ommitted from Nagios check commands

	reinplace "s|/usr/lib/nagios/plugins/|${prefix}/libexec/nagios/|g" \
                "${worksrcpath}/nagios/nagios.tcl"

# Copy a fixed snmptrap file
        file copy -force ${filespath}/snmptrap.tcl ${worksrcpath}/snmptrap
}

post-activate {
ui_msg "\n
To enable the moodss ping module you must activate the ${prefix}/bin/nmicmpd
daemon (a component of the dependent package Scotty).  To do this:

   1) Edit the /etc/services file as described in ${prefix}/lib/moodss/ping/INSTALL.

   2) OS X 10.4 (see below for 10.3) - Load the nmicmpd LaunchD script installed by DarwinPorts' Scotty dependency.
        sudo launchctl load -w /Library/LaunchDaemons/org.darwinports.nmicmpd.plist

   3) Reboot and test the nmicmpd daemon:
        telnet localhost nmicmp
        ps -ax |grep nmicmpd (The daemon loads only when requested and unloads afterwards)

      Or you may test the ping module within moodss:
	moodss ping        

   Additional instructions for OS X 10.3:  
    a) A startup item was created in /Library/StartupItems
        Add \"NMICMPD=-YES-\" to the /etc/hostconfig file to run nmicmpd at system boot.

    b) Add an xinetd entry for nmicmp as described in ${prefix}/lib/moodss/ping/INSTALL.
        
    c) Reboot and test as shown in step 3 above.

\n"
}
