summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey C. Ollie <jeff@ocjtech.us>2007-03-29 12:12:07 -0500
committerJeffrey C. Ollie <jeff@ocjtech.us>2008-02-13 14:50:29 -0600
commit08f05f4dc4419e69567f2f2dc785a3450fe4ec0e (patch)
tree1886e0f2f58a49db47c7656d960674abdc7be1e3
parenta7804ee1e93db466896e57683c44a3cd81c4290b (diff)
downloadrancid-08f05f4dc4419e69567f2f2dc785a3450fe4ec0e.zip
rancid-08f05f4dc4419e69567f2f2dc785a3450fe4ec0e.tar.gz
rancid-08f05f4dc4419e69567f2f2dc785a3450fe4ec0e.tar.xz
Bug fixes and updates.
-rw-r--r--bin/control_rancid.in110
-rw-r--r--bin/rancid-cvs.in3
2 files changed, 52 insertions, 61 deletions
diff --git a/bin/control_rancid.in b/bin/control_rancid.in
index fc8ce14..3d894c2 100644
--- a/bin/control_rancid.in
+++ b/bin/control_rancid.in
@@ -112,7 +112,7 @@ unset noclobber > /dev/null 2>&1
# RCS system
RCSSYS=${RCSSYS:=cvs};
-if [ $RCSSYS != "cvs" -a $RCSSYS != "svn" -s $RCSSYS != "git" ] ; then
+if [ $RCSSYS != "cvs" -a $RCSSYS != "svn" -a $RCSSYS != "git" ] ; then
echo "$RCSSYS is not a valid value for RCSSYS."
exit 1
fi
@@ -176,20 +176,24 @@ then
cp .cvsignore .gitignore
fi
-### FIXME: if $RCSSYS = git do we need to do anything here?
-if [ $RCSSYS = cvs -o $RCSSYS = svn ]; then
- # do cvs update of router.db in case anyone has fiddled.
- $RCSSYS update router.db > $TMP 2>&1
- grep "^C" $TMP > /dev/null
- if [ $? -eq 0 ] ; then
- echo "There were $RCSSYS conflicts during update."
- echo ""
- cat $TMP
- rm -f $TMP
- exit 1
- fi
- rm -f $TMP
-fi
+case $RCSSYS in
+ cvs | svn )
+ # do cvs/svn update of router.db in case anyone has fiddled.
+ $RCSSYS update router.db > $TMP 2>&1
+ grep "^C" $TMP > /dev/null
+ if [ $? -eq 0 ] ; then
+ echo "There were $RCSSYS conflicts during update."
+ echo ""
+ cat $TMP
+ rm -f $TMP
+ exit 1
+ fi
+ rm -f $TMP
+ ;;
+ git )
+ # do nothing here (for now)
+ ;;
+esac
if [ ! -f $DIR/router.db ]
then
@@ -296,30 +300,24 @@ then
cd $DIR/configs
# Add new routers to the CVS structure.
- for router in `comm -13 $DIR/routers.up $DIR/routers.up.new`
+ for router in `comm -13 $DIR/routers.up $DIR/routers.up.new | cut -d: -f1`
do
- OFS=$IFS
- IFS=:
- set $router
- IFS=$OFS
- router=$1
-
- message='new router'
+ message="new router $router in group $GROUP"
touch $router
case $rcssys in
cvs )
cvs add -ko $router
- cvs commit -m $message $router
+ cvs commit -m "$message" $router
;;
svn )
svn add $router
- svn commit -m $message $router
+ svn commit -m "$message" $router
;;
git )
(
flock -x 200
git add $router
- git commit -m $message
+ git commit -m "$message"
) 200>$BASEDIR/.lockfile
;;
esac
@@ -406,16 +404,16 @@ cd $DIR
if [ ! -s routers.up ]
then
# commit router.db
- message="updates"
+ message="updates of group $GROUP"
case $RCSSYS in
cvs | svn )
- $RCSSYS commit -m $message router.db
+ $RCSSYS commit -m "$message" router.db
;;
git )
(
flock -x 200
git add router.db
- git commit -m $message
+ git commit -m "$message"
) 200>$BASEDIR/.lockfile
;;
esac
@@ -483,14 +481,8 @@ echo
# Make sure that no empty configs are accepted. Those that are non-empty
# are renamed from device_name.new -> device_name.
-for router in `cat $devlistfile`
+for router in `cat $devlistfile | cut -d: -f1`
do
- OFS=$IFS
- IFS=':'
- set $router
- IFS=$OFS
- router=$1;
-
if [ ! -s $router.new ]
then
rm -f $router.new
@@ -502,44 +494,44 @@ do
fi
done
-# This has been different for different machines...
-# Diff the directory and then checkin.
-trap 'rm -fr $TMP $TMP.diff $DIR/routers.single;' 1 2 15
-cd $DIR
-case $RCSSYS in
- cvs )
- cvs -f @DIFF_CMD@ -ko | sed -e '/^RCS file: /d' -e '/^--- /d' \
- -e '/^+++ /d' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff
- ;;
- svn )
- svn diff | sed -e '/^+++ /d' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff
- ;;
- git )
- git diff $GROUP/configs | sed -e '/^diff /d' -e '/^index /'d -e '/^+++ /d' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff
- ;;
-esac
-
if [ $alt_mailrcpt -eq 1 ] ; then
subject="router config diffs - courtesy of $mailrcpt"
else
subject="router config diffs"
fi
if [ "X$device" != "X" ] ; then
- message="updates - courtesy of $mailrcpt"
+ message="updates of group $GROUP - courtesy of $mailrcpt"
subject="$GROUP/$device $subject"
else
- message="updates"
+ message="updates of group $GROUP"
subject="$GROUP $subject"
fi
+
+# This has been different for different machines...
+# Diff the directory and then checkin.
+trap 'rm -fr $TMP $TMP.diff $DIR/routers.single;' 1 2 15
+cd $DIR
case $RCSSYS in
- cvs | svn )
- $RCSSYS commit -m $message
+ cvs )
+ cvs -f @DIFF_CMD@ -ko | sed -e '/^RCS file: /d' -e '/^--- /d' \
+ -e '/^+++ /d' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff
+ cvs commit -m "$message"
+ ;;
+ svn )
+ svn diff | sed -e '/^+++ /d' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff
+ svn commit -m "$message"
;;
git )
+ # with git we do things differently - first commit, then grab the diff
(
flock -x 200
- git add $GROUP/configs
- git commit -m $message
+ git add router.db
+ for router in `cat $devlistfile | cut -d: -f1`
+ do
+ git add configs/$router
+ done
+ git commit -m "$message"
+ git diff HEAD^ HEAD -- configs | sed -e '/^diff /d' -e '/^index /'d -e '/^new file /d' -e '/^--- /d' -e 's/^+++ b/+++ /' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff
) 200>$BASEDIR/.lockfile
;;
esac
diff --git a/bin/rancid-cvs.in b/bin/rancid-cvs.in
index 3891d98..506a277 100644
--- a/bin/rancid-cvs.in
+++ b/bin/rancid-cvs.in
@@ -125,7 +125,7 @@ if [ ! -d $CVSROOT ]; then
git add .gitignore
git commit -m "Initializing repository."
) 200>$BASEDIR/.lockfile
- fi
+ esac
fi
# Log dir
@@ -212,7 +212,6 @@ do
$RCSSYS commit -m 'new' router.db
;;
git )
- git add
(
flock -x 200
git add router.db