Bash Script For Subversion (Svn) Repository/Project Creation And User Management

By | October 14, 2009

Bash Script For Subversion (Svn) Repository/Project Creation And User Management

In an organization project revisions and sharing is mostly done through subversion or concurrent versions system. This repositories also act as backup solution.

Creating new projects, editing apache svn.conf, add new users and their passwords are time taking. Inorder to make it simple i have created a bash script.

Script will help to create new project, add new users and their password. The password’s are stored on a common file. Script use two switches “c” (svnmel c) to create new project and “p” (svnmel p) to add and update the users and their passwords.

If the svn project repository already exists, script skips the creation of new project. Change the svn source code directory path and the password file path values mention on the begin of the script.

vi /usr/local/bin/svnmel

#!/bin/bash -e ################################################################################################################################################################################ # SVNMEL is a script used to create new svn projects in the svn parent directory. Script will append # the project variable on apache svn.conf file and also help to create a new # user name and password for authentication. This makes the svn directory secure. Script can use to # create new svn projects (repositories), create new authentication and configure apache svn.conf. # Two switches used for the working on the script. They are "c" and "p". By using "c" new project can # create and using "p" # we can add new user and password to apache passwd file. # ---By Melbin Mathew # www.talk2melbin.com # email: support@talk2melbin.com ################################################################################################################################################################################# #Modify svn home directory and password file paths. svnhome="/SVN" apache="/etc/httpd/conf.d/svn.conf" passfile="/SVN/httpasswd" value=$1 echo "$value" if [ $value == c ] then ## echo "Enter The New Project" read project #echo "hi $project" #svnadmin create project and append the apache svn.conf if [ -d "$svnhome/$project" ] then echo "Project Already Exist" exit else echo -e "Greeting Creating New Project nAppending to Project to Apache svn.conf" svnadmin create "$svnhome/$project" echo -e "<Location /$project> nDAV svn nSVNPath $svnhome nAuthType Basic nAuthName "repo" nAuthUserFile $passfile nrequire valid-user n</Location>" >> $apache fi ##Password creation## echo "Enter User Name" read user if [ -f "$passfile" ] then echo "Appending to httpasswd file" htpasswd -m $passfile $user else echo "Creating New Httpasswd File" htpasswd -cm $passfile $user fi ## Repeat value httpasswd## #passrepeat=$1 #if [ "pass == $passrepeat" ] elif [ $value == p ] then echo "Adding New User Name & Password" echo "Enter User Name" read user #echo $passfile $user htpasswd -m $passfile $user else echo "Parameter Wrong" exit fi

Cheers!

Melbin Mathew

www.talk2melbin.com

Melbin Mathew

I am Melbin Mathew, Systems Engineer from Kerala, India. I live with my parents, daughter and my wonderful wife. I graduated in 2004 with a bachelor’s degree in Electronics and Hardware from Mahatma Gandhi University, Kottayam and completed certification in MCITP, RHCE, CCNA, VCP ...Read More
Category: Scripts

About Melbin Mathew

I am Melbin Mathew, Systems Engineer from Kerala, India. I live with my parents, daughter and my wonderful wife. I graduated in 2004 with a bachelor’s degree in Electronics and Hardware from Mahatma Gandhi University, Kottayam and completed certification in MCITP, RHCE, CCNA, VCP ...Read More

  • mohammad al-rawabdeh

    how i can write bash to list directory entries in the svn repository