summaryrefslogtreecommitdiffstats
path: root/bin/control_rancid.in
diff options
context:
space:
mode:
authorTar Committer <tar@ocjtech.us>2002-05-02 23:08:06 +0000
committerTar Committer <tar@ocjtech.us>2002-05-02 23:08:06 +0000
commitafcac75e572bcdd3cf269b921b7e8324aa5ffd4c (patch)
treedfffbfceb4f15c22781a599d6352586c8b7ce582 /bin/control_rancid.in
parent9f2402b0d86333f5f7e9d50437036cd3124bde47 (diff)
downloadrancid-afcac75e572bcdd3cf269b921b7e8324aa5ffd4c.tar.gz
rancid-afcac75e572bcdd3cf269b921b7e8324aa5ffd4c.tar.xz
rancid-afcac75e572bcdd3cf269b921b7e8324aa5ffd4c.zip
Imported from rancid-2.2.1.tar.gz.rancid-2.2.1
Diffstat (limited to 'bin/control_rancid.in')
-rwxr-xr-xbin/control_rancid.in49
1 files changed, 43 insertions, 6 deletions
diff --git a/bin/control_rancid.in b/bin/control_rancid.in
index 6e13f7b..dc453a0 100755
--- a/bin/control_rancid.in
+++ b/bin/control_rancid.in
@@ -19,8 +19,15 @@
# control_rancid $GROUP
#
+# print a usage message to stderr
+pr_usage() {
+ echo "usage: $0 [-r device_name] [-m mail rcpt] [group [group ...]]" >&2;
+}
+
# command-line options
# -r <device name>
+# -m <mail recipients>
+alt_mailrcpt=0
if [ $# -ge 1 ] ; then
while [ 1 ] ; do
@@ -31,11 +38,27 @@ if [ $# -ge 1 ] ; then
device="$1"
shift
;;
+ -m)
+ shift
+ # next arg is the mail recipient
+ alt_mailrcpt=1
+ if [ -z "$mailrcpt" ] ; then
+ mailrcpt="$1"
+ else
+ mailrcpt="$mailrcpt,$1"
+ fi
+ shift
+ ;;
--)
shift; break;
;;
+ -h)
+ pr_usage
+ exit
+ ;;
-*)
echo "unknown option: $1" >&2
+ pr_usage
exit 1
;;
*)
@@ -45,9 +68,6 @@ if [ $# -ge 1 ] ; then
done
fi
-# Number of things par should run in parallel.
-PAR_COUNT=${PAR_COUNT:-5}
-
# Must specify a group on which to run rancid
if [ $# -lt 1 ]; then
echo 'must specify group'; exit 1
@@ -58,6 +78,12 @@ DIR=$BASEDIR/$GROUP
TMP=${TMPDIR:=/tmp}/rancid.$GROUP.$$
trap 'rm -fr $TMP;' 1 2 15
+# the receipient(s) of diffs
+mailrcpt=${mailrcpt:-"@MAILPLUS@$GROUP"}; export mailrcpt
+
+# Number of things par should run in parallel.
+PAR_COUNT=${PAR_COUNT:-5}
+
# Bail if we do not have the necessary info to run
if [ ! -d $DIR ]
then
@@ -298,13 +324,24 @@ cd $DIR
cvs -f @DIFF_CMD@ | sed -e '/^RCS file: /d' -e '/^--- /d' \
-e '/^+++ /d' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff
-cvs commit -m updates
+if [ $alt_mailrcpt -eq 1 ] ; then
+ subject="router config diffs - courtesy of $mailrcpt"
+else
+ subject="router config diffs"
+fi
+if [ "X$device" != "X" ] ; then
+ cvs commit -m "updates - courtesy of $mailrcpt"
+ subject="$GROUP/$device $subject"
+else
+ cvs commit -m updates
+ subject="$GROUP $subject"
+fi
# Mail out the diffs (if there are any).
if [ -s $TMP.diff ]; then
sendmail -t <<EMAIL
-To: @MAILPLUS@$GROUP
-Subject: $GROUP router config diffs
+To: $mailrcpt
+Subject: $subject
Precedence: bulk
`cat $TMP.diff`