summaryrefslogtreecommitdiffstats
path: root/bin/control_rancid.in
diff options
context:
space:
mode:
authorJeffrey C. Ollie <jeff@ocjtech.us>2007-03-29 01:13:02 -0500
committerJeffrey C. Ollie <jeff@ocjtech.us>2008-02-13 14:47:59 -0600
commit1e2093ce37e6905b9a4f34c153949fe523866c07 (patch)
tree672448f52ada62fcbbe1d5020459890622abed74 /bin/control_rancid.in
parentb73f299e731fbddae095c0b5eff04717b6dce1af (diff)
downloadrancid-1e2093ce37e6905b9a4f34c153949fe523866c07.tar.gz
rancid-1e2093ce37e6905b9a4f34c153949fe523866c07.tar.xz
rancid-1e2093ce37e6905b9a4f34c153949fe523866c07.zip
First attempt at adding git support.
Diffstat (limited to 'bin/control_rancid.in')
-rw-r--r--bin/control_rancid.in55
1 files changed, 39 insertions, 16 deletions
diff --git a/bin/control_rancid.in b/bin/control_rancid.in
index 13b15f8..705c3e1 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" ] ; then
+if [ $RCSSYS != "cvs" -a $RCSSYS != "svn" -s $RCSSYS != "git" ] ; then
echo "$RCSSYS is not a valid value for RCSSYS."
exit 1
fi
@@ -168,17 +168,26 @@ EOF
fi
fi
-# 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
+# create a .cvsignore
+if [ ! -f .cvsignore ]
+then
+ rm -f .cvsignore
+ cp .cvsignore .gitignore
+fi
+
+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
- exit 1
fi
-rm -f $TMP
if [ ! -f $DIR/router.db ]
then
@@ -296,7 +305,7 @@ then
touch $router
if [ $RCSSYS = cvs ] ; then
cvs add -ko $router
- else
+ elif [ $RCSSYS = svn ]; then
svn add $router
fi
$RCSSYS commit -m 'new router' $router
@@ -326,8 +335,10 @@ cd $DIR/configs
for router in `cut -d: -f1 ../routers.up` ; do
if [ $RCSSYS = cvs ] ; then
cvs status $router | grep -i 'status: unknown' > /dev/null 2>&1
- else
+ elif [ $RCSSYS = cvs ]; then
svn status $router | grep '^?' > /dev/null 2>&1
+ else
+ true
fi
if [ $? -eq 0 ]; then
touch $router
@@ -345,7 +356,9 @@ for router in `find . \( -name \*.new -prune -o -name CVS -prune -o -name .svn -
grep -i "^$router:" ../router.db > /dev/null 2>&1
if [ $? -eq 1 ]; then
rm -f $router
- $RCSSYS delete $router
+ if [ $RCSSYS = cvs -o $RCSSYS = svn ]; then
+ $RCSSYS delete $router
+ fi
$RCSSYS commit -m 'deleted router' $router
echo "Deleted $router"
fi
@@ -447,8 +460,10 @@ cd $DIR
if [ $RCSSYS = "cvs" ] ; then
cvs -f @DIFF_CMD@ -ko | sed -e '/^RCS file: /d' -e '/^--- /d' \
-e '/^+++ /d' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff
-else
+elif [ $RCSSYS = "svn" ]; then
svn diff | sed -e '/^+++ /d' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff
+else
+ git diff $GROUP/configs | sed -e '/^diff /d' -e '/^index /'d -e '/^+++ /d' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff
fi
if [ $alt_mailrcpt -eq 1 ] ; then
@@ -457,10 +472,18 @@ else
subject="router config diffs"
fi
if [ "X$device" != "X" ] ; then
- $RCSSYS commit -m "updates - courtesy of $mailrcpt"
+ if [ $RCSSYS = cvs -o $RCSSYS = svn ]; then
+ $RCSSYS commit -m "updates - courtesy of $mailrcpt"
+ else
+ git commit -m "updates - courtesy of $mailrcpt" $GROUP/configs
+ fi
subject="$GROUP/$device $subject"
else
- $RCSSYS commit -m updates
+ if [ $RCSSYS = cvs -o $RCSSYS = svn ]; then
+ $RCSSYS commit -m "updates"
+ else
+ git commit -m "updates" $GROUP/configs
+ fi
subject="$GROUP $subject"
fi