diff options
Diffstat (limited to 'bin/rancid-cvs.in')
-rw-r--r-- | bin/rancid-cvs.in | 66 |
1 files changed, 55 insertions, 11 deletions
diff --git a/bin/rancid-cvs.in b/bin/rancid-cvs.in index 22d5fd2..24d555a 100644 --- a/bin/rancid-cvs.in +++ b/bin/rancid-cvs.in @@ -1,8 +1,9 @@ #! /bin/sh ## -## $Id: rancid-cvs.in,v 1.16 2004/01/11 03:49:13 heas Exp $ +## $Id: rancid-cvs.in,v 1.19 2006/10/05 04:27:43 heas Exp $ ## -## Copyright (C) 1997-2004 by Terrapin Communications, Inc. +## @PACKAGE@ @VERSION@ +## Copyright (C) 1997-2006 by Terrapin Communications, Inc. ## All rights reserved. ## ## This software may be freely copied, modified and redistributed @@ -20,7 +21,7 @@ ## # # Create all of the misc files & dirs needed for each group and import them -# into CVS. +# into CVS or Subversion. # # rancid-cvs # @@ -28,6 +29,32 @@ # Read in the environment ENVFILE="@sysconfdir@/rancid.conf" +# print a usage message to stderr +pr_usage() { + echo "usage: $0 [-V] [group [group ...]]" >&2; +} + +# command-line options +# -V print version string +if [ $# -ge 1 ] ; then + while [ 1 ] ; do + case $1 in + -V) + echo "@PACKAGE@ @VERSION@" + exit 0 + ;; + -*) + echo "unknown option: $1" >&2 + pr_usage + exit 1 + ;; + *) + break; + ;; + esac + done +fi + . $ENVFILE # Base dir @@ -38,9 +65,20 @@ fi cd $BASEDIR +# RCS system +RCSSYS=${RCSSYS:=cvs}; +if [ $RCSSYS != "cvs" -a $RCSSYS != "svn" ] ; then + echo "$RCSSYS is not a valid value for RCSSYS." + exit 1 +fi + # Top level CVS stuff if [ ! -d $CVSROOT ]; then - cvs init + if [ $RCSSYS = cvs ]; then + cvs -d $CVSROOT init + else + svnadmin create $CVSROOT + fi fi # Log dir @@ -65,15 +103,21 @@ do if [ ! -d $DIR ]; then mkdir -p $DIR cd $DIR - cvs import -m "$GROUP" $GROUP new rancid - cd $BASEDIR - cvs co $GROUP + if [ $RCSSYS = cvs ]; then + cvs import -m "$GROUP" $GROUP new rancid + cd $BASEDIR + cvs checkout $GROUP + else + svn import -m "$GROUP" . file://$CVSROOT/$GROUP + cd $BASEDIR + svn checkout file://$CVSROOT/$GROUP $GROUP + fi fi cd $DIR if [ ! -d configs ]; then mkdir configs - cvs add configs - cvs commit -m 'new' configs + $RCSSYS add configs + $RCSSYS commit -m 'new' configs fi # main files @@ -88,7 +132,7 @@ do fi if [ ! -f router.db ]; then touch router.db - cvs add router.db - cvs commit -m 'new' router.db + $RCSSYS add router.db + $RCSSYS commit -m 'new' router.db fi done |