From 989312339ea2e16579803a48700628c5469e327a Mon Sep 17 00:00:00 2001 From: Tar Committer Date: Mon, 12 Jan 2004 03:17:26 +0000 Subject: Imported from rancid-2.3.rc1.tar.gz. --- share/Makefile.am | 53 +++++++ share/Makefile.in | 401 +++++++++++++++++++++++++++++++++++++++++++++++++ share/README.misc | 24 +++ share/cisco-load.exp | 338 +++++++++++++++++++++++++++++++++++++++++ share/cisco-reload.exp | 147 ++++++++++++++++++ share/downreport.in | 81 ++++++++++ share/getipacctg | 121 +++++++++++++++ share/index.html | 12 ++ share/lgnotes.html | 61 ++++++++ share/rtrfilter.in | 164 ++++++++++++++++++++ 10 files changed, 1402 insertions(+) create mode 100644 share/Makefile.am create mode 100644 share/Makefile.in create mode 100644 share/README.misc create mode 100644 share/cisco-load.exp create mode 100644 share/cisco-reload.exp create mode 100644 share/downreport.in create mode 100644 share/getipacctg create mode 100644 share/index.html create mode 100644 share/lgnotes.html create mode 100644 share/rtrfilter.in (limited to 'share') diff --git a/share/Makefile.am b/share/Makefile.am new file mode 100644 index 0000000..858ad27 --- /dev/null +++ b/share/Makefile.am @@ -0,0 +1,53 @@ +## Process this file with automake to produce Makefile.in +## A Makefile.in is supplied, in case you do not have automake. + +## $Id: Makefile.am,v 1.7 2004/01/11 03:43:50 heas Exp $ +## +## Copyright (C) 1997-2004 by Terrapin Communications, Inc. +## All rights reserved. +## +## This software may be freely copied, modified and redistributed +## without fee for non-commerical purposes provided that this license +## remains intact and unmodified with any RANCID distribution. +## +## There is no warranty or other guarantee of fitness of this software. +## It is provided solely "as is". The author(s) disclaim(s) all +## responsibility and liability with respect to this software's usage +## or its effect upon hardware, computer systems, other software, or +## anything else. +## +## Except where noted otherwise, rancid was written by and is maintained by +## Henry Kilmer, John Heasley, Andrew Partan, Pete Whiting, and Austin Schutz. +## + +#AUTOMAKE_OPTIONS=foreign no-dependencies +AUTOMAKE_OPTIONS=foreign + +pkgdata_SCRIPTS= rtrfilter downreport +dist_pkgdata_SCRIPTS=getipacctg +dist_pkgdata_DATA=README.misc cisco-load.exp cisco-reload.exp \ + index.html lgnotes.html + +EXTRA_DIST = rtrfilter.in downreport.in + +CLEANFILES= downreport + +all: + +# auto_edit does the autoconf variable substitution. This allows the +# substitution to have the full expansion of the variables, e.g.: $sysconfdir +# will be /prefix/etc instead of ${prefix}/etc. +# +# This is a bit of a PITA, but is the method recommended by the autoconf +# documentation. +auto_edit = sed \ + -e 's,@prefix\@,$(prefix),g' \ + -e 's,@localstatedir\@,$(localstatedir),g' \ + -e 's,@sysconfdir\@,$(sysconfdir),g' \ + -e 's,@pkgdatadir\@,$(pkgdatadir),g' + +downreport: Makefile $(srcdir)/downreport.in + rm -f downreport downreport.tmp; \ + $(auto_edit) $(srcdir)/downreport.in >downreport.tmp; \ + chmod +x downreport.tmp; \ + mv downreport.tmp downreport diff --git a/share/Makefile.in b/share/Makefile.in new file mode 100644 index 0000000..04c1dd1 --- /dev/null +++ b/share/Makefile.in @@ -0,0 +1,401 @@ +# Makefile.in generated by automake 1.8 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +subdir = share +DIST_COMMON = $(dist_pkgdata_DATA) $(dist_pkgdata_SCRIPTS) \ + $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(srcdir)/rtrfilter.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/include/config.h +CONFIG_CLEAN_FILES = rtrfilter +am__installdirs = $(DESTDIR)$(pkgdatadir) $(DESTDIR)$(pkgdatadir) $(DESTDIR)$(pkgdatadir) +dist_pkgdataSCRIPT_INSTALL = $(INSTALL_SCRIPT) +pkgdataSCRIPT_INSTALL = $(INSTALL_SCRIPT) +SCRIPTS = $(dist_pkgdata_SCRIPTS) $(pkgdata_SCRIPTS) +SOURCES = +DIST_SOURCES = +dist_pkgdataDATA_INSTALL = $(INSTALL_DATA) +DATA = $(dist_pkgdata_DATA) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMINMAILPLUS = @ADMINMAILPLUS@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMM = @COMM@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CVS = @CVS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DIFF = @DIFF@ +DIFF_CMD = @DIFF_CMD@ +DIRNAME = @DIRNAME@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENV_PATH = @ENV_PATH@ +EXEEXT = @EXEEXT@ +EXPECT_PATH = @EXPECT_PATH@ +FIND = @FIND@ +GREP = @GREP@ +ID = @ID@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LG_PING_CMD = @LG_PING_CMD@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAILPLUS = @MAILPLUS@ +MAKE = @MAKE@ +MAKEINFO = @MAKEINFO@ +MKDIR = @MKDIR@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERLV = @PERLV@ +PERLV_PATH = @PERLV_PATH@ +PING_PATH = @PING_PATH@ +RSH = @RSH@ +SENDMAIL = @SENDMAIL@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SORT = @SORT@ +SSH = @SSH@ +STRIP = @STRIP@ +TAR = @TAR@ +TELNET = @TELNET@ +TOUCH = @TOUCH@ +U = @U@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ + +#AUTOMAKE_OPTIONS=foreign no-dependencies +AUTOMAKE_OPTIONS = foreign +pkgdata_SCRIPTS = rtrfilter downreport +dist_pkgdata_SCRIPTS = getipacctg +dist_pkgdata_DATA = README.misc cisco-load.exp cisco-reload.exp \ + index.html lgnotes.html + +EXTRA_DIST = rtrfilter.in downreport.in +CLEANFILES = downreport + +# auto_edit does the autoconf variable substitution. This allows the +# substitution to have the full expansion of the variables, e.g.: $sysconfdir +# will be /prefix/etc instead of ${prefix}/etc. +# +# This is a bit of a PITA, but is the method recommended by the autoconf +# documentation. +auto_edit = sed \ + -e 's,@prefix\@,$(prefix),g' \ + -e 's,@localstatedir\@,$(localstatedir),g' \ + -e 's,@sysconfdir\@,$(sysconfdir),g' \ + -e 's,@pkgdatadir\@,$(pkgdatadir),g' + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign share/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign share/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +rtrfilter: $(top_builddir)/config.status $(srcdir)/rtrfilter.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +install-dist_pkgdataSCRIPTS: $(dist_pkgdata_SCRIPTS) + @$(NORMAL_INSTALL) + $(mkdir_p) $(DESTDIR)$(pkgdatadir) + @list='$(dist_pkgdata_SCRIPTS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f $$d$$p; then \ + f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ + echo " $(dist_pkgdataSCRIPT_INSTALL) $$d$$p $(DESTDIR)$(pkgdatadir)/$$f"; \ + $(dist_pkgdataSCRIPT_INSTALL) $$d$$p $(DESTDIR)$(pkgdatadir)/$$f; \ + else :; fi; \ + done + +uninstall-dist_pkgdataSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(dist_pkgdata_SCRIPTS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ + echo " rm -f $(DESTDIR)$(pkgdatadir)/$$f"; \ + rm -f $(DESTDIR)$(pkgdatadir)/$$f; \ + done +install-pkgdataSCRIPTS: $(pkgdata_SCRIPTS) + @$(NORMAL_INSTALL) + $(mkdir_p) $(DESTDIR)$(pkgdatadir) + @list='$(pkgdata_SCRIPTS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f $$d$$p; then \ + f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ + echo " $(pkgdataSCRIPT_INSTALL) $$d$$p $(DESTDIR)$(pkgdatadir)/$$f"; \ + $(pkgdataSCRIPT_INSTALL) $$d$$p $(DESTDIR)$(pkgdatadir)/$$f; \ + else :; fi; \ + done + +uninstall-pkgdataSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(pkgdata_SCRIPTS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ + echo " rm -f $(DESTDIR)$(pkgdatadir)/$$f"; \ + rm -f $(DESTDIR)$(pkgdatadir)/$$f; \ + done +uninstall-info-am: +install-dist_pkgdataDATA: $(dist_pkgdata_DATA) + @$(NORMAL_INSTALL) + $(mkdir_p) $(DESTDIR)$(pkgdatadir) + @list='$(dist_pkgdata_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " $(dist_pkgdataDATA_INSTALL) $$d$$p $(DESTDIR)$(pkgdatadir)/$$f"; \ + $(dist_pkgdataDATA_INSTALL) $$d$$p $(DESTDIR)$(pkgdatadir)/$$f; \ + done + +uninstall-dist_pkgdataDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_pkgdata_DATA)'; for p in $$list; do \ + f="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " rm -f $(DESTDIR)$(pkgdatadir)/$$f"; \ + rm -f $(DESTDIR)$(pkgdatadir)/$$f; \ + done +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(SCRIPTS) $(DATA) +installdirs: + $(mkdir_p) $(DESTDIR)$(pkgdatadir) $(DESTDIR)$(pkgdatadir) $(DESTDIR)$(pkgdatadir) +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-dist_pkgdataDATA install-dist_pkgdataSCRIPTS \ + install-pkgdataSCRIPTS + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-dist_pkgdataDATA uninstall-dist_pkgdataSCRIPTS \ + uninstall-info-am uninstall-pkgdataSCRIPTS + +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am \ + install-dist_pkgdataDATA install-dist_pkgdataSCRIPTS \ + install-exec install-exec-am install-info install-info-am \ + install-man install-pkgdataSCRIPTS install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ + pdf-am ps ps-am uninstall uninstall-am \ + uninstall-dist_pkgdataDATA uninstall-dist_pkgdataSCRIPTS \ + uninstall-info-am uninstall-pkgdataSCRIPTS + + +all: + +downreport: Makefile $(srcdir)/downreport.in + rm -f downreport downreport.tmp; \ + $(auto_edit) $(srcdir)/downreport.in >downreport.tmp; \ + chmod +x downreport.tmp; \ + mv downreport.tmp downreport +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/share/README.misc b/share/README.misc new file mode 100644 index 0000000..4c6b2c6 --- /dev/null +++ b/share/README.misc @@ -0,0 +1,24 @@ +share/rancid includes some utilities that either don't seem to belong +in (i.e.: not part of the core pkg), contributed sources, or +sources included for convenience/example. + +README.misc This file. +downreport Daily report of routers not listed as up in router.db +getipacctg Get and sort show ip accounting output from cisco router +rtrfilter Procmail mail filter for diffs + +--------------- +rtrfilter can be used to filter rancid diffs to avoid sending unwanted +diffs to certain recipient(s) or diffs which those recipient(s) should +not see without the need to create separate or duplicate group(s). + +/etc/aliases e.g.: + +rancid-foo: engineering, + customer-ops-foo +# +# only send diffs for the SJC routers (aka. *.sjc.shrubbery.net) +customer-ops-foo: "| /usr/local/rancid/share/rancid/rtrfilter -i '\.sjc\.' -s 'sjc router diffs' customer-ops" +# +customer-ops: jimbob, + sally diff --git a/share/cisco-load.exp b/share/cisco-load.exp new file mode 100644 index 0000000..0c28549 --- /dev/null +++ b/share/cisco-load.exp @@ -0,0 +1,338 @@ +## +## $Id: cisco-load.exp,v 1.10 2004/01/11 03:43:50 heas Exp $ +## +## +## Copyright (C) 1997-2004 by Terrapin Communications, Inc. +## All rights reserved. +## +## This software may be freely copied, modified and redistributed +## without fee for non-commerical purposes provided that this license +## remains intact and unmodified with any RANCID distribution. +## +## There is no warranty or other guarantee of fitness of this software. +## It is provided solely "as is". The author(s) disclaim(s) all +## responsibility and liability with respect to this software's usage +## or its effect upon hardware, computer systems, other software, or +## anything else. +## +## Except where noted otherwise, rancid was written by and is maintained by +## Henry Kilmer, John Heasley, Andrew Partan, Pete Whiting, and Austin Schutz. +## +# +# this expect snipit is sourced by clogin (-s option) to load a configuration +# file (named -confg into nvram from an rcp/tftp host. this is an +# _example_ as it not guaranteed to work for all applications. PLEASE test +# for your environment. +# +# it expects the following variables via the -E option: +# rcphost ='host to rcp from' such as 'foo.org' or '192.168.0.1' +# confgpath ='path under /tftpboot where configs are held' +# +# the config file is expected to be routername-confg, where routername is the +# name as grok'd from the router's cmd-line prompt +# +# example usage: +# % clogin -s ./cisco-load.exp -Ercphost=foo.shrubbery.net router +# router +# loading router config from foo.shrubbery.net +# +# keep in mind that it is important to NOT polute the global variable space. +# particularly, do not use variables used within clogin. this may result in +# indeterministic results. an easy way to avoid this is to use a variable +# name prefix (like 'E' or '_'). +# +# useful variables from clogin global space: +# router router name as provided on the cmd-line +# prompt cmd-line prompt as determined by clogin +# +# note: the tcl/expect parser is extremely stoopid. comment lines are NOT +# completely ignored!! so, a '{' or '}' in a comment might produce +# unexpected results. +## +# log_user 1 +# exp_internal 1 + +# sometimes this is a bit slow. note: this overrides clogin -t +set timeout 90 + +# take rcp host from -Ercphost='foo' +if ([info exists Ercphost]) { + #puts "CONFGHOST == $Ercphost" + set confghost [string tolower $Ercphost] +} else { + send_error "ERROR: -Ercphost= was not set on the command-line.\n" + exit +} + +# +# logout of the router +# +proc logout { ecode } { + global prompt + + send "quit\r" + expect { + "$prompt" { logout $ecode } + timeout { send_error "Error: timeout waiting for EOF after quit\n"} + eof { + send_user "\n" + exit $ecode } + } +} + +# +# erase the nvram +# +proc erase { } { + global prompt + + send "\r" + expect $prompt {} + send "write erase\r" + expect { + -re " Continue\[^\n\]\*confirm\]" { + send "\r" + exp_continue } + "$prompt" { } + timeout { + send_error "Error: timeout waiting for write erase.\n" + logout 1 } + eof { logout 1 } + } +} + +# +# load a config via rcp into nvram +# +proc doload { confghost routername config retry } { + global prompt + + # send a return just to be sure we have a prompt. + send "\r" + expect "$prompt" + # start the copy and send the host to load from + # use tftp if retry == 1 + if { $retry == 0 } { + send "copy tftp startup-config\r" + } else { + send "copy rcp startup-config\r" + } + expect { + timeout { + send_error "\nError: timeout exceeded waiting for rcp/tftp host prompt\r" + logout 1 } + "mbiguous command" { + if { $retry == 0 } { + send "copy tftp: startup-config\r" + } else { + send "copy rcp: startup-config\r" + } + exp_continue } + -re "Host or network .*\]\?" { + send "host\r" + exp_continue } + "\]\?" { + send "$confghost\r" } + } + + # + # fill in the rest of the blanks. username (12.0), filename, dest, etc. + # + expect { + -re "Source username .\*\]\?" { + send "$routername\r"; + exp_continue } + -re "Source filename .\*\]\?" { + send "$config\r"; + exp_continue } + -re "Name of configur.\*\]\?" { + send "$config\r"; + exp_continue } + -re "Destination filename .\*\]\?" { + send "startup-config\r"; + exp_continue } + -re "Configure using .\*confirm\]" { send "\r" } + "proceed\? \\\[" { send "yes\r" } + -re "Do you want to over write.\*confirm\]" { send "\r" } + -re "Accessing (rcp|tftp):" { } + timeout { + send_error "\n\tError: timeout exceeded while matching load prompts\n"; + send "" } + } + + expect { + timeout { + send_error "Error: timeout exceeded while loading config\n" + logout 1 } + -re "\[^\n\]*Connection refused" { + send_error "Error: $expect_out(0,string)\n" + logout 1 } + -re "\[^\n\]*Destination unreachable" { + send_error "Error: $expect_out(0,string)\n" + logout 1 } + -re "\[^\n\]*Permission denied" { + send_error "Error: $expect_out(0,string)\n" + logout 1 } + -re "\[^\n]*No such file or directory" { + send_error "Error: $expect_out(0,string)\n" + logout 1 } + -re "\[^\n]*Error copying\[^\n]*Not enough space on device\[^\n]*\r" { + send_error "Error: $expect_out(0,string)\n" + if { $retry == 2 } { +# erase stomps ssh rsa key +# send_user "erasing nvram\n" +# erase + send_user "retrying load\n" + doload $confghost $routername $config 1 + } elseif { $retry == 1 } { +# erase stomps ssh rsa key +# send_user "erasing nvram\n" +# erase + send_user "retrying load with tftp.\n" + doload $confghost $routername $config 0 + } else { + send_error "Error: $expect_out(0,string)\n" + logout 1 + } } + -re "\[^\n]*.*configuration is too large.*\n" { + send_error "Error: $expect_out(0,string)\n" + expect { + -re "\[^\n]*Truncate config.*:" { send "no\r" } + } + logout 1 } + -re "\[^\n]*Error (opening|copying).*\r" { + send_error "Error: $expect_out(0,string)\n" + logout 1 } + -nocase -re "\[^\n]* error\[^a-z\n]+\[^\n]*" { + send_error "$expect_out(0,string)\n" + logout 1 } + "\n" { exp_continue } + -re "^\[^ ]*\#" { + send_user "load successful.\n" + } + } + + return 0; +} + +send_user "loading $router config from $confghost\n"; + +# look for router hostname in prompt (i.e.: deal with fqdn) +send "\r" +expect { + timeout { + send_error "Error: did not receive prompt\n" + exit } + "\n" { exp_continue } + -re "^(\[^ ]*)\#" { + set routername $expect_out(1,string) } +} + +# deal with config subdir? from Econfgpath +if ([info exists confgpath]) { + set config "$confgpath/$routername-confg" +} else { + set config "$routername-confg" +} + +# load the config +if { [doload $confghost $routername $config 1] != 0 } { + logout 1 +} + +logout 0 + +# these were my original transcripts of performing loads. it is a useful +# example of info you may collect to get an idea of what needs to be handled +# in the expect{}s +# +# pdx-oob# +# pdx-oob#copy rcp start +# Address of remote host [255.255.255.255]? 205.238.52.35 +# Name of configuration file [a]? pdx-oob-confg +# Configure using pdx-oob-confg from 205.238.52.35? [confirm] +# +# Connected to 205.238.52.35 +# Loading 8131 byte file pdx-oob-confg: !!!! [OK] +# Compressing configuration from 8131 bytes to 3886 bytes +# [OK] +# pdx-oob# +# + +# 12.0S-isms +# pao2#cop rcp sta +# Address or name of remote host []? eng0 +# Translating "eng0"...domain server (205.238.52.46) [OK] +# +# Source username [pao2]? +# Source filename []? pao2-confg +# Destination filename [startup-config]? +# Warning: Copying this config directly into the nvram from a network server may +# cause damage the the startup config. It is advisable to copy the file +# into the running config first, and then save it using copy run start. +# Do you wish to proceed? [no]: yes +# Accessing rcp://pao2@eng0/pao2-confg... +# Connected to 205.238.52.35 +# Loading 30138 byte file pao2-confg: !!!!!! [OK] +# +# 30138 bytes copied in 2.576 secs (15069 bytes/sec) +# pao2# +# OR IS IT +# sea0#cop rcp sta +# Address or name of remote host []? eng0 +# Source username [sea0]? +# Source filename []? sea0-confg +# Destination filename [startup-config]? +# Accessing rcp://sea0@eng0/sea0-confg...!!!!!!!!!!!!!!!!!! +# 89794 bytes copied in 0.704 secs +# sea0#q +# Connection closed by foreign host. + +# pdx-oob#copy rcp start +# Address of remote host [255.255.255.255]? 205.238.52.35 +# Name of configuration file [a]? pdx-oob-confg +# Configure using pdx-oob-confg from 205.238.52.35? [confirm] +# +# Connected to 205.238.52.35 +# Loading 8131 byte file pdx-oob-confg: !!!! [OK] +# Compressing configuration from 8131 bytes to 3886 bytes +# [OK] +# pdx-oob#copy rcp start +# Address of remote host [205.238.52.35]? 205.238.52.35 +# Name of configuration file [pdx-oob-confg]? pdx-oob-confg +# Configure using pdx-oob-confg from 205.238.52.35? [confirm] +# +# Connected to 205.238.52.35 +# %rcp: /tftpboot/pdx-oob-confg: No such file or directory +# pdx-oob# +# + +# pdx-oob#copy rcp start +# Address of remote host [205.238.52.35]? 205.238.52.35 +# Name of configuration file [pdx-oob-confg]? pdx-oob-confg +# Configure using pdx-oob-confg from 205.238.52.35? [confirm] +# +# Connected to 205.238.52.35 +# %rcp: /tftpboot/pdx-oob-confg: Permission denied +# pdx-oob# +# + +# *** response from filtered pkt +# pdx-oob#copy rcp sta +# Address of remote host [205.238.52.35]? 205.238.1.94 +# Name of configuration file [pdx-oob-confg]? +# Configure using pdx-oob-confg from 205.238.1.94? [confirm] +# % Destination unreachable; gateway or host down +# +# pdx-oob# +# + +# *** response from host w/o rcp daemon +# pdx-oob#cop rcp sta +# Address of remote host [205.238.52.35]? 205.238.1.66 +# Name of configuration file [pdx-oob-confg]? +# Configure using pdx-oob-confg from 205.238.1.66? [confirm] +# % Connection refused by remote host +# +# pdx-oob# +# diff --git a/share/cisco-reload.exp b/share/cisco-reload.exp new file mode 100644 index 0000000..25880c1 --- /dev/null +++ b/share/cisco-reload.exp @@ -0,0 +1,147 @@ +## +## $Id: cisco-reload.exp,v 1.9 2004/01/11 03:43:50 heas Exp $ +## +## Copyright (C) 1997-2004 by Terrapin Communications, Inc. +## All rights reserved. +## +## This software may be freely copied, modified and redistributed +## without fee for non-commerical purposes provided that this license +## remains intact and unmodified with any RANCID distribution. +## +## There is no warranty or other guarantee of fitness of this software. +## It is provided solely "as is". The author(s) disclaim(s) all +## responsibility and liability with respect to this software's usage +## or its effect upon hardware, computer systems, other software, or +## anything else. +## +## Except where noted otherwise, rancid was written by and is maintained by +## Henry Kilmer, John Heasley, Andrew Partan, Pete Whiting, and Austin Schutz. +## +# +# this expect snipit is sourced by clogin (-s option) to issue a reload +# command on a cisco router. it DOES NOT save the config if it has been +# modified. this is an _example_ as it not guaranteed to work for all +# applications. PLEASE test for your environment. +# +# it expects the following variables via the -E option: +# reload_arg ='command argument' such as 'at 05:00' or 'cancel +# +# e.g. usage: +# % clogin -s cisco-reload.exp -Ereload_arg='at 01:00' router +# router +# Reload scheduled for 01:00:00 UTC Sat Jun 23 2001 (in 7 hours and 16 minutes) +# % clogin -s cisco-reload.exp -Ereload_arg='at cancel' router +# router +# % Ambiguous command: "reload at cancel" +# +# % clogin -s cisco-reload.exp -Ereload_arg='cancel' router +# router +# SHUTDOWN ABORTED +# +# +# keep in mind that it is important to NOT polute the global variable space. +# particularly, do not use variables used within clogin. this may result in +# indeterministic results. an easy way to avoid this is to use a variable +# name prefix (like 'E' or '_'). +# +# useful variables from clogin global space: +# router router name as provided on the cmd-line +# prompt cmd-line prompt as determined by clogin +# +# note: the tcl/expect parser is extremely stoopid. comment lines are NOT +# completely ignored!! so, a '{' or '}' in a comment might produce +# unexpected results. +## +# exp_internal 1 +# log_user 1 + +# take reload command from -Ereload_arg='at 05:00' +if ([info exists Ereload_arg]) { + #puts "reload_arg == $Ereload_arg" + set reloadcmd "reload $Ereload_arg" +} else { + send_error "ERROR: -Ereload_arg= was not set on the command-line.\n" + exit +} + +#send_user "$router\n" + +send "\r" +expect { + timeout { send_error "Error: did not receive prompt\n" + exit } + -re "^.*$prompt" { send "$reloadcmd\r" + expect * {} } +} +# look for response +expect { + -re "configuration has been modified.*no.:" { send "no\r"; + exp_continue } + -re "Reload scheduled .*\r" { set sched $expect_out(0,string) + exp_continue } + -re "SHUTDOWN ABORTED" { set sched $expect_out(0,string) } + -re "Proceed with .*confirm\]" { send "\r" } + -re "\n.*No reload " { set sched "no reload scheduled" + send "\r" } + -re "% Ambig\[^\n\r]*" { set sched $expect_out(0,string) } +} +send "\r" +expect "$prompt" +if ([info exists sched]) { + send_user "\t$sched\n" +} +send "quit\r" +expect { + timeout { send_error "Error: timeout waiting for EOF after quit\n"} + eof { exit 0 } +} + +## dennis#reload in ? +## Delay before reload (mmm or hhh:mm) +## +## dennis#reload in 100:10 +## +## System configuration has been modified. Save? [yes/no]: no +## Reload scheduled in 100 hours and 9 minutes +## Proceed with reload? [confirm] +## dennis#reload ca +## dennis#reload cancel +## dennis# +## +## +## *** +## *** --- SHUTDOWN ABORTED --- +## *** +## +## dennis#wr +## Building configuration... +## [OK] +## dennis#reload in 100:10 +## Reload scheduled in 100 hours and 10 minutes +## Proceed with reload? [confirm] +## dennis#rel +## dennis#reload can +## dennis#reload cancel +## dennis# +## +## +## *** +## *** --- SHUTDOWN ABORTED --- +## *** +## System configuration has been modified. Save? [yes/no]: no +## Reload scheduled for 11:51:48 PST Thu Dec 10 1998 (in 299 hours and 59 minutes) +## Proceed with reload? [confirm] +## ultra#reload can +## ultra# +## +## +## *** +## *** --- SHUTDOWN ABORTED --- +## *** +## ultra# reload at 8:10 10 dec +## +## System configuration has been modified. Save? [yes/no]: no +## Reload scheduled for 08:10:00 PST Thu Dec 10 1998 (in 296 hours and 17 minutes) +## Proceed with reload? [confirm] +## ultra# +## diff --git a/share/downreport.in b/share/downreport.in new file mode 100644 index 0000000..a05a524 --- /dev/null +++ b/share/downreport.in @@ -0,0 +1,81 @@ +#! /bin/sh +## +## $Id: downreport.in,v 1.9 2004/01/11 03:43:50 heas Exp $ +## +## Copyright (C) 1997-2004 by Terrapin Communications, Inc. +## All rights reserved. +## +## This software may be freely copied, modified and redistributed +## without fee for non-commerical purposes provided that this license +## remains intact and unmodified with any RANCID distribution. +## +## There is no warranty or other guarantee of fitness of this software. +## It is provided solely "as is". The author(s) disclaim(s) all +## responsibility and liability with respect to this software's usage +## or its effect upon hardware, computer systems, other software, or +## anything else. +## +## Except where noted otherwise, rancid was written by and is maintained by +## Henry Kilmer, John Heasley, Andrew Partan, Pete Whiting, and Austin Schutz. +## +# +# Reports the list of routers not listed as 'up'. + +# Put this in your crontab to run once a day: +# 0 0 * * * @pkgdatadir@/downreport + +# It can optionally +# take a space list of groups on the command line +# It will use the list of groups defined in rancid.conf otherwise. + + +ENVFILE="@sysconfdir@/rancid.conf" + +. $ENVFILE + +if [ $# -ge 1 ] ; then + LIST_OF_GROUPS="$*" +elif [ "$LIST_OF_GROUPS" = "" ] ; then + echo "LIST_OF_GROUPS is empty in $ENVFILE" + exit 1 +fi + + +for GROUP in $LIST_OF_GROUPS; do + ( + echo "To: @MAILPLUS@admin-$GROUP" + echo "Subject: Down router report - $GROUP" + echo "Precedence: bulk" + echo "" + DIR=$BASEDIR/$GROUP + if [ -s $DIR/routers.down ]; then + ( + + cat << EOM + + The following $GROUP routers are listed as other than up. + + Routers listed as "up" in rancid's router.db are polled several +times daily. This is a list of routers that are not "up" and therefore +not polled. + +EOM + + cat $DIR/routers.down; + + ) + + else + ( + + cat << EOM + + No routers are down/ticketed for router group $GROUP (yay). + +EOM + + ) + fi + ) | sendmail -t + +done diff --git a/share/getipacctg b/share/getipacctg new file mode 100644 index 0000000..9a5eb20 --- /dev/null +++ b/share/getipacctg @@ -0,0 +1,121 @@ +#! /bin/sh +## +## $Id: getipacctg,v 1.7 2004/01/11 03:43:50 heas Exp $ +## +## Copyright (C) 1997-2004 by Terrapin Communications, Inc. +## All rights reserved. +## +## This software may be freely copied, modified and redistributed +## without fee for non-commerical purposes provided that this license +## remains intact and unmodified with any RANCID distribution. +## +## There is no warranty or other guarantee of fitness of this software. +## It is provided solely "as is". The author(s) disclaim(s) all +## responsibility and liability with respect to this software's usage +## or its effect upon hardware, computer systems, other software, or +## anything else. +## +## Except where noted otherwise, rancid was written by and is maintained by +## Henry Kilmer, John Heasley, Andrew Partan, Pete Whiting, and Austin Schutz. +## +# +# getipacctg uses clogin to login to a cisco router, collect the o/p of +# show ip accounting, and sort by the greatest number of bytes. If a +# second argument is supplied, it is a number indicating the top N producers. +# a third (3 to N) argument(s) specify a prefix(es) to match/select src/dst +# IPs, while others will be filtered. +# +# usage: getipacctg [] \ +# [ [...]] +# example: +# getipacctg router 25 192.168.0.0/24 +# will display the top 25 for src or dst ip's within prefix +# 192.168.0.0/24 +# +# Contributed to rancid by Steve Neighorn of SCN Reasearch. + +TMP="/tmp/ipacct.$$.prefixes" +TMP2="/tmp/ipacct.$$.sorted" +TMP3="/tmp/ipacct.$$.pl" + +if [ $# -eq 0 ] ; then + echo "usage: getipacctg router_name [] [ [...]]" >&2 + exit 1; +fi + +trap 'rm -fr /tmp/ipacct.$$ $TMP $TMP2 $TMP3;' 1 2 15 +clogin -c 'show ip accounting' $1 > /tmp/ipacct.$$ + +if [ $? -ne 0 ] ; then + echo "clogin failed." >&2 + exit 1 +fi +# rest of the command-line options +exec 6>$TMP +HEAD="cat" +shift +while [ $# -ne 0 ] ; do + echo $1 | grep '/' > /dev/null + if [ $? -eq 1 ] ; then + HEAD="head -$1" + else + echo $1 1>&6 + fi + shift +done +6>&- + +egrep '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ +[0-9]+\.[0-9]+\.' /tmp/ipacct.$$ | \ + sed -e 's/^ *//' -e 's/ */ /g' -e 's/.$//' | \ + awk '{print $4":"$0;}' | sort -nr | \ + sed -e 's/^[^:]*://' > $TMP2 + +if [ -s $TMP ] ; then +cat > $TMP3 <) { + chomp; + s/\s*//g; + /(.*)\/(.*)\$/; + my(\$ip) = \$1; my(\$mask) = \$2; + \$ip = ip_to_int(\$ip); + \$mask = (~0) << (32 - \$mask); + \$ip = \$ip & (\$mask); + \$prefs[\$nprefs++] = \$ip; + \$prefs[\$nprefs++] = \$mask; + } + close(PREFS); + open(DATA, "< \$ARGV[1]") || die "could not open \$ARGV[1]\n"; + while () { + chomp; + @A = split(/ /); + \$A[0] = ip_to_int(\$A[0]); + \$A[1] = ip_to_int(\$A[1]); + for (\$f = 0; \$f < \$nprefs; \$f += 2) { + if ((\$A[0] & \$prefs[\$f + 1]) == \$prefs[\$f] || + (\$A[1] & \$prefs[\$f + 1]) == \$prefs[\$f]) { + print "\$_\n"; + break; + } + } + } +PERL + perl $TMP3 $TMP $TMP2 | $HEAD +else + $HEAD $TMP2 +fi + +rm -fr /tmp/ipacct.$$ $TMP $TMP2 $TMP3 +trap ';' 1 2 15 +exit 0 diff --git a/share/index.html b/share/index.html new file mode 100644 index 0000000..0b7ef06 --- /dev/null +++ b/share/index.html @@ -0,0 +1,12 @@ + + + diff --git a/share/lgnotes.html b/share/lgnotes.html new file mode 100644 index 0000000..9f28ec3 --- /dev/null +++ b/share/lgnotes.html @@ -0,0 +1,61 @@ + + + + + +Looking Glass Notes + + +    Looking Glass Notes +

+
+

+

    +Just a few straight forward notes on our implementation of +Ed Kern's looking glass. See the original at +http://nitrous.digex.net. +
+

+

+

    +
  • Some items are not implemented for the junipers/foundrys yet (so, as i get + to it) or no equivalent command exists. +
  • If there is something which you feel is missing, feel free to ask + and/or send comments to + rancid@shrubbery.net. No guarantees.
  • +
  • Only one query per router allowed at any given time. This is to avoid + resource deprivation on the looking glass host or the router. The + looking glass will attempt to serialize queries.
  • +
  • The looking glass will ping a router prior to querying it to avoid + trying to query routers which are down or otherwise inaccessible.
  • +
  • Login failures can be intermittent or permanent, either due to the + router being inaccessible from the looking glass machine, + or authorization failure(s). Contact your local network engineering + folks to resolve login failures.
  • +
  • Queries followed by <something> require an argument(s) in the text + window below the query list. Some queries take optional arguments + denoted by [something]. Multiple arguments should be separated by a + space.
  • +
  • Note that output from certain queries is cached by the server and may + be slightly out of date. These queries will be noted as such in the + output. This is limited to queries which could produce lots of output, + such as 'sh ip bgp dampened-paths'.
  • +
  • Note that some queries have potential to produce great load on the router + and produce lots of output, such as 'sh ip bgp' or 'sh ip bgp reg '^3561'. + The looking glass attempts to deny such commands.
  • +
+

+Some useful hints: +

    +
  • Show interfaces can take arguments other than an interface name, assuming + the router is running an O/S version with the capability. For example; a + cisco can take 'descriptions' or 'brief' and 'terse' for the juniper.
  • +
  • Show ip bgp neighbor can take additional arguments (if configured to allow + it), such as 'advertised routes', 'flap-statistics', 'received-routes', + and 'routes'. The argument will be converted for the platform.
  • +
+ + + diff --git a/share/rtrfilter.in b/share/rtrfilter.in new file mode 100644 index 0000000..9807e1f --- /dev/null +++ b/share/rtrfilter.in @@ -0,0 +1,164 @@ +#! @PERLV_PATH@ +## +## $Id: rtrfilter.in,v 1.13 2004/01/11 03:43:50 heas Exp $ +## +## Copyright (C) 1997-2004 by Terrapin Communications, Inc. +## All rights reserved. +## +## This software may be freely copied, modified and redistributed +## without fee for non-commerical purposes provided that this license +## remains intact and unmodified with any RANCID distribution. +## +## There is no warranty or other guarantee of fitness of this software. +## It is provided solely "as is". The author(s) disclaim(s) all +## responsibility and liability with respect to this software's usage +## or its effect upon hardware, computer systems, other software, or +## anything else. +## +## Except where noted otherwise, rancid was written by and is maintained by +## Henry Kilmer, John Heasley, Andrew Partan, Pete Whiting, and Austin Schutz. +## +# +# rtrtfilter - "| rtrfilter -x -i -f \ +# -u -s " +# expects to read an email message on stdin containing a diff from +# rancid and emails a filtered copy to with the subject of the +# original msg or the contents of -s . the perl regex(es) specified +# via -x or -i (exclusive and inclusive, respectively) are applied to the +# router names (i.e.: files) from the "Index:" of the diff o/p. alternatively, +# the regex's may be specified in -f in the form: +# # comment +# x +# # comment +# i +# do not include /'s in the regex's. +# e.g.: +# #i inc1 +# i a0[12]\. +# i a0[34]\. +# # comment +# x router\.db +# x ^r0[0-9] +# #i foo +# +# exclusion takes precedence and defaults to nothing. inclusion defaults to +# everything. +# +# this program requires the Mail::Mailer module which can be found on CPAN. +## +BEGIN { +$me = $0; +$me =~ s/.*\/(\S+)$/$1/; +} + +require 'newgetopt.pl'; +use Mail::Mailer; + +# process command line options +$newgetopt'ignorecase=0; +$newgetopt'autoabbrev=1; +$result = &NGetOpt('h','x=s@','i=s@','f=s','s=s'); +&usage($result) if (defined($opt_h) || $result == 0); + +if ($#ARGV < 0) { + usage; +} +my($rcpts) = join(',', @ARGV); + +# if specified, read the regex file and append to @opt_i / @opt_x +if (defined($opt_f)) { + open(FILE, "< $opt_f") || die "Cant open the regex file $opt_f: $!"; + + while () { + next if (! /^(i|x)\s+(.*$)/); + #/(i|x)\s+(.*)$/; + if ($1 eq "i" ) { + push(@opt_i, $2); + } else { + push(@opt_x, $2); + } + } + close(FILE); +} + +# read the header, grok the subject line +my($subject, $from); +while () { + last if (/^$/); + if (s/^from: //i) { + chomp; + $from = $_; + } + if (s/^subject: //i) { + chomp; + $subject = $_; + } +} +if (defined($opt_s)) { $subject = $opt_s;} +if (defined($opt_u)) { $from = $opt_u;} + +# filter the remainder of the mail. save mail in memory to avoid empty msgs +my(@mail); +my($skip) = 1; +while () { + # look for /^Index: ", the filtering key + if (/^Index: (.*)$/) { + # strip the directory before passing to filter() + my($line) = ($1 =~ /.*\/([^\/\s]*)$/); + $skip = filter($line); + } + + next if ($skip); + + push(@mail, $_); +} + +# send mail, if any +if ($#mail < 0) { exit; } +$mailer = new Mail::Mailer 'sendmail', ('-t'); +$headers{From} = $from; +$headers{"Reply-To"} = $from; +$headers{"Errors-To"} = $from; +$headers{Subject} = $subject; +$headers{To} = $rcpts; +$headers{Precedence} = "bulk"; + +$mailer->open(\%headers); +print $mailer @mail; +$mailer->close; + +exit; + +# filter $line inclusive/exclusive (0 / 1) +sub filter { + my($line) = shift; + + # exclusion + if (defined(@opt_x)) { + foreach $regex (@opt_x) { + if ($line =~ /$regex/) { return(1); } + } + } + + # inclusion / default inclusion + if (! @opt_i) { return(0); } + foreach $regex (@opt_i) { + if ($line =~ /$regex/) { return(0); } + } + + # inclusion regex specified, but fall through + return(1); +} + +sub usage { + print STDERR <] [-x ] [-f ] [-u ] [-s ] [ ...] + -h prints this message + -f file containing perl regex matching router names (mind the cwd()) + -i perl regex matching router names (inclusive) + -u From: address + -s mail subject + -x perl regex matching router names (exclusive) +USAGE + exit $_; +} -- cgit