summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTar Committer <tar@ocjtech.us>1999-06-20 23:17:14 +0000
committerTar Committer <tar@ocjtech.us>1999-06-20 23:17:14 +0000
commit8c5c1d20fc744c7e60a6197fc397b44d424c65b8 (patch)
tree4b32e7ecf45efe9619d3909df3a943edb86f7027
downloadrancid-8c5c1d20fc744c7e60a6197fc397b44d424c65b8.tar.gz
rancid-8c5c1d20fc744c7e60a6197fc397b44d424c65b8.tar.xz
rancid-8c5c1d20fc744c7e60a6197fc397b44d424c65b8.zip
Imported from rancid-1.0.tar.gz.rancid-1.0
-rw-r--r--.cloginrc.sample35
-rw-r--r--README93
-rw-r--r--Todo3
-rwxr-xr-xbin/clogin472
-rwxr-xr-xbin/control_rancid197
-rwxr-xr-xbin/create_cvs81
-rw-r--r--bin/cvs_helper28
-rwxr-xr-xbin/do-diffs43
-rw-r--r--bin/env21
-rwxr-xr-xbin/jlogin402
-rwxr-xr-xbin/jrancid327
-rwxr-xr-xbin/par128
-rwxr-xr-xbin/rancid800
-rwxr-xr-xbin/rancid-fe33
-rwxr-xr-xbin/rename113
-rwxr-xr-xbin/run-me35
16 files changed, 2811 insertions, 0 deletions
diff --git a/.cloginrc.sample b/.cloginrc.sample
new file mode 100644
index 0000000..71cd704
--- /dev/null
+++ b/.cloginrc.sample
@@ -0,0 +1,35 @@
+# comments are cool, as is whitespace
+# currently clogin supports three add directives; password, user, and
+# autoenable.
+# eventually, others may be added to allow other features.
+##
+#add password sl-bb*-dc cow24
+#add password sl-gw*-dc geeks
+#add password sl* hank dog
+#add password at* pete cow
+#add password sdn* mujahid horse
+#add password icm* peter
+#add password * anything
+#
+#add user sl-gw*-dc twit
+#add user sdn* sdn_auto
+#add user sdn-bb* ops_eng
+#add user * $env(USER)
+
+# customer x
+# these routers ask for a username and password. we automatically get
+# enable access after successful authentication.
+add user *.custx.net roger
+add password *.custx.net {doger}
+add autoenable *.custx.net 1
+
+# customer y
+# this is the normal cisco login. a password followed by and enable password.
+add password *.custy.net {vector} {victor}
+
+# customer z
+add user *.custz.net shirley
+add password *.custz.net {jive} {surely}
+
+# all our routers, ie: everything else
+add password * {clearance} {clarence}
diff --git a/README b/README
new file mode 100644
index 0000000..6cf53a0
--- /dev/null
+++ b/README
@@ -0,0 +1,93 @@
+Rancid is a "Really Awesome New Cisco confIg Differ" developed to
+maintain CVS controlled copies of router configs.
+
+The following is the packing list for Rancid:
+
+README - This file.
+env - Enviromental settings needed.
+run-me - Script designed to be run from cron calling control_rancid.
+control_rancid - Builds router list, calls rancid on each router and
+ handles cvs routines.
+rancid-fe - chooses between rancid an jrancid
+rancid - Runs commands on router and processes the output - the meat.
+jrancid - Runs commands on juniper routers and processes the output
+clogin - Expect script that logs into routers either interactively,
+ runs a set of commands or runs another expect script.
+jlogin - Expect script that logs into juniper routers similarly to
+ clogin. it is not terribly robust, but mainly used for it's
+ -c and -s options.
+.cloginrc - TCL commands to set passwords, usernames etc. used by clogin and
+ jlogin.
+par - Parallel processing of commands - any commands.
+
+rancid will also need to have the following packages:
+cvs - code revision system available from prep.ai.mit.edu:/pub/gnu
+rcs - code revision system which cvs built on top of. available from
+ prep.ai.mit.edu:/pub/gnu
+gnudiff - gnudiff provides the -u option. if you do not have gnu's diff,
+ you will have to modify control_rancid to use 'diff -c' or some
+ such. see examples.
+perl5 - perl version 5 or greater available from www.cpan.org
+expect -
+tcl - required by expect
+
+Quick Installation Guide (an example):
+
+1) mkdir <basedir>
+ All rancid crud will be under this directory.
+
+2) mkdir <basedir>/bin
+
+3) Put the contents of rancid in <basedir>/bin. modify the location of
+ perl and expect in each of clogin, par, rancid, and rename if necessary.
+
+4) Modify env.
+
+5) Put .cloginrc in your home directory.
+
+6) Modify .cloginrc.
+
+7) Modify /etc/aliases
+ Rancid sends the diffs and other controlling emails to rancid-<GROUP>
+ and problems to rancid-admin-<GROUP>, where <GROUP> is the "GROUP" of
+ routers. This way you can seperate your backbone routers from your
+ access routers or seperate based upon network etc... Different router
+ uses forced different people being interested in router "groups" -
+ thus is setup. Make sure email to rancid-<GROUP> works. /etc/aliases
+ can be maintainable by Majordomo stuff.
+ - OR -
+ Modify your home directory's .mailrc. Control_rancid uses sendmail
+ to send diffs. To use a private .mailrc, control_rancid will have to
+ be modified to use ucbmail or, better yet, something else which allow
+ the Precedence header to be set. Pick your poison.
+
+ The Precedence header set to bulk or junk *hopefully* avoids
+ auto-responders and vacation type mail filters.
+
+8) Modify run-me &/ do-diffs.
+ Set path to env.
+
+9) Modify create_cvs.
+ Set path to env.
+
+10) Run create_cvs.
+ This creates all of the CVS necessary directories and all of the
+ config directories.
+
+11) For each "group", create the router.db file in the group directory.
+ The file is of the form "router:mfg:state" where "router" is the name
+ of the router, mfg is the manufacturer (cisco|juniper), and "state"
+ is either up or down. Each router listed as "up" will have the
+ configuration grabbed.
+
+12) Put run-me/do-diffs in cron to be called however ofter you want it to run
+ for each group (run-me <GROUP>). eg:
+
+ # run config differ hourly
+ 1 * * * * $HOME/bin/do-diffs
+ # clean out hourly differ logs
+ 50 23 * * * /usr/bin/find $BASEDIR/logs -mtime +2 -exec rm {} \;
+
+13) Send me any bugs, suggestions or updates (rancid@shrubbery.net).
+
+-Hank
diff --git a/Todo b/Todo
new file mode 100644
index 0000000..b13b717
--- /dev/null
+++ b/Todo
@@ -0,0 +1,3 @@
+- detect 'same' vty configs
+ - ignoring length/width/passwd is a start, but need more
+- sort route-maps into alpha order
diff --git a/bin/clogin b/bin/clogin
new file mode 100755
index 0000000..ddd06af
--- /dev/null
+++ b/bin/clogin
@@ -0,0 +1,472 @@
+#!/usr/local/bin/expect --
+##
+##
+## Copyright (C) 1997 by Henry Kilmer, Erik Sherk and Pete Whiting.
+## All rights reserved.
+##
+## This software may be freely copied, modified and redistributed without
+## fee for non-commerical purposes provided that this copyright notice is
+## preserved intact on all copies and modified copies.
+##
+## 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.
+##
+##
+#
+# clogin - Cisco login
+#
+# Most options are intuitive for logging into a Cisco router.
+# The default is to enable (thus -noenable). Some folks have
+# setup tacacs to have a user login at priv-lvl = 15 (enabled)
+# so the -autoenable flag was added for this case (don't go through
+# the process of enabling and the prompt will be the "#" prompt.
+# The default username password is the same as the vty password.
+#
+
+# Usage line
+set usage "Usage: $argv0 \[-u user\] \[-p user-password\] \[-v vty-password\] \
+\[-w enable-username\] \[-e enable-password\] \[-noenable\] \
+\[-f cloginrc-file\] \[-c command\] \[-s script-file\] \[-autoenable\] \
+\[-t timeout\] router \[router...\]\n"
+
+# env(CLOGIN) may contain:
+# x == do not set xterm banner or name
+
+# Password file
+set password_file $env(HOME)/.cloginrc
+# Default is to login to the router
+set do_command 0
+set do_script 0
+# The default is to automatically enable
+set enable 1
+# The default is that you login non-enabled (tacacs can have you login already enabled)
+set autoenable 0
+# The default is to look in the password file to find the passwords. This
+# tracks if we receive them on the command line.
+set do_passwd 1
+set do_enapasswd 1
+
+# Find the user in the ENV, or use the unix userid.
+if {[ info exists env(CISCO_USER) ] } {
+ set default_user $env(CISCO_USER)
+} else {
+ # This uses "id" which I think is portable. At least it has existed
+ # (without options) on all machines/OSes I've been on recently -
+ # unlike whoami or id -nu.
+ regexp {\(([^)]*)} [exec id] junk default_user
+}
+
+# Sometimes routers take awhile to answer (the default is 10 sec)
+set timeout 45
+
+# Process the command line
+for {set i 0} {$i < $argc} {incr i} {
+ set arg [lindex $argv $i]
+
+ switch -glob -- $arg {
+ # Username
+ -u* -
+ -U* {
+ if {! [ regexp .\[uU\](.+) $arg ignore user]} {
+ incr i
+ set username [ lindex $argv $i ]
+ }
+ # VTY Password
+ } -p* -
+ -P* {
+ if {! [ regexp .\[pP\](.+) $arg ignore userpasswd]} {
+ incr i
+ set userpasswd [ lindex $argv $i ]
+ }
+ set do_passwd 0
+ # VTY Password
+ } -v* -
+ -v* {
+ if {! [ regexp .\[vV\](.+) $arg ignore passwd]} {
+ incr i
+ set passwd [ lindex $argv $i ]
+ }
+ set do_passwd 0
+ # Enable Username
+ } -w* -
+ -W* {
+ if {! [ regexp .\[wW\](.+) $arg ignore enauser]} {
+ incr i
+ set enausername [ lindex $argv $i ]
+ }
+ # Enable Password
+ } -e* -
+ -E* {
+ if {! [ regexp .\[eE\](.+) $arg ignore enapasswd]} {
+ incr i
+ set enapasswd [ lindex $argv $i ]
+ }
+ set do_enapasswd 0
+ # Command to run.
+ } -c* -
+ -C* {
+ if {! [ regexp .\[cC\](.+) $arg ignore command]} {
+ incr i
+ set command [ lindex $argv $i ]
+ }
+ set do_command 1
+ # Expect script to run.
+ } -s* -
+ -S* {
+ if {! [ regexp .\[sS\](.+) $arg ignore sfile]} {
+ incr i
+ set sfile [ lindex $argv $i ]
+ }
+ if { ! [ file readable $sfile ] } {
+ send_user "Error: Can't read $sfile\n"
+ exit 1
+ }
+ set do_script 1
+ # alternate cloginrc file
+ } -f* -
+ -F* {
+ if {! [ regexp .\[fF\](.+) $arg ignore password_file]} {
+ incr i
+ set password_file [ lindex $argv $i ]
+ }
+ } -t* -
+ -T* {
+ incr i
+ set timeout [ lindex $argv $i ]
+ # Do we enable?
+ } -noenable {
+ set enable 0
+ # Does tacacs automatically enable us?
+ } -autoenable {
+ set autoenable 1
+ set enable 0
+ } -* {
+ send_user "Error: Unknown argument! $arg\n"
+ send_user $usage
+ exit 1
+ } default {
+ break
+ }
+ }
+}
+# Process routers...no routers listed is an error.
+if { $i == $argc } {
+ send_user "Error: $usage"
+}
+
+# Only be quiet if we are running a script (it can log its output
+# on its own)
+if { $do_script } {
+ log_user 0
+} else {
+ log_user 1
+}
+
+#
+# Done configuration/variable setting. Now run with it...
+#
+
+# Sets Xterm title if interactive...if its an xterm and the user cares
+proc label { host } {
+ global env
+ # if CLOGIN has an 'x' in it, don't set the xterm name/banner
+ if [info exists env(CLOGIN)] {
+ if {[string first "x" $env(CLOGIN)] != -1} { return }
+ }
+ # take host from ENV(TERM)
+ if [info exists env(TERM)] {
+ if [regexp \^(xterm|vs) $env(TERM) ignore ] {
+ send_user "\033]1;[lindex [split $host "."] 0]\a"
+ send_user "\033]2;$host\a"
+ }
+ }
+}
+
+# This is a helper function to make the password file easier to
+# maintain. Using this the password file has the form:
+# add password sl* pete cow
+# add password at* steve
+# add password * hanky-pie
+proc add {var args} { global $var ;lappend $var $args}
+proc find {var router} {
+ source_password_file
+ upvar $var list
+ if { [info exists list] } {
+ foreach line $list {
+ if { [string match [lindex $line 0] $router ] } {
+ return [lrange $line 1 end]
+ }
+ }
+ }
+ return {}
+}
+
+# Loads the password file. Note that as this file is tcl, and that
+# it is sourced, the user better know what to put in there, as it
+# could install more than just password info... I will assume however,
+# that a "bad guy" could just as easy put such code in the clogin
+# script, so I will leave .cloginrc as just an extention of that script
+proc source_password_file { } {
+ global env password_file read_password_file
+ if { [info exists read_password_file] } { return }
+ if { [info exists password_file] == 0 } {
+ set password_file $env(HOME)/.cloginrc
+ }
+ set read_password_file 1
+ file stat $password_file fileinfo
+ if { [expr ($fileinfo(mode) & 007)] != 0000 } {
+ send_user "Error: $password_file must not be world readable/writable\n"
+ exit 1
+ }
+ source $password_file
+}
+
+# Log into the router.
+proc login { router user userpswd passwd enapasswd prompt } {
+ global spawn_id in_proc do_command do_script
+ set in_proc 1
+
+ # Telnet to the router & try to login.
+ if [ catch {spawn telnet $router} reason ] {
+ send_user "Error: failed to telnet: $reason\n"
+ exit 1
+ }
+ sleep 0.3
+
+ # This helps cleanup each expect clause.
+ expect_after {
+ timeout {
+ send_user "\nError: TIMEOUT reached\n"
+ close; wait
+ if { $in_proc} {
+ return 1
+ } else {
+ continue
+ }
+ } eof {
+ send_user "\nError: EOF received\n"
+ close; wait
+ if { $in_proc} {
+ return 1
+ } else {
+ continue
+ }
+ }
+ }
+
+ # Here we get a little tricky. There are several possibilities:
+ # the router can ask for a username and passwd and then
+ # talk to the TACACS server to authenticate you, or if the
+ # TACACS server is not working, then it will use the enable
+ # passwd. Or, the router might not have TACACS turned on,
+ # then it will just send the passwd.
+ expect {
+ eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ "Connection refused" {
+ expect eof
+ send_user "Error: Connection Refused\n"; wait; return 1
+ } "Unknown host\r\n" {
+ expect eof
+ send_user "Error: Unknown host\n"; wait; return 1
+ } "Host is unreachable" {
+ expect eof
+ send_user "Error: Host Unreachable!\n"; wait; return 1
+ } "No address associated with name" {
+ expect eof
+ send_user "Error: Unknown host\n"; wait; return 1
+ }
+ -re "(Username|login):" { send "$user\r"
+ expect {
+ eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ -re "\[Pp]assword:" { send "$userpswd\r" }
+ "$prompt" { set in_proc 0; return 0 }
+ }
+ exp_continue
+ }
+ "Password:" { send "$passwd\r"
+ expect {
+ eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ "Password:" { send "$enapasswd\r" }
+ "$prompt" { set in_proc 0; return 0 }
+ }
+ exp_continue
+ }
+ "$prompt" { }
+ denied { send_user "Error: Check your passwd for $router\n"
+ if { $do_command || $do_script } {
+ send "quit"
+ wait
+ return 1
+ } else {
+ return 1
+ }
+ }
+ "% Bad passwords" {send_user "Error: Check your passwd for $router\n"; return 1 }
+ }
+ set in_proc 0
+ return 0
+}
+
+# Enable
+proc do_enable { enauser enapasswd } {
+ global prompt in_proc
+ set in_proc 1
+
+ send "enable\r"
+ expect {
+ "Username:" { send "$enauser\r"; exp_continue}
+ "Password:" { send "$enapasswd\r"; exp_continue}
+ "#" { }
+ denied { send_user "Error: Check your Enable passwd\n"; return 1}
+ "% Bad passwords" { send_user "Error: Check your Enable passwd\n"
+ return 1
+ }
+ }
+ # Set the prompt variable so script files don't need to know what it is.
+ set prompt "#"
+ set in_proc 0
+ return 0
+}
+
+# Run commands given on the command line.
+proc run_commands { prompt command } {
+ global in_proc
+ set in_proc 1
+
+ send "term length 0\r"
+ expect $prompt {}
+
+ # Is this a multi-command?
+ if [ string match "*\;*" "$command" ] {
+ set commands [split $command \;]
+ set num_commands [llength $commands]
+
+ for {set i 0} {$i < $num_commands} { incr i} {
+ send "[lindex $commands $i]\r"
+ expect {
+ -re "^\[^\n\r]*$prompt." { exp_continue }
+ -re "^\[^\n\r *]*$prompt" {}
+ "\n" { exp_continue }
+ }
+ }
+ } else {
+ send "$command\r"
+ expect {
+ -re "^\[^\n\r]*$prompt." { exp_continue }
+ -re "^\[^\n\r *]*$prompt" {}
+ "\n" { exp_continue }
+ }
+ }
+ send "exit\r"
+ expect {
+ "\n" { exp_continue }
+ timeout { return 0 }
+ eof { return 0 }
+ }
+ set in_proc 0
+}
+
+#
+# For each router... (this is main loop)
+#
+set in_proc 0
+foreach router [lrange $argv $i end] {
+ set router [string tolower $router]
+ send_user "$router\n"
+
+ # Figure out prompt.
+ # Since autoenable is off by default, if we have it defined, it
+ # was done on the command line. If it is not specifically set on the
+ # command line, check the password file.
+ if $autoenable {
+ set prompt "#"
+ } else {
+ set ae [find autoenable $router]
+ if { "$ae" == "1" } {
+ set autoenable 1
+ set enable 0
+ set prompt "#"
+ } else {
+ set autoenable 0
+ set prompt ">"
+ }
+ }
+
+ # Figure out passwords
+ if { $do_passwd || $do_enapasswd } {
+ set pswd [find password $router]
+ if { [llength $pswd] == 0 } {
+ send_user "Error - no password for $router in $password_file.\n"
+ continue
+ }
+ if { $do_enapasswd && !$autoenable && [llength $pswd] < 2 } {
+ send_user "Error - no enable password for $router in $password_file."
+ continue
+ }
+ set passwd [lindex $pswd 0]
+ set enapasswd [lindex $pswd 1]
+ }
+
+ # Figure out username
+ if {[info exists username]} {
+ # command line username
+ set user $username
+ } else {
+ set user [find user $router]
+ if { "$user" == "" } { set user $default_user }
+ }
+
+ # Figure out username's password (if different from the vty password)
+ if {[info exists userpasswd]} {
+ # command line username
+ set userpswd $userpasswd
+ } else {
+ set userpswd [find userpassword $router]
+ if { "$userpswd" == "" } { set userpswd $passwd }
+ }
+
+ # Figure out enable username
+ if {[info exists enausername]} {
+ # command line enausername
+ set enauser $enausername
+ } else {
+ set enauser [find enauser $router]
+ if { "$enauser" == "" } { set enauser $user }
+ }
+
+ # Login to the router
+ if {[login $router $user $userpswd $passwd $enapasswd $prompt]} {
+ continue
+ }
+ if { $enable } {
+ if {[do_enable $enauser $enapasswd]} {
+ if { $do_command || $do_script } {
+ close; wait
+ continue
+ }
+ }
+ }
+
+ if { $do_command } {
+ if {[run_commands $prompt $command]} {
+ continue
+ }
+ } elseif { $do_script } {
+ send "term length 0\r"
+ expect $prompt {}
+ source $sfile
+ close
+ } else {
+ label $router
+ log_user 1
+ interact
+ }
+
+ # End of for each router
+ wait
+ sleep 0.3
+}
+exit 0
diff --git a/bin/control_rancid b/bin/control_rancid
new file mode 100755
index 0000000..89ec0df
--- /dev/null
+++ b/bin/control_rancid
@@ -0,0 +1,197 @@
+#!/bin/sh
+##
+##
+## Copyright (C) 1996 by Henry Kilmer.
+## All rights reserved.
+##
+## This software may be freely copied, modified and redistributed without
+## fee for non-commerical purposes provided that this copyright notice is
+## preserved intact on all copies and modified copies.
+##
+## 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.
+##
+##
+#
+# control_rancid $GROUP
+#
+
+# Number of things par should run in parallel.
+PAR_COUNT=5
+
+# Must specify a group to run rancid
+if [ $# -lt 1 ]; then
+ echo 'must specify group'; exit 1
+else
+ GROUP=$1
+fi
+TMP=/var/tmp/rancid.$GROUP.$$
+DIR=$BASEDIR/$GROUP
+
+# Bail if we do not have the necessary info to run
+if [ ! -d $DIR ]
+then
+ (
+ echo "$DIR does not exist."
+ ) | Mail -s "no $GROUP directory" rancid-admin-$GROUP
+ exit 1
+fi
+if [ ! -f $DIR/router.db ]
+then
+ (
+ echo "$DIR/router.db does not exist."
+ ) | Mail -s "no $GROUP/router.db file" rancid-admin-$GROUP
+ exit 1;
+elif [ ! -s $DIR/router.db ]
+then
+ exit
+fi
+
+# generate the list of routers we should try to fetch
+cd $DIR
+rm -f $DIR/allrouters.new
+perl -F: -ane '{($F[0] =~ tr@A-Z@a-z@,print "$F[0]:$F[1]\n")
+ if ($F[2] =~ /^up$/i);}' $DIR/router.db | sort -u > $DIR/allrouters.new
+
+if diff $DIR/allrouters $DIR/allrouters.new > $DIR/allrouters.diffs
+then
+ rm -f $DIR/allrouters.new
+else
+ (
+ echo New routers:
+ comm -13 $DIR/allrouters $DIR/allrouters.new | sed -e 's/^/ /' -e 's/:.*$//'
+ echo
+ echo Deleted routers:
+ comm -23 $DIR/allrouters $DIR/allrouters.new | sed -e 's/^/ /' -e 's/:.*$//'
+ ) | Mail -s "changes in $GROUP routers" rancid-admin-$GROUP
+
+ cd $DIR/configs
+
+ # Add new routers to the CVS structure.
+ for router in `comm -13 $DIR/allrouters $DIR/allrouters.new`
+ do
+ OFS=$IFS
+ IFS=:
+ set $router
+ IFS=$OFS
+ router=$1
+
+ touch $router
+ cvs add $router
+ cvs commit -m 'new router' $router
+ echo "Added $router"
+ done
+ echo
+ cd $DIR
+
+ mv $DIR/allrouters.new $DIR/allrouters
+fi
+rm -f $DIR/allrouters.diffs $DIR/allrouters.new
+
+# no routers, empty list or all 'down'
+if [ ! -s $DIR/allrouters ]
+then
+ exit;
+fi
+
+# Now we can actually try to get the configs
+cd $DIR/configs
+
+# The number of processes running at any given time can be
+# tailored to the specific installation.
+echo "Trying to get all of the configs."
+par -q -n $PAR_COUNT -c "rancid-fe \{}" $DIR/allrouters
+
+# This section will generate a list of missed routers
+# and try to grab them again. It will run through
+# $pass times.
+pass=4
+round=1
+if [ -f $DIR/allrouters.missed ]; then
+ rm -f $DIR/allrouters.missed
+fi
+while [ $round -le $pass ]
+do
+ echo "====================================="
+ echo "Getting missed routers: round $round."
+
+ for router in `cat $DIR/allrouters`
+ do
+ OFS=$IFS
+ IFS=':'
+ set $router
+ IFS=$OFS
+ router=$1; mfg=$2
+
+ if [ ! -f $DIR/configs/$router.new ]
+ then
+ echo "$router:$mfg" >> $DIR/allrouters.missed
+ fi
+ done
+
+ if [ -f $DIR/allrouters.missed ]; then
+ par -q -n $PAR_COUNT -c "rancid-fe \{}" $DIR/allrouters.missed
+ rm -f $DIR/allrouters.missed
+ round=`expr $round + 1`
+ else
+ echo "All routers sucessfully completed."
+ round=`expr $pass + 1`
+ fi
+done
+echo
+
+# Now that we have the new configs, rename them to their proper
+# name.
+rename 's/.new$//' *.new
+
+# This has been different for different machines...
+# Diff the directory and then checkin.
+cd $DIR
+#cvs diff -c3 >$TMP.diff
+#cvs diff -C 3 >$TMP.diff
+cat > $TMP.sedf << EOF
+/^RCS file: /d
+#/^retrieving revision /d
+/^--- /d
+/^+++ /d
+s/^\([-+ ]\)/\1 /
+EOF
+cvs -f diff -u -4 | sed -f $TMP.sedf >$TMP.diff
+rm -f $TMP.sedf
+
+cvs commit -m updates
+
+# Mail out the diffs (if there are any).
+if [ -s $TMP.diff ]; then
+ sendmail -t <<EMAIL
+To: rancid-$GROUP
+Subject: $GROUP router config diffs
+Precedence: bulk
+
+`cat $TMP.diff`
+EMAIL
+fi
+
+# If any machines have not been reached within 24 hours, mail
+# out a list of them.
+cd $DIR/configs
+rm -f $DIR/routers.failed
+perl -F: -ane '{$t = (stat($F[0]))[9]; print `ls -ld $F[0]`
+ if (time() - $t >= 86400);}' $DIR/allrouters | sort -u > $DIR/routers.failed
+if [ -s $DIR/routers.failed ]
+then
+ (
+ cat <<END
+The following routers have not been successfully contacted within the
+last 24 hours.
+
+END
+ cat $DIR/routers.failed
+ ) | Mail -s "config fetcher problems - $GROUP" rancid-admin-$GROUP
+fi
+
+# Cleanup
+rm -f $TMP.diff $TMP.lst
diff --git a/bin/create_cvs b/bin/create_cvs
new file mode 100755
index 0000000..675cda8
--- /dev/null
+++ b/bin/create_cvs
@@ -0,0 +1,81 @@
+#!/bin/sh
+##
+##
+## Copyright (C) 1996 by Henry Kilmer.
+## All rights reserved.
+##
+## This software may be freely copied, modified and redistributed without
+## fee for non-commerical purposes provided that this copyright notice is
+## preserved intact on all copies and modified copies.
+##
+## 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.
+##
+##
+#
+# Create all of the misc files & dirs needed.
+#
+# create_cvs
+#
+
+# Read in the environment
+ENVFILE="`dirname $0`/env"
+
+. $ENVFILE
+
+# Top level CVS stuff
+if [ ! -d $CVSROOT ]; then
+ cvs init
+fi
+
+# Log dir
+if [ ! -d $BASEDIR/logs ]; then
+ mkdir $BASEDIR/logs
+fi
+
+# Which groups to do
+if [ $# -ge 1 ] ; then
+ LIST_OF_GROUPS="$*"; export LIST_OF_GROUPS
+elif [ "$LIST_OF_GROUPS" = "" ] ; then
+ echo "LIST_OF_GROUPS is empty in $ENVFILE"
+ exit 1
+fi
+
+for GROUP in `echo $LIST_OF_GROUPS` ;
+do
+
+ DIR=$BASEDIR/$GROUP
+
+ # Directory for the group and the configs
+ if [ ! -d $DIR ]; then
+ mkdir -p $DIR
+ cd $DIR
+ cvs import -m "$GROUP" $GROUP new rancid
+ cd $BASEDIR
+ cvs co $GROUP
+ fi
+ if [ -d $DIR -a ! -d $DIR/configs ]; then
+ cd $DIR
+ mkdir configs
+ cvs add configs
+ cvs commit -m 'new' configs
+ cd $BASEDIR
+ fi
+
+ # main files
+ if [ ! -f $DIR/allrouters ]; then
+ cd $DIR
+ touch $DIR/allrouters
+ cd $BASEDIR
+ fi
+ if [ ! -f $DIR/router.db ]; then
+ cd $DIR
+ touch router.db
+ cvs add router.db
+ cvs commit -m 'new' router.db
+ cd $BASEDIR
+ fi
+done
diff --git a/bin/cvs_helper b/bin/cvs_helper
new file mode 100644
index 0000000..fe46435
--- /dev/null
+++ b/bin/cvs_helper
@@ -0,0 +1,28 @@
+#!/bin/sh
+##
+##
+## Copyright (C) 1996 by Henry Kilmer.
+## All rights reserved.
+##
+## This software may be freely copied, modified and redistributed without
+## fee for non-commerical purposes provided that this copyright notice is
+## preserved intact on all copies and modified copies.
+##
+## 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.
+##
+##
+#
+# cvs_helper
+#
+
+# Remove old config
+rm <file>
+cvs remove <file>
+
+# Look at an old revision...put file in <dir>
+cvs export -d <dir> -rX.YZ
+
diff --git a/bin/do-diffs b/bin/do-diffs
new file mode 100755
index 0000000..3b5eced
--- /dev/null
+++ b/bin/do-diffs
@@ -0,0 +1,43 @@
+#!/bin/sh
+##
+# do diffs for each of the diff groups ($LIST_OF_GROUPS) from <BASEDIR>/bin/env
+##
+
+ENVFILE="`dirname $0`/env"
+
+. $ENVFILE
+
+if [ $# -ge 1 ] ; then
+ LIST_OF_GROUPS="$*"; export LIST_OF_GROUPS
+elif [ "$LIST_OF_GROUPS" = "" ] ; then
+ echo "LIST_OF_GROUPS is empty in $ENVFILE"
+ exit 1
+fi
+
+if [ ! -d $BASEDIR/logs ] ; then
+ mkdir $BASEDIR/logs
+fi
+
+for GROUP in $LIST_OF_GROUPS
+do
+
+ LOCKFILE=/tmp/.$GROUP.run.lock
+
+ (
+ echo starting: `date`
+ echo
+
+ if [ -f $LOCKFILE ]
+ then
+ echo hourly config diffs failed: $LOCKFILE exists
+ /bin/ls -l $LOCKFILE
+ else
+ /usr/bin/touch $LOCKFILE
+ control_rancid $GROUP
+ /bin/rm -f $LOCKFILE
+ fi
+
+ echo ending: `date`
+ echo
+ ) >$BASEDIR/logs/$GROUP.`date +%y%m%d.%H%M%S` 2>&1
+done
diff --git a/bin/env b/bin/env
new file mode 100644
index 0000000..14ae8a1
--- /dev/null
+++ b/bin/env
@@ -0,0 +1,21 @@
+#
+# This file setups up the environment used for rancid
+#
+# This will be site specific
+#
+TERM=network;export TERM
+#
+# Under $BASEDIR, there will be a bin directory for the rancid programs,
+# a log directory for the logs from rancid and a directory for each group
+# of routers. In addition to these directories, there will be the CVS
+# repositories as well.
+#
+BASEDIR=$HOME/rancid; export BASEDIR
+PATH=$BASEDIR/bin:/usr/local/bin:/usr/ucb:/usr/bin:/bin:/usr/lib:/usr/sbin;export PATH
+CVSROOT=$BASEDIR/CVS; export CVSROOT
+LIST_OF_GROUPS="sl joebobisp"
+# For each group, define a list of people to receive the diffs
+# in a .mailrc file in the following format:
+# alias rancid-$GROUP hank@rem.com pwhiting@sprint.net
+#
+umask 007
diff --git a/bin/jlogin b/bin/jlogin
new file mode 100755
index 0000000..485db7f
--- /dev/null
+++ b/bin/jlogin
@@ -0,0 +1,402 @@
+#!/usr/local/bin/expect --
+##
+##
+## Copyright (C) 1997 by Henry Kilmer, Erik Sherk and Pete Whiting.
+## All rights reserved.
+##
+## This software may be freely copied, modified and redistributed without
+## fee for non-commerical purposes provided that this copyright notice is
+## preserved intact on all copies and modified copies.
+##
+## 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.
+##
+##
+#
+# jlogin - juniper ssh login
+#
+## Most options are intuitive for logging into a Cisco router.
+## The default username password is the same as the vty password.
+#
+
+# Usage line
+set usage "Usage: $argv0 \[-e encryption_type\] \[-u username\] \[-p user-password\]\
+\[-f cloginrc-file\] \[-c command\] \[-s script-file\]\
+router \[router...\]\n"
+
+# env(CLOGIN) may contain the following chars:
+# x == do not set xterm banner or name
+
+# Password file
+set password_file $env(HOME)/.cloginrc
+# Default is to login to the router
+set do_command 0
+set do_script 0
+# The default is to automatically enable
+set enable 1
+# The default is to look in the password file to find the passwords. This
+# tracks if we receive them on the command line.
+set do_passwd 1
+
+# Find the user in the ENV, or use the unix userid.
+if {[ info exists env(CISCO_USER) ] } {
+ set default_user $env(CISCO_USER)
+} else {
+ # This uses "id" which I think is portable. At least it has existed
+ # (without options) on all machines/OSes I've been on recently -
+ # unlike whoami or id -nu.
+ regexp {\(([^)]*)} [exec id] junk default_user
+}
+
+# Sometimes routers take awhile to answer (the default is 10 sec)
+set timeout 45
+
+# Process the command line
+for {set i 0} {$i < $argc} {incr i} {
+ set arg [lindex $argv $i]
+
+ switch -glob -- $arg {
+ # Username
+ -u* -
+ -U* {
+ if {! [ regexp .\[uU\](.+) $arg ignore user]} {
+ incr i
+ set username [ lindex $argv $i ]
+ }
+ # user Password
+ } -p* -
+ -P* {
+ if {! [ regexp .\[pP\](.+) $arg ignore userpswd]} {
+ incr i
+ set userpswd [ lindex $argv $i ]
+ }
+ set do_passwd 0
+ # Command to run.
+ } -c* -
+ -C* {
+ if {! [ regexp .\[cC\](.+) $arg ignore command]} {
+ incr i
+ set command [ lindex $argv $i ]
+ }
+ set do_command 1
+ # Expect script to run.
+ } -s* -
+ -S* {
+ if {! [ regexp .\[sS\](.+) $arg ignore sfile]} {
+ incr i
+ set sfile [ lindex $argv $i ]
+ }
+ if { ! [ file readable $sfile ] } {
+ send_user "Error: Can't read $sfile\n"
+ exit 1
+ }
+ set do_script 1
+ # encryption type
+ } -e* -
+ -E* {
+ if {! [ regexp .\[eE\](.+) $arg ignore encrypt]} {
+ incr i
+ set encrypt [ lindex $argv $i ]
+ }
+ # alternate cloginrc file
+ } -f* -
+ -F* {
+ if {! [ regexp .\[fF\](.+) $arg ignore password_file]} {
+ incr i
+ set password_file [ lindex $argv $i ]
+ }
+ } -* {
+ send_user "Error: Unknown argument! $arg\n"
+ send_user $usage
+ exit 1
+ } default {
+ break
+ }
+ }
+}
+# Process routers...no routers listed is an error.
+if { $i == $argc } {
+ send_user "Error: $usage"
+}
+
+# Only be quiet if we are running a script (it can log its output
+# on its own)
+if { $do_script } {
+ log_user 0
+} else {
+ log_user 1
+}
+
+#
+# Done configuration/variable setting. Now run with it...
+#
+
+# Sets Xterm title if interactive...if its an xterm and the user cares
+proc label { host } {
+ global env
+ # if CLOGIN has an 'x' in it, don't set the xterm name/banner
+ if [info exists env(CLOGIN)] {
+ if {[string first "x" $env(CLOGIN)] != -1} { return }
+ }
+ # take host from ENV(TERM)
+ if [info exists env(TERM)] {
+ if [regexp \^(xterm|vs) $env(TERM) ignore ] {
+ send_user "\033]1;[lindex [split $host "."] 0]\a"
+ send_user "\033]2;$host\a"
+ }
+ }
+}
+
+# This is a helper function to make the password file easier to
+# maintain. Using this the password file has the form:
+# add password sl* pete cow
+# add password at* steve
+# add password * hanky-pie
+proc add {var args} { global $var ;lappend $var $args }
+
+proc find {var router} {
+ source_password_file
+ upvar $var list
+ if { [info exists list] } {
+ foreach line $list {
+ if { [string match [lindex $line 0] $router ] } {
+ return [lrange $line 1 end]
+ }
+ }
+ }
+ return {}
+}
+
+# Loads the password file. Note that as this file is tcl, and that
+# it is sourced, the user better know what to put in there, as it
+# could install more than just password info... I will assume however,
+# that a "bad guy" could just as easy put such code in the clogin
+# script, so I will leave .cloginrc as just an extention of that script
+proc source_password_file { } {
+ global env password_file read_password_file
+ if { [info exists read_password_file] } { return }
+ if { [info exists password_file] == 0 } {
+ set password_file $env(HOME)/.cloginrc
+ }
+ set read_password_file 1
+ file stat $password_file fileinfo
+ if { [expr ($fileinfo(mode) & 007)] != 0000 } {
+ send_user "Error: $password_file must not be world readable/writable\n"
+ exit 1
+ }
+ source $password_file
+}
+
+# Log into the router.
+proc login { router user passwd prompt encrypttype} {
+ global spawn_id in_proc do_command do_script
+ set in_proc 1
+
+ # ssh to the router & try to login.
+ if [ catch {spawn ssh -c $encrypttype -x -l $user $router} reason ] {
+ send_user "Error: failed to ssh: $reason\n"
+ exit 1
+ }
+ sleep 0.3
+
+ # This helps cleanup each expect clause.
+ expect_after {
+ timeout {
+ send_user "\nError: TIMEOUT reached\n"
+ close; wait
+ if { $in_proc} {
+ return 1
+ } else {
+ continue
+ }
+ } eof {
+ send_user "\nError: EOF received\n"
+ close; wait
+ if { $in_proc} {
+ return 1
+ } else {
+ continue
+ }
+ }
+ }
+
+ # Here we get a little tricky. There are several possibilities:
+ # the router can ask for a username and passwd and then
+ # talk to the TACACS server to authenticate you, or if the
+ # TACACS server is not working, then it will use the enable
+ # passwd. Or, the router might not have TACACS turned on,
+ # then it will just send the passwd.
+ expect {
+ eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ "Connection refused" {
+ expect eof
+ send_user "Error: Connection Refused\n"; wait; return 1
+ } "Unknown host\r\n" {
+ expect eof
+ send_user "Error: Unknown host\n"; wait; return 1
+ } "Host is unreachable" {
+ expect eof
+ send_user "Error: Host Unreachable!\n"; wait; return 1
+ } "No address associated with name" {
+ expect eof
+ send_user "Error: Unknown host\n"; wait; return 1
+ }
+ -re "Host key not found .* \(yes\/no\)\?" {
+ send "yes\r"
+ send_user "Host $router added to the list of known hosts.\n"
+ exp_continue }
+ -re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" {
+ send "no\r"
+ send_user "Error: The host key for $router has changed. update the known_hosts file accordingly.\n"
+ return 1 }
+ -re "(Username|^login):" { send "$user\r"
+ expect {
+ eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ -re "\[Pp]assword:" { send "$passwd\r" }
+ "$prompt" { set in_proc 0; return 0 }
+ }
+ exp_continue
+ }
+ "\[Pp]assword:" { send "$passwd\r"
+ expect {
+ eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ "$prompt" { set in_proc 0; return 0 }
+ }
+ exp_continue
+ }
+ "$prompt" { }
+ denied { send_user "Error: Check your passwd for $router\n"
+ if { $do_command || $do_script } {
+ send "quit"
+ wait
+ return 1
+ } else {
+ return 1
+ }
+ }
+ "% Bad passwords" {send_user "Error: Check your passwd for $router\n"; return 1 }
+ }
+ set in_proc 0
+ return 0
+}
+
+# Run commands given on the command line.
+proc run_commands { prompt command } {
+ global in_proc
+ set in_proc 1
+
+ send "set cli complete-on-space off\r"
+ expect $prompt {}
+ send "set cli screen-length 0\r"
+ expect $prompt {}
+
+ # Is this a multi-command?
+ if [ string match "*\;*" "$command" ] {
+ set commands [split $command \;]
+ set num_commands [llength $commands]
+
+ for {set i 0} {$i < $num_commands} { incr i} {
+ send "[lindex $commands $i]\r"
+ expect {
+ -re "^\[^\n\r *]*$prompt $" {}
+ -re "^\[^\n\r]*$prompt." { exp_continue }
+ -re "(\r\n|\n)" { exp_continue }
+ }
+ }
+ } else {
+ send "$command\r"
+ expect {
+ -re "^\[^\n\r *]*$prompt $" {}
+ -re "^\[^\n\r]*$prompt." { exp_continue }
+ -re "(\r\n|\n)" { exp_continue }
+ }
+ }
+ send "quit\r"
+ expect {
+ "\n" { exp_continue }
+ timeout { return 0 }
+ eof { return 0 }
+ }
+ set in_proc 0
+}
+
+#
+# For each router... (this is main loop)
+#
+set in_proc 0
+foreach router [lrange $argv $i end] {
+ set router [string tolower $router]
+ send_user "$router\n"
+
+ set prompt ">"
+
+ # Figure out passwords
+# if { $do_passwd } {
+# set pswd [find password $router]
+# if { [llength $pswd] == 0 } {
+# send_user "Error - no password for $router in $password_file.\n"
+# continue
+# }
+# if { $do_enapasswd && !$autoenable && [llength $pswd] < 2 } {
+# send_user "Error - no enable password for $router in $password_file."
+# continue
+# }
+# set passwd [lindex $pswd 0]
+# }
+
+ # Figure out username
+ if {[info exists username]} {
+ # command line username
+ set loginname $username
+ } else {
+ set loginname [find user $router]
+ if { "$loginname" == "" } { set loginname $default_user }
+ }
+
+ # Figure out loginname's password (if different from the vty password)
+ if {[info exists userpswd]} {
+ # command line passwd
+ set passwd $userpswd
+ } else {
+ set passwd [lindex [find password $loginname@$router] 0]
+ if { "$passwd" == "" } { set passwd [lindex [find password $router] 0] }
+ }
+
+ # Figure out encryption tpye
+ if {[info exists encrypt]} {
+ # command line encryption type
+ set encrypttype $encrypt
+ } else {
+ set encrypttype "3des"
+ }
+
+ # Login to the router
+ if {[login $router $loginname $passwd $prompt $encrypttype]} {
+ continue
+ }
+
+ if { $do_command } {
+ if {[run_commands $prompt $command]} {
+ continue
+ }
+ } elseif { $do_script } {
+ send "set cli complete-on-space off\r"
+ expect $prompt {}
+ send "set cli screen-length 0\r"
+ expect $prompt {}
+ source $sfile
+ close
+ } else {
+ label $router
+ log_user 1
+ interact
+ }
+
+ # End of for each router
+ wait
+ sleep 0.3
+}
+exit 0
diff --git a/bin/jrancid b/bin/jrancid
new file mode 100755
index 0000000..b5b968e
--- /dev/null
+++ b/bin/jrancid
@@ -0,0 +1,327 @@
+#!/usr/local/bin/perl
+##
+## Amazingly hacked version of Hank's rancid - this one tries to
+## deal with Junipers.
+##
+## Original Rancid: Copyright (C) 1997 by Henry Kilmer.
+## All rights reserved.
+##
+## This software may be freely copied, modified and redistributed without
+## fee for non-commerical purposes provided that this copyright notice is
+## preserved intact on all copies and modified copies.
+##
+## 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.
+##
+##
+#
+# RANCID - Really Awesome New Cisco confIg Differ
+#
+# usage: jrancid [-d] [-l] [-f filename | $host]
+#
+use Getopt::Std;
+getopts('dfl');
+$debug = $opt_d;
+$log = $opt_l;
+$file = $opt_f;
+$host = $ARGV[0];
+
+$clean_run = 0;
+
+# This routine is used to print out the router configuration
+sub ProcessHistory {
+ my($new_hist_tag,$new_command,$command_string,@string)=(@_);
+ if((($new_hist_tag ne $hist_tag) || ($new_command ne $command))
+ && defined %history) {
+ print eval "$command \%history";
+ undef %history;
+ }
+ if (($new_hist_tag) && ($new_command) && ($command_string)) {
+ if ($history{$command_string}) {
+ $history{$command_string} = "$history{$command_string}@string";
+ } else {
+ $history{$command_string} = "@string";
+ }
+ } elsif (($new_hist_tag) && ($new_command)) {
+ $history{++$#history} = "@string";
+ } else {
+ print "@string";
+ }
+ $hist_tag = $new_hist_tag;
+ $command = $new_command;
+ 1;
+}
+
+sub numerically { $a <=> $b; }
+
+# This is a sort routing that will sort numerically on the
+# keys of a hash as if it were a normal array.
+sub keynsort {
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $key (sort numerically keys(%lines)) {
+ $sorted_lines[$i] = $lines{$key};
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# This is a sort routing that will sort on the
+# keys of a hash as if it were a normal array.
+sub keysort {
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $key (sort keys(%lines)) {
+ $sorted_lines[$i] = $lines{$key};
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# This is a sort routing that will sort on the
+# values of a hash as if it were a normal array.
+sub valsort{
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $key (sort values %lines) {
+ $sorted_lines[$i] = $key;
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# This is a numerical sort routing (ascending).
+sub numsort {
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $num (sort {$a <=> $b} keys %lines) {
+ $sorted_lines[$i] = $lines{$num};
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# This is a sort routine that will sort on the
+# ip address when the ip address is anywhere in
+# the strings.
+sub ipsort {
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $addr (sort sortbyipaddr keys %lines) {
+ $sorted_lines[$i] = $lines{$addr};
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# These two routines will sort based upon IP addresses
+sub ipaddrval {
+ my(@a) = ($_[0] =~ m#^(\d+)\.(\d+)\.(\d+)\.(\d+)$#);
+ $a[3]+256*($a[2]+256*($a[1]+256*$a[0]));
+}
+sub sortbyipaddr {
+ &ipaddrval($a) <=> &ipaddrval($b);
+}
+
+###
+### Start of real work
+###
+
+# This routine parses "show chassis clocks"
+sub ShowChassisClocks {
+ print STDERR " In ShowChassisClocks: $_" if ($debug);
+ /error: the chassis subsystem is not running/ && return;
+ ProcessHistory("","","","# $_") && return;
+ return;
+}
+
+# This routine parses "show chassis environment"
+sub ShowChassisEnvironment {
+ print STDERR " In ShowChassisEnvironment: $_" if ($debug);
+ /error: the chassis subsystem is not running/ && return;
+ /Couldn\'t initiate connection/ && return;
+ / backplane temperature/ && return;
+ /(\s*Power supply.*), temperature/ && ProcessHistory("","","","# $1\n") && return;
+ /(\s*.+) +\d+ degrees C.*$/ && ProcessHistory("","","","# $1\n") && return;
+ ProcessHistory("","","","# $_") && return;
+ return;
+}
+
+# This routine parses "show chassis firmware"
+sub ShowChassisFirmware {
+ print STDERR " In ShowChassisFirmware: $_" if ($debug);
+ /error: the chassis subsystem is not running/ && return;
+ ProcessHistory("","","","# $_") && return;
+ return;
+}
+
+# This routine parses "show chassis fpc detail"
+sub ShowChassisFpcDetail {
+ print STDERR " In ShowChassisFpcDetail: $_" if ($debug);
+ /error: the chassis subsystem is not running/ && return;
+ / Temperature:/ && return;
+ / Start time:/ && return;
+ / Uptime:/ && return;
+ ProcessHistory("","","","# $_") && return;
+ return;
+}
+
+# This routine parses "show chassis hardware"
+sub ShowChassisHardware {
+ print STDERR " In ShowChassisHardware: $_" if ($debug);
+ /error: the chassis subsystem is not running/ && return;
+ ProcessHistory("","","","# $_") && return;
+ return;
+}
+
+# This routine parses "show chassis routing-engine"
+sub ShowChassisRoutingEngine {
+ print STDERR " In ShowChassisRoutingEngine: $_" if ($debug);
+ /^Routing Engine status:/ && ProcessHistory("","","","# $_") && return;
+ / DRAM:/ && ProcessHistory("","","","# $_") && return;
+ /^\s*$/ && ProcessHistory("","","","# $_") && return;
+ return;
+}
+
+# This routine parses "show chassis scb"
+sub ShowChassisSCB {
+ print STDERR " In ShowChassisSCB: $_" if ($debug);
+ /error: the chassis subsystem is not running/ && return;
+ / Temperature:/ && return;
+ / utilization:/ && return;
+ /time:/ && return;
+ / (IP|MLPS) routes:/ && return;
+ / used:/ && return;
+ ProcessHistory("","","","# $_") && return;
+ return;
+}
+
+# This routine parses "show version"
+sub ShowVersion {
+ print STDERR " In ShowVersionAndBlame: $_" if ($debug);
+ /^Juniper Networks is:/ && ProcessHistory("","","","\n$_") && return;
+ ProcessHistory("","","","# $_") && return;
+ return;
+}
+
+# This routine parses "show configuration"
+sub ShowConfiguration {
+ print STDERR " In ShowConfiguration: $_" if ($debug);
+ /^database header mismatch: / && return(-1);
+ s/(\s*authentication-key ).*$/#$1<removed>;/;
+ ProcessHistory("","","","$_") && return;
+ return;
+}
+
+###
+### End of real work
+###
+
+# dummy function
+sub DoNothing {print STDOUT;}
+
+# Main subroutine that splits up the work
+# All Subs return the name of the next function to use.
+# If the sub returns a new funtion name, that name will be used
+# else the main loop keeps using the current function
+sub FlailHelplessly {
+ print STDERR "Flailing: $_" if ($debug);
+ print STDOUT "Flailing: $_" if ($log);
+ /(show chassis clocks)/ && delete($commands{$1}) && return("ShowChassisClocks");
+ /(show chassis environment)/ && delete($commands{$1}) && return("ShowChassisEnvironment");
+ /(show chassis firmware)/ && delete($commands{$1}) && return("ShowChassisFirmware");
+ /(show chassis fpc detail)/ && delete($commands{$1}) && return("ShowChassisFpcDetail");
+ /(show chassis hardware)/ && delete($commands{$1}) && return("ShowChassisHardware");
+ /(show chassis routing-engine)/ && delete($commands{$1}) && return("ShowChassisRoutingEngine");
+ /(show chassis scb)/ && delete($commands{$1}) && return("ShowChassisSCB");
+ /(show version)/ && delete($commands{$1}) && return("ShowVersion");
+ /(show configuration)/ && delete($commands{$1}) && return("ShowConfiguration");
+ return "FlailHelplessly";
+}
+
+# Main
+@commands=("show chassis clocks", "show chassis environment",
+ "show chassis firmware", "show chassis fpc detail",
+ "show chassis hardware", "show chassis routing-engine",
+ "show chassis scb", "show version", "show configuration");
+
+foreach $c (@commands) { $commands{$c} = 1; }
+$jnx_commands=join(";",@commands);
+$cmds_regexp=join("|",@commands);
+$func = FlailHelplessly;
+
+open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
+# make OUTPUT unbuffered
+select(OUTPUT); $| = 1;
+
+if ($file) {
+ print STDERR "opening file $host\n" if ($debug);
+ print STDOUT "opening file $host\n" if ($log);
+ open(INPUT,"< $host") || die "open failed for $host: $!\n";
+} else {
+ print(STDERR "executing echo jlogin -c\"$jnx_commands\" $host\n") if ($debug);
+ print(STDOUT "executing echo jlogin -c\"$jnx_commands\" $host\n") if ($debug);
+ open(INPUT,"jlogin -c\"$jnx_commands\" $host </dev/null |") ||
+ die "jlogin failed for $host: $!\n";
+}
+while(<INPUT>) {
+ tr/\015//d;
+ if (/quit/) {
+ delete($commands{"quit"});
+ $clean_run=1;
+ last;
+ }
+ if (/^Error:/) {
+ print STDOUT ("$host jlogin error: $_");
+ print STDERR ("$host jlogin error: $_") if ($debug);
+ $clean_run=0;
+ last;
+ }
+ if (/System shutdown message/) {
+ print STDOUT ("$host shutdown msg: $_");
+ print STDERR ("$host shutdown msg: $_") if ($debug);
+ $clean_run = 0;
+ last;
+ }
+ if (/($cmds_regexp)/) {
+ ProcessHistory("","","","# $host> $1\n");
+ $func = FlailHelplessly;
+ print STDERR ("HIT COMMAND:$_") if ($debug);
+ } else {
+ $rval=eval $func;
+ if ($rval == -1) {
+ $clean_run = 0;
+ last;
+ }
+ $func=$rval if ($rval);
+ }
+}
+print STDOUT "Done jlogin: $_\n" if ($log);
+# Flush History
+ProcessHistory("","","","");
+# Cleanup
+close(INPUT);
+close(OUTPUT);
+
+# check for completeness
+$commands = join(", ", keys(%commands));
+if (scalar(%commands) || !$clean_run) {
+ if (scalar(%commands)) {
+ print STDOUT "missed cmd(s): $commands\n";
+ print STDERR "missed cmd(s): $commands[0]\n" if ($debug);
+ }
+ if (!$clean_run) {
+ print STDOUT "End of run not found - removing $host.new\n";
+ print STDERR "End of run not found - removing $host.new\n" if ($debug);
+ system("/usr/bin/tail -1 $host.new");
+ }
+ unlink "$host.new";
+}
diff --git a/bin/par b/bin/par
new file mode 100755
index 0000000..a0138d8
--- /dev/null
+++ b/bin/par
@@ -0,0 +1,128 @@
+#!/usr/local/bin/perl
+##
+##
+## Copyright (C) 1997 by Henry Kilmer and Peter Whiting.
+## All rights reserved.
+##
+## This software may be freely copied, modified and redistributed without
+## fee for non-commerical purposes provided that this copyright notice is
+## preserved intact on all copies and modified copies.
+##
+## 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.
+##
+##
+#
+# PAR - parallel processing of command
+#
+# par -q -n # -l logfile -c command -x -d
+# -q = quiet mode (don't log anything to the logfiles)
+# -n # = number of processes to run at once (default = 3)
+# -l logfile = logfile to store par logging into (.0-.n)
+# -c command = command to run (can also be in the list
+# of routers begining with a :
+# -x = view par logs as they run through xterms
+# -i = run commands through interactive xterms
+# -d = print debugging to stderr
+#
+# par takes a list of items to run a command on. If the list entry begins
+# with a ":" the remainder of the line is the command to run ("{}" will be
+# replaced with each subsequent item in the list. If the list entry begins
+# with a "#", the entry is ignored. If a command is defined (either with
+# the -c or with a : line) any entry thereafter will be applied to the
+# command by replacing the {} brackets. In no cammand is defined, then each
+# line is assumed to be a command to be run.
+#
+use Getopt::Std;
+getopts('n:l:c:xidq');
+$procs=$opt_n; $procs=3 if(!$procs);
+$command=$opt_c;$command="{}" if(!$command);
+$parlog=$opt_l; $parlog="par.log.".time if(!$parlog);
+$debug=$opt_d;
+
+if ($opt_q && ($opt_x || $opt_l)) {
+ print STDERR "-q nullifies -x and -l\n";
+ exit 1;
+}
+
+$signalled=0;
+
+sub handler {
+ $signalled++;
+ print STDERR "Received signal - ending run ($signalled).\n";
+ if($signalled>1) {
+ printf STDERR "Ok - killing $id!\n";
+ kill 9, 0;
+ exit(1);
+ }
+}
+
+$SIG{'INT'} = 'handler';
+$SIG{'TERM'} = 'handler';
+$SIG{'QUIT'} = 'handler';
+
+sub start {
+ local($cmd,$logfile)=@_;
+ unless ($id=fork) {
+ if (!$opt_q) {
+ local($date)=scalar localtime;
+ open(LOG,">>$logfile");
+ print(LOG "!!!!!!!\n!$date: $cmd\n!!!!!!!\n");
+ close(LOG);
+ exec "($cmd) >>$logfile";
+ } else {
+ exec "($cmd)";
+ }
+ exit 0;
+ }
+ print STDERR "Starting $cmd: process id=$id logfile=$logfile\n" if ($debug);
+ $id;
+}
+
+sub finish {
+ if(($id=wait)>0){
+ $logfile=$log{$id};
+ print STDERR "$id finished (logfile $logfile)\n" if($logfile && $debug);
+ $logfile;
+ }
+}
+
+sub watchf {
+ local($log)=@_;
+ unless(fork) { exec "xterm -e tail -f $log" ; exit 1; }
+}
+
+for($i=0;<>;$i++) {
+ chop;
+ if (/^\#/){$i--;next;}
+ if(/^:(.*)$/){$command=$1;$i--;next;}
+ if ($i<$procs) {
+ $logfile="running.$i"; $logfile="$parlog.$i" if (!$opt_q);
+ watchf($logfile) if($opt_x);
+ } else { $logfile=finish; }
+ last if $signalled;
+ if ($logfile) {
+ $cmd = $command;
+ $cmd =~ s/\{\}/$_/g;
+ $cmd = "xterm -e $cmd" if ($opt_i);
+ $id=start($cmd,$logfile);
+ $log{$id}=$logfile;
+ }
+ print STDERR "$i/$procs: $_: id=$id, log=$log{$id}\n" if ($debug);
+}
+
+if($signalled && !eof) {
+ $i--;
+ print STDERR "Signalled - not running these:\n$_\n";
+ while(<>){print STDERR;}
+} else {
+ print STDERR "All work assigned. Waiting for remaining processes.\n" if ($debug);
+}
+$procs=$i if ($i<$procs);
+while($procs) {
+ $procs-- if(finish);
+}
+print STDERR "Complete\n" if ($debug);
diff --git a/bin/rancid b/bin/rancid
new file mode 100755
index 0000000..9b346fe
--- /dev/null
+++ b/bin/rancid
@@ -0,0 +1,800 @@
+#!/usr/local/bin/perl
+##
+##
+## Copyright (C) 1997 by Henry Kilmer.
+## All rights reserved.
+##
+## This software may be freely copied, modified and redistributed without
+## fee for non-commerical purposes provided that this copyright notice is
+## preserved intact on all copies and modified copies.
+##
+## 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.
+##
+##
+#
+# RANCID - Really Awesome New Cisco confIg Differ
+#
+# usage: rancid [-d] [-l] [-f filename | $host]
+#
+use Getopt::Std;
+getopts('dflm');
+$log = $opt_l;
+$debug = $opt_d;
+$file = $opt_f;
+$host = $ARGV[0];
+$clean_run = 0;
+$found_end = 0;
+$timeo = 90; # clogin time in seconds
+
+# This routine is used to print out the router configuration
+sub ProcessHistory {
+ my($new_hist_tag,$new_command,$command_string,@string)=(@_);
+ if((($new_hist_tag ne $hist_tag) || ($new_command ne $command))
+ && defined %history) {
+ print eval "$command \%history";
+ undef %history;
+ }
+ if (($new_hist_tag) && ($new_command) && ($command_string)) {
+ if ($history{$command_string}) {
+ $history{$command_string} = "$history{$command_string}@string";
+ } else {
+ $history{$command_string} = "@string";
+ }
+ } elsif (($new_hist_tag) && ($new_command)) {
+ $history{++$#history} = "@string";
+ } else {
+ print "@string";
+ }
+ $hist_tag = $new_hist_tag;
+ $command = $new_command;
+ 1;
+}
+
+sub numerically { $a <=> $b; }
+
+# This is a sort routing that will sort numerically on the
+# keys of a hash as if it were a normal array.
+sub keynsort {
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $key (sort numerically keys(%lines)) {
+ $sorted_lines[$i] = $lines{$key};
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# This is a sort routing that will sort on the
+# keys of a hash as if it were a normal array.
+sub keysort {
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $key (sort keys(%lines)) {
+ $sorted_lines[$i] = $lines{$key};
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# This is a sort routing that will sort on the
+# values of a hash as if it were a normal array.
+sub valsort{
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $key (sort values %lines) {
+ $sorted_lines[$i] = $key;
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# This is a numerical sort routing (ascending).
+sub numsort {
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $num (sort {$a <=> $b} keys %lines) {
+ $sorted_lines[$i] = $lines{$num};
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# This is a sort routine that will sort on the
+# ip address when the ip address is anywhere in
+# the strings.
+sub ipsort {
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $addr (sort sortbyipaddr keys %lines) {
+ $sorted_lines[$i] = $lines{$addr};
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# These two routines will sort based upon IP addresses
+sub ipaddrval {
+ my(@a) = ($_[0] =~ m#^(\d+)\.(\d+)\.(\d+)\.(\d+)$#);
+ $a[3]+256*($a[2]+256*($a[1]+256*$a[0]));
+}
+sub sortbyipaddr {
+ &ipaddrval($a) <=> &ipaddrval($b);
+}
+
+# This routine parses "show version"
+sub ShowVersion {
+ print STDERR " In ShowVersion: $_" if ($debug);
+ if (/^Slave in slot (\d+) is running/) {
+ $slave = " Slave:";
+ return;
+ }
+ /^IOS .* Software \(([A-Za-z-0-9]*)\), .*Version\s+(.*)$/ &&
+ ProcessHistory("COMMENTS","keysort","F1","!Image:$slave Software: $1, $2\n") && return;
+ /^([A-Za-z-0-9_]*) Synced to mainline version: (.*)$/ &&
+ ProcessHistory("COMMENTS","keysort","F2",
+ "!Image:$slave $1 Synced to mainline version: $2\n") && return;
+ /^Compiled (.*)$/ &&
+ ProcessHistory("COMMENTS","keysort","F3","!Image:$slave Compiled: $1\n") && return;
+ /^ROM: (System )?Bootstrap.*(Version.*)$/ &&
+ ProcessHistory("COMMENTS","keysort","G1","!ROM Bootstrap: $2\n") && return;
+ /^ROM: \d+ Bootstrap .*(Version.*)$/ &&
+ ProcessHistory("COMMENTS","keysort","G2","!ROM Image: Bootstrap$1\n") &&
+ return;
+ /^ROM: .*(Version.*)$/ &&
+ ProcessHistory("COMMENTS","keysort","G3","!ROM Image: $1\n") && return;
+ /^BOOTFLASH: .*(Version.*)$/ &&
+ ProcessHistory("COMMENTS","keysort","G4","!BOOTFLASH: $1\n") && return;
+ /^System image file is "([^\"]*)", booted via (\S*)/ &&
+# removed the booted source due to
+# CSCdk28131: cycling info in 'sh ver'
+# ProcessHistory("COMMENTS","keysort","F4","!Image: booted via $2, $1\n") &&
+ ProcessHistory("COMMENTS","keysort","F4","!Image: booted $1\n") &&
+ return;
+ /^System image file is "([^\"]*)"$/ &&
+ ProcessHistory("COMMENTS","keysort","F5","!Image: $1\n") &&
+ return;
+ if (/(\S+)\s+\((\S+)\)\s+processor.*with (\S+K) bytes/) {
+ if ( $1 eq "CSC") {
+ $type = "AGS";
+ } elsif ( $1 eq "CSC4") {
+ $type = "AGS+";
+ } elsif ( $1 eq "RSP1") {
+ $type = "7500";
+ } elsif ( $1 eq "RSP2") {
+ $type = "7500";
+ } elsif ( $1 eq "RSP4") {
+ $type = "7500";
+ } elsif ( $1 eq "RSP7000") {
+ $type = "7500";
+ } elsif ( $1 eq "RP1") {
+ $type = "7000";
+ } elsif ( $1 eq "RP") {
+ $type = "7000";
+ } elsif ( $1 eq "7202" || $1 eq "7204" || $1 eq "7206") {
+ $type = "7200";
+ } elsif ($1 eq "12004/GRP" || $1 eq "12008/GRP" || $1 eq "12012/GRP") {
+ $type = "12000";
+ } else {
+ $type = $1;
+ }
+ print STDERR "TYPE = $type\n" if ($debug);
+ ProcessHistory("COMMENTS","keysort","A1","!Chassis type:$slave $1 - a $type router\n");
+ ProcessHistory("COMMENTS","keysort","B1","!Memory:$slave main $3\n");
+ ProcessHistory("COMMENTS","keysort","A3","!CPU:$slave $2\n");
+ return;
+ }
+ if (/(\S+) Silicon\s*Switch Processor/) {
+ if (!defined($C0)) {$C0=1; ProcessHistory("COMMENTS","keysort","C0","!\n");}
+ ProcessHistory("COMMENTS","keysort","C2","!SSP: $1\n");
+ $ssp = 1;
+ $sspmem = $1;
+ return;
+ }
+ /^(\d+K) bytes of multibus/ &&
+ ProcessHistory("COMMENTS","keysort","B2","!Memory: multibus $1\n") && return;
+ /^(\d+K) bytes of non-volatile/ &&
+ ProcessHistory("COMMENTS","keysort","B3","!Memory: nvram $1\n") && return;
+ /^(\d+K) bytes of flash memory/ &&
+ ProcessHistory("COMMENTS","keysort","B5","!Memory: flash $1\n") &&
+ return;
+ /^(\d+K) bytes of .*flash partition/ &&
+ ProcessHistory("COMMENTS","keysort","B6","!Memory: flash partition $1\n") &&
+ return;
+ /^(\d+K) bytes of Flash internal/ &&
+ ProcessHistory("COMMENTS","keysort","B4","!Memory: bootflash $1\n") &&
+ return;
+ /^(\d+K) bytes of Flash PCMCIA card at slot 0 / &&
+ ProcessHistory("COMMENTS","keysort","B7","!Memory: pcmcia slot0 $1\n") && return;
+ /^(\d+K) bytes of Flash PCMCIA card at slot 1 / &&
+ ProcessHistory("COMMENTS","keysort","B8","!Memory: pcmcia slot1 $1\n") && return;
+ if (/^Configuration register is (.*)$/) {
+ $config_register=$1;
+ return;
+ }
+ return;
+}
+
+# This routine parses "show env all"
+sub ShowEnv {
+ # Skip if this is not a 7500 or 7000.
+ print STDERR " In ShowEnv: $_" if ($debug);
+ return if ($type !~ /^7/);
+ if (!defined($E0)) {$E0=1; ProcessHistory("COMMENTS","keysort","E0","!\n");}
+ if (/^Arbiter type (\d), backplane type (\S+)/) {
+ if (!defined($C0)) {$C0=1; ProcessHistory("COMMENTS","keysort","C0","!\n");}
+ ProcessHistory("COMMENTS","keysort","C1","!Enviromental Arbiter Type: $1\n");
+ ProcessHistory("COMMENTS","keysort","A2","!Chassis type: $2 backplane\n");
+ return;
+ }
+ /^\s*(Power .*)/ &&
+ ProcessHistory("COMMENTS","keysort","E1","!Power: $1\n") && return;
+ /^\s*(Lower Power .*)/i &&
+ ProcessHistory("COMMENTS","keysort","E2","!Power: $1\n") && return;
+ return;
+}
+
+# This routine parses "show gsr chassis-info" for the gsr
+# This will create arrarys for hw info.
+sub ShowGSR {
+ # Skip if this is not a 1200n.
+ print STDERR " In ShowGSR: $_" if ($debug);
+ return if ($type !~ /^120/);
+ /^$/ && return;
+ /^\s+Chassis: type (\S+) Fab Ver: (\S+)/ &&
+ ProcessHistory("COMMENTS","keysort","D0","!\n") &&
+ ProcessHistory("COMMENTS","keysort","D1","!GSR Chassis type: $1 Fab Ver: $2\n") && return;
+ /^\s+Chassis S\/N: (.*)$/ &&
+ ProcessHistory("COMMENTS","keysort","D2","!GSR Chassis S/N: $1\n") && return;
+ /^\s+PCA: (\S+)\s*rev: (\S+)\s*dev: \S+\s*HW ver: (\S+)$/ &&
+ ProcessHistory("COMMENTS","keysort","D3","!GSR Backplane PCA: $1, rev $2, ver $3\n") && return;
+ /^\s+Backplane S\/N: (\S+)$/ &&
+ ProcessHistory("COMMENTS","keysort","D4","!GSR Backplane S/N: $1\n") && return;
+
+ return;
+}
+
+# This routine parses "show boot"
+sub ShowBoot {
+ # Pick up boot variables if 7000/7500/12000; otherwise pick up bootflash.
+ print STDERR " In ShowBoot: $_" if ($debug);
+ return if /^\s*$/;
+ return if /^\s*\^\s*$/;
+ return if /Invalid input detected/;
+ return if /(Open device \S+ failed|Error opening \S+:)/;
+ if (!defined($H0)) {$H0=1; ProcessHistory("COMMENTS","keysort","H0","!\n");}
+ if ($type !~ /^(1200|7)/) {
+ ProcessHistory("COMMENTS","keysort","H2","!BootFlash: $_");
+ } elsif (/variable/) {
+ ProcessHistory("COMMENTS","keysort","H1","!Variable: $_");
+ }
+ return;
+}
+
+# This routine parses "show flash"
+sub ShowFlash {
+ # skip if this is 7000, 7200, 7500, or 12000.
+ print STDERR " In ShowFlash: $_" if ($debug);
+ return if /^\s*$/;
+ return if ($type =~ /^(1200|7.0)/);
+ return if /^\s*\^\s*$/;
+ return if /Invalid input detected/;
+ ProcessHistory("FLASH","","","!Flash: $_");
+ return;
+}
+
+# This routine parses "dir /all bootflash:"
+sub DirBootflash {
+ # Skip if this is not a 7000, 7200, 7500, or 12000.
+ print STDERR " In DirBootflash: $_" if ($debug);
+ return if /^\s*$/;
+ return if ($type !~ /^(1200|7.0)/);
+ return if /^\s*\^\s*$/;
+ return if /Invalid input detected/;
+ /: device being squeezed/ && return(-1); # Flash is busy
+ return if /(Open device \S+ failed|Error opening \S+:)/;
+ ProcessHistory("FLASH","","","!Flash: BootFlash: $_");
+ return;
+}
+
+# This routine parses "dir /all slot0:"
+sub DirSlot0 {
+ # Skip if this is not a 3600, 7000, 7200, 7500, or 12000.
+ print STDERR " In DirSlot0: $_" if ($debug);
+ return if /^\s*$/;
+ return if ($type !~ /^(1200|7.0|36.0)/);
+ return if /^\s*\^\s*$/;
+ return if /Invalid input detected/;
+ /: device being squeezed/ && return(-1); # Flash is busy
+ return if /(Open device \S+ failed|Error opening \S+:)/;
+ ProcessHistory("FLASH","","","!Flash: Slot0: $_");
+ return;
+}
+
+# This routine parses "dir /all slot1:"
+sub DirSlot1 {
+ # Skip if this is not a 3600, 7000, 7200, 7500, or 12000.
+ print STDERR " In DirSlot1: $_" if ($debug);
+ return if /^\s*$/;
+ return if ($type !~ /^(1200|7.0|36.0)/);
+ return if /^\s*\^\s*$/;
+ return if /Invalid input detected/;
+ /: device being squeezed/ && return(-1); # Flash is busy
+ return if /(Open device \S+ failed|Error opening \S+:)/;
+ ProcessHistory("FLASH","","","!Flash: Slot1: $_");
+ return;
+}
+
+# This routine parses "show controllers"
+sub ShowContAll {
+ # Skip if this is a 70[01]0, 7500, or 12000.
+ print STDERR " In ShowContAll: $_" if ($debug);
+ return if ($type =~ /^(1200|7[05])/);
+ if (/^Interface (\S*)$/) { $INT = "$1, "; return; }
+ /^(BRI unit \d)/ &&
+ ProcessHistory("INT","","","!Interface: $1\n") && return;
+ /^LANCE unit \d, NIM/ &&
+ ProcessHistory("INT","","","!Interface: $_") && return;
+ /^(LANCE unit \d)/ &&
+ ProcessHistory("INT","","","!Interface: $1\n") && return;
+ /(Media Type is \S+),/ &&
+ ProcessHistory("INT","","","!\t$1\n");
+ if (/(M\dT:) show controller:$/) {
+ my($ctlr) = $1;
+ $_ = <INPUT>; tr/\015//d; s/ subunit \d,//;
+ ProcessHistory("INT","","","!Interface: $ctlr $_");
+ }
+ /^(HD unit \d), idb/ &&
+ ProcessHistory("INT","","","!Interface: $1\n") && return;
+ /^HD unit \d, NIM/ &&
+ ProcessHistory("INT","","","!Interface: $_") && return;
+ /^buffer size \d+ HD unit \d, (.*)/ &&
+ ProcessHistory("INT","","","!\t$1\n") && return;
+ /^AM79970 / && ProcessHistory("INT","","","!Interface: $_") && return;
+ /^buffer size \d+ (Universal Serial: .*)/ &&
+ ProcessHistory("INT","","","!\t$1\n") && return;
+ /^Hardware is (.*)/ &&
+ ProcessHistory("INT","","","!Interface: $INT$1\n") && return;
+ /^(QUICC Serial unit \d),/ &&
+ ProcessHistory("INT","","","!$1\n") && return;
+ /^QUICC Ethernet .*/ &&
+ ProcessHistory("INT","","","!$_") && return;
+ /^DTE .*\.$/ &&
+ ProcessHistory("INT","","","!\t$_") && return;
+ /^(cable type :.*),/ &&
+ ProcessHistory("INT","","","!\t$1\n") && return;
+ /^(.* cable.*), received clockrate \d+$/ &&
+ ProcessHistory("INT","","","!\t$1\n") && return;
+ /^.* cable.*$/ &&
+ ProcessHistory("INT","","","!\t$_") && return;
+ return;
+}
+
+# This routine parses "show controllers cbus"
+# Some of this is printed out in ShowDiagbus.
+sub ShowContCbus {
+ # Skip if this is not a 7000 or 7500.
+ print STDERR " In ShowContCbus: $_" if ($debug);
+ return if ($type !~ /^7[05]0/);
+ if (/^\s*slot(\d+): ([^,]+), hw (\S+), sw (\S+), ccb/) {
+ $slot = $1;
+ $board{$slot} = $2;
+ $hwver{$slot} = $3;
+ $hwucode{$slot} = $4;
+ } elsif (/^\s*(\S+) (\d+), hardware version (\S+), microcode version (\S+)/) {
+ $slot = $2;
+ $board{$slot} = $1;
+ $hwver{$slot} = $3;
+ $hwucode{$slot} = $4;
+ } elsif (/(Microcode .*)/) {
+ $ucode{$slot} = $1;
+ } elsif (/(software loaded .*)/) {
+ $ucode{$slot} = $1;
+ } elsif (/(\d+) Kbytes of main memory, (\d+) Kbytes cache memory/) {
+ $hwmemd{$slot} = $1;
+ $hwmemc{$slot} = $2;
+ } elsif (/byte buffers/) {
+ chop;
+ s/^\s*//;
+ $hwbuf{$slot} = $_;
+ } elsif (/Interface (\d+) - (\S+ \S+),/) {
+ $interface = $1;
+ ProcessHistory("HW","","","!\n!Int $interface: in slot $slot, named $2\n");
+ return;
+ } elsif (/(\d+) buffer RX queue threshold, (\d+) buffer TX queue limit, buffer size (\d+)/) {
+ ProcessHistory("HW","","","!Int $interface: rxq $1, txq $2, bufsize $3\n");
+ return;
+ }
+ return;
+}
+
+# This routine parses "show diagbus"
+# This will create arrarys for hw info.
+sub ShowDiagbus {
+ # Skip if this is not a 7000, 70[01]0, or 7500.
+ print STDERR " In ShowDiagbus: $_" if ($debug);
+ return if ($type !~ /^7[05]/);
+ if (/^\s*Slot (\d+):/i) {
+ $slot = $1;
+ return;
+ } elsif (/^\s*Slot (\d+) \(virtual\):/i) {
+ $slot = $1;
+ return;
+ } elsif (/^\s*(.*Processor.*|.*controller|.*Chassis Interface), HW rev (\S+), board revision (\S+)/i) {
+ $board = $1;
+ $hwver = $2;
+ $boardrev = $3;
+ if ($board =~ /Processor/) {
+ if ($board =~ /7000 Route\/Switch/) {
+ $board = "RSP7000";
+ } elsif ($board =~ /Route\/Switch Processor (\d)/) {
+ $board = "RSP$1";
+ } elsif ($board =~ /Route/) {
+ $board = "RP";
+ } elsif ($board =~ /Silicon Switch/) {
+ $board = "SSP";
+ } elsif ($board =~ /Switch/) {
+ $board = "SP";
+ $board = "SSP $sspmem" if $ssp;
+ } elsif ($board =~ /ATM/) {
+ $board = "AIP";
+ }
+ } elsif ($board =~ /(.*) controller/i) {
+ $board = $1;
+ }
+ # hwucode{$slot} defined in ShowContCbus
+ if (defined $hwucode{$slot}) {
+ ProcessHistory("SLOT","","","!\n!Slot $slot/$board: hvers $hwver rev $boardrev ucode $hwucode{$slot}\n");
+ } else {
+ ProcessHistory("SLOT","","","!\n!Slot $slot/$board: hvers $hwver rev $boardrev\n");
+ }
+ # These are also from the ShowContCbus
+ ProcessHistory("SLOT","","","!Slot $slot/$board: $ucode{$slot}\n") if (defined $ucode{$slot});
+ ProcessHistory("SLOT","","","!Slot $slot/$board: memd $hwmemd{$slot}, cache $hwmemc{$slot}\n")
+ if ((defined $hwmemd{$slot}) && (defined $hwmemc{$slot}));
+ ProcessHistory("SLOT","","","!Slot $slot/$board: $hwbuf{$slot}\n") if (defined $hwbuf{$slot});
+ return;
+ }
+ /Serial number: (\S+)\s*Part number: (\S+)/ &&
+ ProcessHistory("SLOT","","","!Slot $slot/$board: part $2, serial $1\n") && return;
+ /^\s*Controller Memory Size: (.*)$/ &&
+ ProcessHistory("SLOT","","","!Slot $slot/$board: $1\n") &&
+ return;
+ if (/PA Bay (\d) Information/) {
+ $pano = $1;
+ if ("PA" =~ /$board/) {
+ ($s,$c) = split(/\//,$board);
+ $board = "$s/$c/PA $pano";
+ } else {
+ $board =~ s/\/PA \d//;
+ $board = "$board/PA $pano";
+ }
+ return;
+ }
+ /\s+(.*) PA, (\d) ports?, (\S+)/ &&
+ ProcessHistory("SLOT","","","!Slot $slot/$board: type $3, $2 ports\n") && return;
+ /\s+(.*) PA( \(\S+\))?, (\d) ports?/ &&
+ ProcessHistory("SLOT","","","!Slot $slot/$board: type $1$2, $3 ports\n") && return;
+ /^\s*HW rev (\S+), Board revision (\S+)/ &&
+ ProcessHistory("SLOT","","","!Slot $slot/$board: hvers $1 rev $2\n") && return;
+ /Serial number: (\S+)\s*Part number: (\S+)/ &&
+ ProcessHistory("SLOT","","","!Slot $slot/$board: part $2, serial $1\n") && return;
+ return;
+}
+
+# This routine parses "show diags" for the gsr, 7200, 3600
+# This will create arrarys for hw info.
+sub ShowDiags {
+ # Skip if this is not a 12000.
+ print STDERR " In ShowDiags: $_" if ($debug);
+ return if ($type !~ /^(1200|720|36.0)/);
+ /^$/ && return;
+ if (!defined($showdiags)) {$showdiags=1; ProcessHistory("SLOT","","","!\n");}
+ s/Port Packet Over SONET/POS/;
+ if (/^\s*SLOT (\d+)\s+\(.*\): (.*)/) {
+ $slot = $1;
+ ProcessHistory("SLOT","","","!Slot $slot: $2\n");
+ $board = "RP" if (/Route Processor/);
+ $board = "CLK" if (/Clock Scheduler Card/);
+ return;
+ }
+ if (/^\s+PCA:\s+(.*)/){
+ local($part) = $1;
+ $_ = <INPUT>;
+ /^\s+HW version (\S+)\s+S\/N (\S+)/ &&
+ ProcessHistory("SLOT","","","!Slot $slot/PCA: part $part, serial $2\n") &&
+ ProcessHistory("SLOT","","","!Slot $slot/PCA: hvers $1\n");
+ return;
+ }
+
+ if (/^\s+MBUS: .*\)\s+(.*)/) {
+ local($tmp) = "!Slot $slot/MBUS: part $1";
+ $_ = <INPUT>;
+ /^\s+HW version (\S+)\s+S\/N (\S+)/ &&
+ ProcessHistory("SLOT","","","$tmp, serial $2\n") &&
+ ProcessHistory("SLOT","","","!Slot $slot/MBUS: hvers $1\n");
+ return;
+ }
+ if (/^\s+MBUS Agent Software version (.*)/) {
+ local($sw) = $1;
+ local($tail) = "!\n" if ($board =~ /(CLK|RP)/);
+ ProcessHistory("SLOT","","","!Slot $slot/MBUS: software $sw\n$tail");
+ return;
+ }
+ if (/^\s+DRAM size: (\d+)/) {
+ local($dram) = $1 / 1048576;
+ $_ = <INPUT>;
+ /^\s+FrFab SDRAM size: (\d+)/ &&
+ ProcessHistory("SLOT","","","!Slot $slot/MBUS: $dram Mbytes DRAM, "
+ . $1 / 1024 . " Kbytes SDRAM\n!\n");
+ return;
+ }
+ # 7200 and 3600 stuff
+ if (/^(Slot) (\d+):/ || /^\s+(WIC) Slot (\d):/) {
+ if ($1 eq "WIC") {
+ $WIC = "/$2";
+ } else {
+ $slot = $2;
+ undef($WIC);
+ }
+ $_ = <INPUT>; tr/\015//d;
+ # clean up hideous 7200 format to look more like 7500 output
+ s/Fast-ethernet on C7200 I\/O card/FE-IO/;
+ s/ with MII or RJ45/-TX/;
+ s/Fast-ethernet /100Base/; s/[)(]//g;
+
+ /\s+(.*)\s+port adapter?,\s+(\d+)\s+/ &&
+ ProcessHistory("SLOT","","","!Slot $slot: type $1, $2 ports\n");
+ /\s+(.*)\s+daughter card(.*)$/ &&
+ ProcessHistory("SLOT","","","!Slot $slot$WIC: type $1$2\n");
+ /\s+(FT1)$/ &&
+ ProcessHistory("SLOT","","","!Slot $slot$WIC: type $1\n");
+ return;
+ }
+ /revision\s+(\S+).*revision\s+(\S+)/ &&
+ ProcessHistory("SLOT","","","!Slot $slot$WIC: hvers $1 rev $2\n") && return;
+ /number\s+(\S+)\s+Part number\s+(\S+)/ &&
+ ProcessHistory("SLOT","","","!Slot $slot$WIC: part $2, serial $1\n!\n") && return;
+ return;
+}
+
+# This routine parses "show c7200" for the 7200
+# This will create arrarys for hw info.
+sub ShowC7200 {
+ # Skip if this is not a 7200.
+ print STDERR " In ShowC7200: $_" if ($debug);
+ return if ($type !~ /^72/);
+ /^$/ && return;
+ if (/C7200 Midplane EEPROM:/) {
+ $_ = <INPUT>;
+ /revision\s+(\S+).*revision\s+(\S+)/;
+ ProcessHistory("SLOT","","","!Slot Midplane: hvers $1 rev $2\n");
+ $_ = <INPUT>;
+ /number\s+(\S+)\s+Part number\s+(\S+)/;
+ ProcessHistory("SLOT","","","!Slot Midplane: part $2, serial $1\n!\n");
+ return;
+ }
+ if (/C7200 CPU EEPROM:/) {
+ $_ = <INPUT>;
+ /revision\s+(\S+).*revision\s+(\S+)/ &&
+ ProcessHistory("SLOT","","","!Slot CPU: hvers $1 rev $2\n");
+ $_ = <INPUT>;
+ /number\s+(\S+)\s+Part number\s+(\S+)/ &&
+ ProcessHistory("SLOT","","","!Slot CPU: part $2, serial $1\n!\n");
+ return;
+ }
+ return;
+}
+
+# This routine processes a "write term"
+sub WriteTerm {
+ print STDERR " In WriteTerm: $_" if ($debug);
+ /Non-Volatile memory is in use/ && return(-1); # NvRAM is locked
+ # skip the crap
+ if (/^(##+$|Building configuration...)/i) {
+ while (<INPUT>) {
+ next if (/^Current configuration:/i);
+ next if (/^([%!].*|\s*)$/);
+ next if (/^ip add.*ipv4:/); # band-aid for 3620 12.0S
+ last;
+ }
+ ProcessHistory("","","","!\nconfig-register $config_register\n");
+ tr/\015//d;
+ }
+ # Dog gone Cool matches to process the rest of the config
+ /^tftp-server flash / && return; # kill and tftp remains
+ /^ntp clock-period / && return; # kill ntp clock-period
+ /^ length / && return; # kill length on serial lines
+ /^ width / && return; # kill width on serial lines
+ /^enable password / &&
+ ProcessHistory("ENABLE","","","!enable password <removed>\n") &&
+ return;
+ /^(username .*) password \d *(\S)\s*(.*)/ &&
+ ProcessHistory("USER","","","$1 password <removed>\n") &&
+ return;
+ /^\s*password / &&
+ ProcessHistory("LINE-PASS","","","! password <removed>\n") &&
+ return;
+ /^\s*neighbor (\S*) password / &&
+ ProcessHistory("","","","! neighbor $1 password <removed>\n") &&
+ return;
+ /fair-queue individual-limit/ && return;
+ # filter out any RCS/CVS tags to avoid confusing local CVS storage
+ s/\$(Revision|Id):/ $1:/;
+ # order access-lists
+ /^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ &&
+ ProcessHistory("ACL $1 $2","ipsort","$3","$_") && return;
+ # order extended access-lists
+ /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+host\s+(\S+)/ &&
+ ProcessHistory("EACL $1 $2","ipsort","$3","$_") && return;
+ /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+(\d\S+)/ &&
+ ProcessHistory("EACL $1 $2","ipsort","$3","$_") && return;
+ /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+any/ &&
+ ProcessHistory("EACL $1 $2","ipsort","0.0.0.0","$_") && return;
+ /^ip prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\d\S+)(\/.*)$/ &&
+ ProcessHistory("PACL $1 $3","ipsort","$4","ip prefix-list $1 $3 $4$5\n")
+ && return;
+ # order logging statements
+ /^logging (\d+\.\d+\.\d+\.\d+)/ &&
+ ProcessHistory("LOGGING","ipsort","$1","$_") && return;
+ # order name-server statements
+ /^ip name-server (\d+\.\d+\.\d+\.\d+)/ &&
+ ProcessHistory("NAMESERVER","ipsort","$1","$_") && return;
+ # order snmp-server host statements
+ /^snmp-server host (\d+\.\d+\.\d+\.\d+)/ &&
+ ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_") && return;
+ /^snmp-server community / &&
+ ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && return;
+ # order tacacs server statements
+ /^tacacs-server host (\d+\.\d+\.\d+\.\d+)/ &&
+ ProcessHistory("TAC","ipsort","$1","$_") && return;
+ # order clns host statements
+ /^clns host \S+ (\S+)/ && ProcessHistory("CLNS","keysort","$1","$_") && return;
+ # order alias statements
+ /^alias / && ProcessHistory("ALIAS","keysort","$_","$_") && return;
+ # delete ntp auth password
+ /^(ntp authentication-key \d+ md5) / &&
+ ProcessHistory("","","","!$1 <removed>\n") && return;
+ # order ntp peers/servers
+ if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) {
+ $sortkey = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5);
+ ProcessHistory("NTP","keysort",$sortkey,"$_");
+ return;
+ }
+ # order ip host line statements
+ /^ip host line(\d+)/ &&
+ ProcessHistory("IPHOST","numsort","$1","$_") && return;
+ # order ip nat source static statements
+ /^ip nat (\S+) source static (\S+)/ &&
+ ProcessHistory("IP NAT $1","ipsort","$2","$_") && return;
+ # order atm map-list statements
+ /^\s+ip\s+(\d+\.\d+\.\d+\.\d+)\s+atm-vc/ &&
+ ProcessHistory("ATM map-list","ipsort","$1","$_") && return;
+ # order ip rcmd lines
+ /^ip rcmd/ && ProcessHistory("RCMD","keysort","$_","$_") && return;
+ ProcessHistory("","","","$_");
+ # end of config
+ if (/^end$/) {
+ $found_end = 1;
+ return "FlailHelplessly";
+ }
+ return;
+}
+
+# dummy function
+sub DoNothing {print STDOUT;}
+
+# Main subroutine that splits up the work
+# All Subs return the name of the next function to use.
+# If the sub returns a new funtion name, that name will be used
+# else the main loop keeps using the current function
+sub FlailHelplessly {
+ print STDERR "Flailing: $_" if ($debug);
+ print STDOUT "Flailing: $_" if ($log);
+ /#(show version)$/ && delete($commands{$1}) && return("ShowVersion");
+ /#(show env all)$/ && delete($commands{$1}) && return("ShowEnv");
+ /#(show gsr chassis)$/ && delete($commands{$1}) && return("ShowGSR");
+ /#(show boot.*)$/ && delete($commands{$1}) && return("ShowBoot");
+ /#(show flash)$/ && delete($commands{$1}) &&
+ (ProcessHistory("FLASH","","","!\n"),return("ShowFlash"));
+ /#(dir \/all bootflash\:)$/ && delete($commands{$1}) &&
+ (ProcessHistory("FLASH","","","!\n"), return("DirBootflash"));
+ /#(dir \/all slot0\:)$/ && delete($commands{$1}) &&
+ (ProcessHistory("FLASH","","","!\n"),return("DirSlot0"));
+ /#(dir \/all slot1\:)$/ && delete($commands{$1}) &&
+ (ProcessHistory("FLASH","","","!\n"),return("DirSlot1"));
+ # These three generate a list of the hw.
+ # There are a few variable created in ShowContCbus
+ # That are printed out in ShowDiagbus.
+ /#(show controllers cbus)$/ && delete($commands{$1}) && return("ShowContCbus");
+ /#(show controllers)$/ && delete($commands{$1}) && return("ShowContAll");
+ /#(show diagbus)$/ && delete($commands{$1}) && return("ShowDiagbus");
+ /#(show diag)$/ && delete($commands{$1}) && return("ShowDiags");
+ /#(show c7200)$/ && delete($commands{$1}) && return("ShowC7200");
+ /#(write term)$/ && delete($commands{$1}) && return("WriteTerm");
+ return "FlailHelplessly";
+}
+
+# Main
+@commands=("show version","show env all","show gsr chassis",
+ "show boot","show bootvar","show flash","dir /all bootflash:",
+ "dir /all slot0:", "dir /all slot1:","show controllers",
+ "show controllers cbus", "show diagbus","show diag","show c7200",
+ "write term");
+
+foreach $c (@commands) { $commands{$c} = 1; }
+$cisco_cmds=join(";",@commands);
+$cmds_regexp=join("|",@commands);
+$func = FlailHelplessly;
+
+open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
+# make OUTPUT unbuffered
+select(OUTPUT); $| = 1;
+
+if ($file) {
+ print STDERR "opening file $host\n" if ($debug);
+ print STDOUT "opening file $host\n" if ($log);
+ open(INPUT,"<$host") || die "open failed for $host: $!\n";
+} else {
+ print STDERR "executing clogin -t $timeo -c\"$cisco_cmds\" $host\n" if ($debug);
+ print STDOUT "executing clogin -t $timeo -c\"$cisco_cmds\" $host\n" if ($log);
+ open(INPUT,"clogin -t $timeo -c\"$cisco_cmds\" $host </dev/null |") ||
+ die "clogin failed for $host: $!\n";
+# open(INPUT,"-|") || exec("clogin","-c\"$cisco_cmds\"",$host);
+}
+
+ProcessHistory("COMMENTS","keysort","B0","!\n");
+ProcessHistory("COMMENTS","keysort","F0","!\n");
+ProcessHistory("COMMENTS","keysort","G0","!\n");
+while(<INPUT>) {
+ tr/\015//d;
+ if (/\#exit$/) {
+ $clean_run=1;
+ last;
+ }
+ if (/^Error:/) {
+ print STDOUT ("$host clogin error: $_");
+ print STDERR ("$host clogin error: $_") if ($debug);
+ $clean_run=0;
+ last;
+ }
+ if (/#\s*($cmds_regexp)/) {
+ $func = FlailHelplessly;
+ print STDERR ("HIT COMMAND:$_") if ($debug);
+ } else {
+ $rval=eval $func;
+ if ($rval == -1) {
+ $clean_run = 0;
+ last;
+ }
+ $func=$rval if ($rval);
+ }
+}
+print STDOUT "Done $logincmd: $_\n" if ($log);
+# Flush History
+ProcessHistory("","","","");
+# Cleanup
+close(INPUT);
+close(OUTPUT);
+
+# check for completeness
+if (scalar(%commands) || !$clean_run || !$found_end) {
+ if (scalar(%commands)) {
+ print STDOUT "missed cmd(s): $commands\n";
+ print STDERR "missed cmd(s): $commands[0]\n" if ($debug);
+ }
+ if (!$clean_run || !$found_end) {
+ print STDOUT "End of run not found - removing $host.new\n";
+ print STDERR "End of run not found - removing $host.new\n" if ($debug);
+ system("/usr/bin/tail -1 $host.new");
+ }
+ unlink "$host.new";
+}
diff --git a/bin/rancid-fe b/bin/rancid-fe
new file mode 100755
index 0000000..e3dc94e
--- /dev/null
+++ b/bin/rancid-fe
@@ -0,0 +1,33 @@
+#!/usr/local/bin/perl
+##
+##
+## Copyright (C) 1997 by Henry Kilmer.
+## All rights reserved.
+##
+## This software may be freely copied, modified and redistributed without
+## fee for non-commerical purposes provided that this copyright notice is
+## preserved intact on all copies and modified copies.
+##
+## 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.
+##
+##
+#
+# rancid-FE - front-end to rancid/jrancid for use with par.
+#
+# usage: rancid-fe <router>:<vendor>
+#
+
+($router, $vendor) = split('\:', $ARGV[0]);
+
+if ($vendor =~ /^cisco$/i) {
+ exec('rancid', $router);
+} elsif ($vendor =~ /^juniper$/i) {
+ exec('jrancid', $router);
+}
+
+printf(STDERR "unknown router manufacturer for $router: $vendor\n");
+exit(-1);
diff --git a/bin/rename b/bin/rename
new file mode 100755
index 0000000..8883355
--- /dev/null
+++ b/bin/rename
@@ -0,0 +1,113 @@
+#!/usr/local/bin/perl
+'di';
+'ig00';
+#
+# Revision 3.0.1.2 90/08/09 03:17:57 lwall
+# patch19: added man page for relink and rename
+#
+
+if ($ARGV[0] eq '-i') {
+ shift;
+ if (open(TTYIN, "</dev/tty") && open(TTYOUT,">/dev/tty")) {
+ $inspect++;
+ select((select(TTYOUT),$|=1)[0]);
+ }
+}
+($op = shift) || die "Usage: rename [-i] perlexpr [filenames]\n";
+if (!@ARGV) {
+ @ARGV = <STDIN>;
+ chop(@ARGV);
+}
+for (@ARGV) {
+ unless (-e) {
+ print STDERR "$0: $_: $!\n";
+ $status = 1;
+ next;
+ }
+ $was = $_;
+ eval $op;
+ die $@ if $@;
+ if ($was ne $_) {
+ if ($inspect && -e) {
+ print TTYOUT "remove $_? ";
+ next unless <TTYIN> =~ /^y/i;
+ }
+ unless (rename($was, $_)) {
+ print STDERR "$0: can't rename $was to $_: $!\n";
+ $status = 1;
+ }
+ }
+}
+exit $status;
+##############################################################################
+__END__
+ # These next few lines are legal in both Perl and nroff.
+
+.00; # finish .ig
+
+'di \" finish diversion--previous line must be blank
+.nr nl 0-1 \" fake up transition to first page again
+.nr % 0 \" start at page 1
+';<<'.ex'; #__END__ ############# From here on it's a standard manual page ############
+.TH RENAME 1 "July 30, 1990"
+.AT 3
+.SH NAME
+rename \- renames multiple files
+.SH SYNOPSIS
+.B rename [-i] perlexpr [files]
+.SH DESCRIPTION
+.I Rename
+renames the filenames supplied according to the rule specified as the
+first argument.
+The argument is a Perl expression which is expected to modify the $_
+string in Perl for at least some of the filenames specified.
+If a given filename is not modified by the expression, it will not be
+renamed.
+If no filenames are given on the command line, filenames will be read
+via standard input.
+.PP
+The
+.B \-i
+flag will prompt to remove the old file first if it exists. This
+flag will be ignored if there is no tty.
+.PP
+For example, to rename all files matching *.bak to strip the extension,
+you might say
+.nf
+
+ rename 's/\e.bak$//' *.bak
+
+.fi
+To translate uppercase names to lower, you'd use
+.nf
+
+ rename 'y/A-Z/a-z/' *
+
+.fi
+To do the same thing but leave Makefiles unharmed:
+.nf
+
+ rename 'y/A-Z/a-z/ unless /^Make/' *
+
+.fi
+To rename all the *.f files to *.BAD, you'd use
+.nf
+
+ rename 's/\e.f$/.BAD/' *.f
+
+.SH ENVIRONMENT
+.fi
+No environment variables are used.
+.SH FILES
+.SH AUTHOR
+Larry Wall
+.SH "SEE ALSO"
+mv(1)
+.br
+perl(1)
+.SH DIAGNOSTICS
+If you give an invalid Perl expression you'll get a syntax error.
+.SH BUGS
+.I Rename
+does not check for the existence of target filenames, so use with care.
+.ex
diff --git a/bin/run-me b/bin/run-me
new file mode 100755
index 0000000..b17d850
--- /dev/null
+++ b/bin/run-me
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+ENVFILE="`dirname $0`/env"
+
+. $ENVFILE
+
+if [ $# -lt 1 ]; then
+ DOME="$LIST_OF_GROUPS"
+else
+ DOME="$*"
+fi
+
+for GROUP in $DOME
+do
+
+ LOCKFILE=/tmp/.$GROUP.run.lock
+
+ (
+ echo starting: `date`
+ echo
+
+ if [ -f $LOCKFILE ]
+ then
+ echo hourly cisco diffs failed: $LOCKFILE exists
+ /bin/ls -l $LOCKFILE
+ else
+ /usr/bin/touch $LOCKFILE
+ control_rancid $GROUP
+ /bin/rm -f $LOCKFILE
+ fi
+
+ echo
+ echo ending: `date`
+ ) >$BASEDIR/logs/$GROUP.`date +%Y%m%d.%H%M%S` 2>&1
+done