Subversion repository creation shell script
Posted in dev-sys on October 26, 2006
I've updated my svn repository creation script, it now copies and imports the code.
Works for me, etc.
#!/bin/sh
# Darren Beale - siftware.co.uk # bealers@gmail.com
# Oct 06 # v0.2
# This simple script creates a folder structure # containing /trunk /tags and /branches. It then places the # contents of a folder specified by the user into the trunk, # creates a subversion repository and imports the code.
# Use as you see fit
## change me SVN_PASSWD_FILE="/etc/subversion/passwd" SVN_REALM="SIFTWARE" SVN_SERVER="shrek"
if [ `id -u` != 0 ]; then echo "You need to be root to run this script" exit 1; fi
echo echo "You now need to enter the FULL path to the source code that you will be importing." echo "After importing the folder will be renamed but otherwise untouched." echo "Note: that the *contents* of this folder will be placed into the trunk for the new project." echo echo -n "Path: " read SOURCE_PATH echo
if [ ! -d $SOURCE_PATH ]; then
echo "That directory does not exist, exiting..." exit 1; fi
echo -n "Please enter the name of the repository that you would like to create: "; read REPOSITORY_NAME
echo echo "Copying source code" cd /tmp mkdir $REPOSITORY_NAME cd $REPOSITORY_NAME mkdir trunk tags branches cd trunk cp -Rp $SOURCE_PATH/* .
echo echo "Renaming $SOURCE_PATH" mv $SOURCE_PATH $SOURCE_PATH.pre.svn
echo echo "Creating repository"
svnadmin create --fs-type fsfs /export/svn/$REPOSITORY_NAME
echo "[general] password-db = $SVN_PASSWD_FILE realm = $SVN_REALM"> /export/svn/$REPOSITORY_NAME/conf/svnserve.conf
cd /export/svn chown -R svn:svn $REPOSITORY_NAME find $REPOSITORY_NAME -type d -exec chmod 2770 {} ;
echo echo "Importing....." cd /tmp/$REPOSITORY_NAME /usr/bin/svn import . file:///export/svn/$REPOSITORY_NAME/
echo echo "Done." echo echo "You can Ctrl-D now, cd to your sandbox and checkout your project by typing:" echo "svn co svn://$SVN_SERVER/$REPOSITORY_NAME/trunk $REPOSITORY_NAME" echo