From 645e58bd66f33a6c3601438fd0950d85a82b7820 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Thu, 29 Mar 2007 01:13:02 -0500 Subject: First attempt at adding git support. --- bin/control_rancid.in | 55 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 16 deletions(-) (limited to 'bin/control_rancid.in') diff --git a/bin/control_rancid.in b/bin/control_rancid.in index 2e39068..34343e1 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 @@ -457,8 +470,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 @@ -467,10 +482,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 -- cgit