summaryrefslogtreecommitdiffstats
path: root/bin/rancid-run.in
diff options
context:
space:
mode:
authorJeffrey C. Ollie <jeff@ocjtech.us>2007-03-25 23:16:40 -0500
committerJeffrey C. Ollie <jeff@ocjtech.us>2007-03-25 23:16:40 -0500
commited56ea51bb811dcdabb00d036786b412fdbf4d36 (patch)
treee880bcf06d9e757c39ee0cae83713b3de885c6df /bin/rancid-run.in
parentad03c748e10fe5b8dbd95c3bcdbcc2c02e777e7b (diff)
parentac54243f382e817c08c1f895ccfdc05dcacdb044 (diff)
downloadrancid-2.3.2a7-usercmd.patch.tar.gz
rancid-2.3.2a7-usercmd.patch.tar.xz
rancid-2.3.2a7-usercmd.patch.zip
Update usercmd branch with latest vendor changes.rancid-2.3.2a7-usercmd.patch
Diffstat (limited to 'bin/rancid-run.in')
-rw-r--r--bin/rancid-run.in119
1 files changed, 69 insertions, 50 deletions
diff --git a/bin/rancid-run.in b/bin/rancid-run.in
index b59b026..42e387a 100644
--- a/bin/rancid-run.in
+++ b/bin/rancid-run.in
@@ -1,8 +1,9 @@
#! /bin/sh
##
-## $Id: rancid-run.in,v 1.28 2004/01/11 06:11:23 hank Exp $
+## $Id: rancid-run.in,v 1.35 2006/10/05 04:27:43 heas Exp $
##
-## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
+## @PACKAGE@ @VERSION@
+## Copyright (C) 1997-2006 by Terrapin Communications, Inc.
## All rights reserved.
##
## This software may be freely copied, modified and redistributed
@@ -23,10 +24,9 @@
# @sysconfdir@/rancid.conf or those specified on the command-line.
#
+# Default ENVFILE, overrideable with -f flag.
ENVFILE="@sysconfdir@/rancid.conf"
-. $ENVFILE
-
TMPDIR=${TMPDIR:=/tmp}; export TMPDIR
# control_rancid argv
@@ -34,19 +34,30 @@ CR_ARGV=""; export CR_ARGV
# print a usage message to stderr
pr_usage() {
- echo "usage: $0 [-r device_name] [-m mail rcpt] [group [group ...]]" >&2;
+ echo "usage: $0 [-V] [-f config_file] [-r device_name] [-m mail rcpt] [group [group ...]]" >&2;
}
# command-line options
+# -V
+# -f <config file name>
+# -m <mailto address>
# -r <device name>
if [ $# -ge 1 ] ; then
while [ 1 ] ; do
case $1 in
- -r)
+ -V)
+ echo "@PACKAGE@ @VERSION@"
+ exit 0
+ ;;
+ -f)
shift
- # next arg is the device name
- CR_ARGV="$CR_ARGV -r $1"; export CR_ARGV
+ # next arg is the alternate config file name
+ ENVFILE="$1"
+ if [ -z $ENVFILE ]; then
+ pr_usage
+ exit 1
+ fi
shift
;;
-m)
@@ -55,6 +66,12 @@ if [ $# -ge 1 ] ; then
CR_ARGV="$CR_ARGV -m $1"; export CR_ARGV
shift
;;
+ -r)
+ shift
+ # next arg is the device name
+ CR_ARGV="$CR_ARGV -r $1"; export CR_ARGV
+ shift
+ ;;
--)
shift; break;
;;
@@ -74,6 +91,9 @@ if [ $# -ge 1 ] ; then
done
fi
+. $ENVFILE
+
+
if [ $# -ge 1 ] ; then
LIST_OF_GROUPS="$*"; export LIST_OF_GROUPS
elif [ "$LIST_OF_GROUPS" = "" ] ; then
@@ -88,49 +108,48 @@ fi
for GROUP in $LIST_OF_GROUPS
do
- LOCKFILE=$TMPDIR/.$GROUP.run.lock
-
- (
- echo starting: `date`
- echo
-
- if [ -f $LOCKFILE ]
- then
- echo hourly config diffs failed: $LOCKFILE exists
- ls -l $LOCKFILE
-
- # Send email if the lock file is old.
- if [ "X$LOCKTIME" = "X" ] ; then
- LOCKTIME=4
- fi
- @PERLV@ -e "\$t = (stat(\"$LOCKFILE\"))[9]; print \"OLD\\n\" if (time() - \$t >= $LOCKTIME*60*60);" > $TMPDIR/.$GROUP.old
- if [ -s $TMPDIR/.$GROUP.old ]
- then
- (
- echo "To: @ADMINMAILPLUS@$GROUP"
- echo "Subject: rancid hung - $GROUP"
- echo "Precedence: bulk"
- echo ""
-
- cat <<END
+ LOCKFILE=$TMPDIR/.$GROUP.run.lock
+
+ (
+ echo starting: `date`
+ echo
+
+ if [ -f $LOCKFILE ]
+ then
+ echo hourly config diffs failed: $LOCKFILE exists
+ ls -l $LOCKFILE
+
+ # Send email if the lock file is old.
+ if [ "X$LOCKTIME" = "X" ] ; then
+ LOCKTIME=4
+ fi
+ @PERLV@ -e "\$t = (stat(\"$LOCKFILE\"))[9]; print \"OLD\\n\" if (time() - \$t >= $LOCKTIME*60*60);" > $TMPDIR/.$GROUP.old
+ if [ -s $TMPDIR/.$GROUP.old ]
+ then
+ (
+ echo "To: @ADMINMAILPLUS@${GROUP}${MAILDOMAIN}"
+ echo "Subject: rancid hung - $GROUP"
+ echo "Precedence: bulk"
+ echo ""
+
+ cat <<END
rancid $GROUP hung on `hostname`? Old lockfile still exists:
`ls -l $LOCKFILE`
END
- ) | sendmail -t
- fi
- rm -f $TMPDIR/.$GROUP.old
-
- else
- trap 'rm -fr $LOCKFILE;exit 1' 1 2 3 6 10 15
- touch $LOCKFILE
- if [ $? -eq 0 ] ; then
- control_rancid $CR_ARGV $GROUP
- rm -f $LOCKFILE
- fi
- trap '' 1 2 3 6 10 15
- fi
-
- echo
- echo ending: `date`
- ) >$LOGDIR/$GROUP.`date +%Y%m%d.%H%M%S` 2>&1
+ ) | sendmail -t
+ fi
+ rm -f $TMPDIR/.$GROUP.old
+ else
+ trap 'rm -fr $LOCKFILE;exit 1' 1 2 3 6 10 15
+ touch $LOCKFILE
+ if [ $? -eq 0 ] ; then
+ control_rancid $CR_ARGV $GROUP
+ rm -f $LOCKFILE
+ fi
+ trap '' 1 2 3 6 10 15
+ fi
+
+ echo
+ echo ending: `date`
+ ) >$LOGDIR/$GROUP.`date +%Y%m%d.%H%M%S` 2>&1
done