Monday, December 22, 2008

My First Shell Script

Here's little script I wrote to setup a Subversion repository and a Trac project. This is my first shell script, and it doesn't include any error handling -- so don't hate.


#!/bin/bash

#***************************
# Initialize a new SVN repository and TRAC project
# Scott Wolff (scott.wolff@tuscan.ca)
# last edit: December 22, 2008
#***************************

# edit these paths for your own environment
SVN_PATH='/path/to/your/svn/folder/' #dont forget the trailing slash
TRAC_PATH='/path/to/your/trac/folder/' #again, with the trailing slash

# you should not need to edit below this comment

echo Enter Your Project Name
read PROJECT_NAME

REPOS_PATH=$SVN_PATH/$PROJECT_NAME
TRAC_PROJECT_PATH=$TRAC_PATH/$PROJECT_NAME

# create the SVN repository and change the permissions
sudo svnadmin create $REPOS_PATH
sudo chown -R www-data:www-data $REPOS_PATH

# create the TRAC project
sudo trac-admin $TRAC_PATH$PROJECT_NAME initenv $PROJECT_NAME 'sqlite:db/trac.db' 'svn' $REPOS_PATH '/usr/share/trac/templates'
sudo chown -R www-data:www-data $TRAC_PROJECT_PATH

No comments: