Trac Hacks for Managing Multiple Projects
2007.11.14 21:40Since Trac does not have true multi-project support, I’ve thrown together some tricks to manage multiple instances for my personal projects.
Directory Structure
I created a “Trac Home” where I keep all of my Trac files.
$TRAC_HOME/
etc/
(scripts and notes)
sites/
(Trac project dirs)
static/
(images used in Trac project sites)
templates/
(common templates for all Trac projects)
Database
I wrote a script to create a database for a new Trac project. I create the databases with the naming convention trac_${project}.
trac_db_user='trac'
trac_db_passwd='(your_passwd_goes_here)'
exec_sql() {
if [ $# -ne 1 ]; then
echo "ERROR -- exec_sql() expected arguments: <sql>. received: '$@'"
return 1
fi
sql=$1
echo "executing sql '$sql'"
mysql -u root -p -e "$sql" mysql
}
if [ $# != 1 ]; then
echo "ERROR -- expected arguments: <project_name>"
exit 1
fi
project=$1
db=trac_$project
db_sql="drop database if exists $db; create database $db default character set utf8 collate utf8_general_ci;"
user_sql="grant all privileges on $db.* to '$trac_db_user'@'localhost' identified by '$trac_db_passwd' with grant option;"
exec_sql "$db_sql $user_sql"
Common Header
What I originally wrote here is now out of date. Trac’s template language and mechanism for sharing templates across instances changed in version 0.11.
Read this.
What’s Left?
I’d also like an easy way to keep priorities, permissions, and custom reports in sync across instances, so I can use the same terminology for all projects.
I usually delete all severities and let the priority dictate the hierarchy of tasks. I also sometimes simplify the priorities to just high, normal, or low.