Saturday, August 23, 2014

Script: create new SVN project, create branches and trunk folders, set permissions


Script for automatically creating a new SVN project, branches / trunk folders and setting file permissions.

Usage: $ ./repoCreate.sh svn-project-name

File (repoCreate.sh) contents:

#!/bin/bash

dirRepo="/svn-repos-location/$1"
dirCheckoutTmp="~/svn-new-project-tmp"

if [ -d "$dirRepo" ]; then
        echo "ERROR: Directory already exists: $dirRepo"
        exit
fi

echo "Creating repository folder"
svnadmin create $dirRepo

echo "Checking out, creating trunk/branches folders and first commit"
if [ -d "$dirCheckoutTmp" ]; then
        echo "Deleting directory $dirCheckoutTmp"
        rm -rf $dirCheckoutTmp
fi
svn co file://$dirRepo $dirCheckoutTmp
cd $dirCheckoutTmp
mkdir trunk
mkdir branches
mkdir tags
svn add *
svn ci -m "init deploy" *
rm -rf $dirCheckoutTmp

echo "Setting additional permissions"
chown -R user:group $dirRepo




No comments: