# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           perl5 1.0

name                rancid
version             3.13
revision            1
categories          net
license             BSD-old
maintainers         nomaintainer

description         Really Awesome New Cisco confIg Differ

long_description    Rancid maintains a CVS/SVN/git repository of router and \
                    device config files.  It emails you when changes \
                    occur and tells you what commands were changed.

homepage            https://www.shrubbery.net/${name}
master_sites        ftp://ftp.shrubbery.net/pub/rancid/

checksums           rmd160  7600e3a8ac7e7dd301cce8b4b90d3a68dd9d5672 \
                    sha256  7241d2972b1f6f76a28bdaa0e7942b1257e08b404a15d121c9dee568178f8bf5 \
                    size    506297

perl5.branches      5.34
depends_lib-append  port:perl${perl5.major} \
                    port:p${perl5.major}-lockfile-simple \
                    path:lib/libssl.dylib:openssl

patchfiles          patch-etc-Makefile.am.diff \
                    patch-bin-Makefile.in.diff

post-patch {
# Set path for lg.conf.sample so Looking Glass will work
    reinplace "s|@prefix@/bin|@prefix@/libexec/rancid:@prefix@/bin|g" \
        ${worksrcpath}/etc/lg.conf.sample.in
}

configure.env       PERLV_PATH=${perl5.bin}
configure.args      --localstatedir=${prefix}/var/${name} \
                    --bindir=${prefix}/libexec/${name} \
                    --sysconfdir=${prefix}/etc/${name} \
                    --mandir=\\\${prefix}/share/man

post-destroot {
    system "ln -s -f ${prefix}/libexec/${name}/rancid-cvs ${destroot}${prefix}/bin/rancid-cvs"
    system "ln -s -f ${prefix}/libexec/${name}/rancid-run ${destroot}${prefix}/bin/rancid-run"
}

notes "
#### To complete the RANCID installation ####

Copy the sample .cloginrc file to the RANCID user's home directory,\
make sure it isn't world readable, and edit it according to your needs.

	cp ${prefix}/share/rancid/cloginrc.sample ~/.cloginrc
	sudo chmod 640 ~/.cloginrc

See the README file in ${prefix}/share/rancid for more information.


To use the optional looking glass service to run status check commands\
(show ip route, show run, etc) against your devices from a web form,\
perform these steps:

1) Copy the looking glass files and set permissions.

   Use the lg.conf.sample looking glass configuration file as a start.
	cd ${prefix}/etc/rancid
	cp lg.conf.sample lg.conf

   Make an /lg folder in your Apache document root and copy lg files
	sudo mkdir -p <Apache-directory>/lg/log
	cd <Apache-directory>/lg
	sudo cp ${prefix}/share/rancid/index.html ./
	sudo cp ${prefix}/share/rancid/lgnotes.html ./

   Copy the .cgi's to the Apache document root
	cd <Apache-directory>/lg
	cp ${prefix}/libexec/rancid/lg.cgi      ./
	cp ${prefix}/libexec/rancid/lgform.cgi  ./

   Set the file permissions.  The rancid-user should also be the Apache user.
	sudo chown -R <rancid-user>:<rancid-user> <Apache-docroot>/lg


2) To enable the cgi's in this directory to run, set this line in your httpd.conf:

	<Directory /Library/WebServer/Documents/lg>
   		Options ExecCGI
	</Directory>


3) Goto url http://localhost/lg with a web browser to use the looking glass.

#### WARNING DATABASE FORMAT CHANGE ####

Note that the router.db format has changed. The file separator is now a \
semicolon from a colon.

This is to better support IPv6 addresses in the file.

#### WARNING DATABASE FORMAT CHANGE ####
"

livecheck.type      regex
livecheck.url       [lindex ${master_sites} 0]
livecheck.regex     ${name}-(\[0-9.\]+)\\.
