summaryrefslogtreecommitdiffstats
path: root/bin/rancid-cvs.in
diff options
context:
space:
mode:
authorJeffrey C. Ollie <jeff@ocjtech.us>2007-03-29 09:44:10 -0500
committerJeffrey C. Ollie <jeff@ocjtech.us>2008-02-13 14:50:29 -0600
commita7804ee1e93db466896e57683c44a3cd81c4290b (patch)
tree6893ba33fff9a6fb3fa62afa9d15155286ab56c8 /bin/rancid-cvs.in
parent1e2093ce37e6905b9a4f34c153949fe523866c07 (diff)
downloadrancid-a7804ee1e93db466896e57683c44a3cd81c4290b.tar.gz
rancid-a7804ee1e93db466896e57683c44a3cd81c4290b.tar.xz
rancid-a7804ee1e93db466896e57683c44a3cd81c4290b.zip
More work on git.
Diffstat (limited to 'bin/rancid-cvs.in')
-rw-r--r--bin/rancid-cvs.in116
1 files changed, 87 insertions, 29 deletions
diff --git a/bin/rancid-cvs.in b/bin/rancid-cvs.in
index 3943348..3891d98 100644
--- a/bin/rancid-cvs.in
+++ b/bin/rancid-cvs.in
@@ -87,21 +87,44 @@ cd $BASEDIR
# RCS system
RCSSYS=${RCSSYS:=cvs};
-if [ $RCSSYS != "cvs" -a $RCSSYS != "svn" -a $RCSSYS != "git" ] ; then
- echo "$RCSSYS is not a valid value for RCSSYS."
- exit 1
-fi
+case $RCSSYS in
+ cvs | svn )
+ # we're good
+ ;;
+ git )
+ # force $CVSROOT
+ CVSROOT=$BASEDIR/.git
+ ;;
+ * )
+ echo "$RCSSYS is not a valid value for RCSSYS."
+ exit 1
+ ;;
+esac
# Top level CVS stuff
if [ ! -d $CVSROOT ]; then
- if [ $RCSSYS = cvs ]; then
- cvs -d $CVSROOT init
- elif [ $RCSSYS = svn ]; then
- svnadmin create $CVSROOT @SVN_FSTYPE@
- else
- # git does not use $CVSROOT, instead configs are stored in $BASEDIR
- git init
- echo "logs" >> .gitignore
+ case $RCSSYS in
+ cvs )
+ cvs -d $CVSROOT init
+ ;;
+ svn )
+ svnadmin create $CVSROOT @SVN_FSTYPE@
+ ;;
+ git )
+ # git does not use $CVSROOT, instead configs are stored in $BASEDIR
+ (
+ flock -x 200
+ git init
+ rm -f .gitignore
+ echo "/logs" >> .gitignore
+ echo "/.lockfile" >> .gitignore
+ echo "*~" >> .gitignore
+ echo ".#*" >> .gitignore
+ echo ".cvsignore" >> .gitignore
+ echo "*.new" >> .gitignore
+ git add .gitignore
+ git commit -m "Initializing repository."
+ ) 200>$BASEDIR/.lockfile
fi
fi
@@ -127,23 +150,48 @@ do
if [ ! -d $DIR ]; then
mkdir -p $DIR
cd $DIR
- if [ $RCSSYS = cvs ]; then
- cvs import -m "$GROUP" $GROUP new rancid
- cd $BASEDIR
- cvs checkout $GROUP
- elif [ $RCSSYS = svn ]; then
- svn import -m "$GROUP" . file://$CVSROOT/$GROUP
- cd $BASEDIR
- svn checkout file://$CVSROOT/$GROUP $GROUP
- fi
+ case $RCSSYS in
+ cvs )
+ cvs import -m "$GROUP" $GROUP new rancid
+ cd $BASEDIR
+ cvs checkout $GROUP
+ ;;
+ svn )
+ svn import -m "$GROUP" . file://$CVSROOT/$GROUP
+ cd $BASEDIR
+ svn checkout file://$CVSROOT/$GROUP $GROUP
+ ;;
+ git )
+ cd $BASEDIR
+ echo "$GROUP/routers.all" >> .gitignore
+ echo "$GROUP/routers.down" >> .gitignore
+ echo "$GROUP/routers.up" >> .gitignore
+ echo "$GROUP/routers.mail" >> .gitignore
+ echo "$GROUP/routers.added" >> .gitignore
+ echo "$GROUP/routers.deleted" >> .gitignore
+ echo "$GROUP/routers.single" >> .gitignore
+ echo "$GROUP/routers.up.missed" >> .gitignore
+ echo "$GROUP/routers.failed" >> .gitignore
+ (
+ flock -x 200
+ git add .gitignore
+ git commit -m "Update .gitignore"
+ ) 200>$BASEDIR/.lockfile
+ ;;
+ esac
fi
cd $DIR
if [ ! -d configs ]; then
mkdir configs
- if [ $RCSSYS = cvs -o $RCSSYS = svn ]; then
- $RCSSYS add configs
- $RCSSYS commit -m 'new' configs
- fi
+ case $RCSSYS in
+ cvs | svn )
+ $RCSSYS add configs
+ $RCSSYS commit -m 'new' configs
+ ;;
+ git )
+ # nothing to be done here
+ ;;
+ esac
fi
# main files
@@ -158,9 +206,19 @@ do
fi
if [ ! -f router.db ]; then
touch router.db
- if [ $RCSSYS = cvs -o $RCSSYS = svn ]; then
- $RCSSYS add router.db
- fi
- $RCSSYS commit -m 'new' router.db
+ case $RCSSYS in
+ cvs | svn )
+ $RCSSYS add router.db
+ $RCSSYS commit -m 'new' router.db
+ ;;
+ git )
+ git add
+ (
+ flock -x 200
+ git add router.db
+ git commit -m "Initializing $GROUP"
+ ) 200>$BASEDIR/.lockfile
+ ;;
+ esac
fi
done