ipsure logo
Logo and Language
Login icon Language selection icon
Hello, guest
*NIX Active category menu left background Active category menu right background BACKUP Hands-On blog header image Right block of Hands-On blog header image Final menu block of Hands-On blog header image
Home page Hands-On Services IT Business Contact About References Terms of Use RSS


Trac and Subversion (SVN) on FreeBSD

Filed under: *NIX — Tags: , , , , , , — Sezgin Bayrak @ 13:57

Trac logoTrac was not our primary destination but it immediately became the significant part, following the installation of Subversion (SVN). Thereby this article arose and began to progress step by step last week when I received a request from one of my clients to erect a Subversion platform for their development team in order to manage the production flow for their brand new web application project. Need of wiki style documentation, direct synchronization within the document root and the extra web interface capabilities were their collateral prospects that have also been right behind the main idea. Both parties well knew that the name of the solution was Trac.

As I don’t prefer to play around with Apache and its base modules which serve a production candidate, I decided to go straight with the internal web daemons of both Trac and Subversion which I though that they would be more safer and easier way of accomplishing the tasks, particularly in terms of authentication and synchronization issues. Although it seems to be a piece of cake, you realize that you spend considerable amount of time to assemble the total solution, so I decided to prepare a Quick(est) Installation Guide for those who want to install and run the combination on FreeBSD (8.1-RELEASE) on the fly. Note that Trac and Subversion must reside on the same server.

Let’s get busy;


# cd /usr/ports/devel/subversion
# make install clean
# install -v -m 0755 -d /home/svn
# install -v -m 0755 -d /home/svn/repositories
# svnadmin create --fs-type fsfs /home/svn/repositories/myproject/
# cd /home/svn/repositories/myproject/
# mkdir branches tags trunk
# pw groupadd svn
# pw useradd -n svn -g svn -d /home/svn -s /bin/sh
# passwd svn
# chown -R svn:svn /home/svn/
# chmod -R 775 /home/svn/repositories
# vi /etc/rc.conf
svnserve_flags="-d --listen-port=3690 --listen-host"


Edit the svnserve.conf file;

# vi /home/svn/repositories/myproject/conf/svnserve.conf
anon-access = none
auth-access = write
password-db = /path/to/passwd
realm = My Project Repository


# vi /path/to/passwd
sezgin = xxxxxxxx
baha = yyyyyyyy



# cd /usr/ports/www/trac/
# make install clean
# cd /home
# mkdir trac
# chown -R svn:svn trac/
# trac-admin /home/trac/myproject initenv
Creating a new Trac environment at /home/trac/myproject

Trac will first ask a few questions about your environment
in order to initialize and prepare the project database.

 Please enter the name of your project.
 This name will be used in page titles and descriptions.

Project Name [My Project]> MyProject

 Please specify the connection string for the database to use.
 By default, a local SQLite database is created in the environment
 directory. It is also possible to use an already existing
 PostgreSQL database (check the Trac documentation for the exact
 connection string syntax).

Database connection string [sqlite:db/trac.db]>

Creating and Initializing Project
 Installing default wiki pages

Project environment for 'MyProject' created.

You may now configure the environment by editing the file:


If you'd like to take this new project environment for a test drive,
try running the Trac standalone web server `tracd`:

 tracd --port 8000 /home/trac/myproject

Then point your browser to http://localhost:8000/myproject.
There you can also browse the documentation for your installed
version of Trac, including information on further setup (such as
deploying Trac to a real web server).

The latest documentation can also always be found on the project


# chmod -R 775 /home/trac/myproject

Configure trac.ini, leave “repository_sync_per_request” parameter empty!

# vi /home/trac/myproject/conf/trac.ini
default_language = en
repository_sync_per_request =

tracopt.ticket.commit_updater.* = enabled

myproject.dir = /home/svn/repositories/myproject
myproject.description = MyProject main repository
myproject.type = svn

Create Trac users;

FORMAT:    htdigest [ -c ] passwdfile realm username

# htdigest -c /home/trac/myproject/conf/users.htdigest MyProjectRealm sezgin
Enter a password for this user and confirm it.

Add other users by removing “-c” parameter;

# htdigest /home/trac/myproject/conf/users.htdigest MyProjectRealm baha
# cd /usr/local/etc/rc.d/
# touch tracd
# chmod 555 tracd
# vi tracd
# $Id$

# PROVIDE: tracd
# KEYWORD: shutdown
# Add the following line into /etc/rc.conf to enable Tracd:
# tracd_enable="YES"
# - optional -
# tracd_flags="-d --listen-port=81"
# tracd_data="/path/to/project"

. "/etc/rc.subr"

# Set the defaults
tracd_flags=${tracd_flags:-"-d --port=81"}

load_rc_config $name

command_args=" --pidfile=${tracd_pidfile} ${tracd_data}"

run_rc_command "$1"

save and quit tracd script with wq!

# vi /etc/rc.conf



Be careful! Your realm name must match the one you picked while creating the users above.

tracd_flags="-dsp 81 --auth=myproject,/home/trac/myproject/conf/users.htdigest,MyProjectRealm"


trac-admin /path/to/myproject permission add username-from-users.htdigest TRAC_ADMIN

# trac-admin /home/trac/myproject permission add sezgin TRAC_ADMIN

Refresh the page and you will see the Admin tab in the right upper corner of the page, if you’re logged in. You may now also browse and manage the repositories by visiting


As the repository “myproject” has been added via trac.ini, we should first run trac-admin $ENV repository resync “myproject” to synchronize Trac with this repository. We should also set up a post-commit hook on the repository to call trac-admin $ENV changeset added “myproject” $REV for each committed changeset.

# trac-admin /home/trac/myproject repository resync "myproject"
Resyncing repository history for myproject...
44 revisions cached.

Explicit Synchronization

In order to get your existing subversion repository to show up in Trac Repository Index and get the commits appear as a timeline in Trac, create the following scripts (without extension);

# cd /tmp/
# mkdir cache
# chown -R root:svn cache
# cd /home/svn/repositories/myproject/hooks/
# touch post-commit
# vi post-commit
export PYTHON_EGG_CACHE="/tmp/cache"
su svn -c '/usr/local/bin/trac-admin /home/trac/myproject changeset added /home/svn/repositories/myproject "$2"'


# chmod 755 post-commit
# touch post-revprop-change
# vi post-revprop-change
export PYTHON_EGG_CACHE="/tmp/cache"
su svn -c '/usr/local/bin/trac-admin /home/trac/myproject changeset modified /home/svn/repositories/myproject "$2"'


# chmod 755 post-revprop-change

Notice that we’ve used “su” to become svn user who normally should run the script because we access the repository through svn:// instead of http://

Install the Account Manager plugin;

# cd /usr/ports/www/trac-accountmanager/
# make install clean
# cp /usr/local/lib/python2.6/site-packages/TracAccountManager-0.2.1dev-py2.6.egg /home/trac/myproject/plugins/
# /usr/local/etc/rc.d/tracd restart

If you need to uninstall a plugin later, follow this method;

# easy_install -m <plugin name>
# cd /usr/ports/www/<plugin port name>/
# make deinstall
# /usr/local/etc/rc.d/tracd restart

SVN CHECKOUT in Document Root

Do an in-place ‘import’ to have a working copy. Otherwise you’ll receive “Skipped ‘.’ ” errors when you try to do svn updates. Don’t forget the dot at the end.

# cd /usr/local/www/apache22/data/myproject/webfolder/
# svn co svn:// .

Now create a sh script named svnup.sh for automatically updating the repository files into document root at the background;

echo "Starting background svnup checks..."
while true;
/usr/local/bin/svn up --username sezgin --password 'xxxxxxxx' --non-interactive /usr/local/www/apache22/data/myproject/webfolder
sleep 10

Put your script inside /etc/rc.local to background it on reboots.

# cd /etc
# touch rc.local
# vi rc.local
/path/to/script/svnup.sh > /var/log/svnup.log 2>&1 &

Save and quit, then create the log file.

# touch /var/log/svnup.log
# reboot

That’s all. Now you must have a turn-key Subversion & Trac installation on your system. If you face any troubles, especially during the repository synchronization, go to Admin tab and enable File Logging with DEBUG Log level. Give a name to your log file such as trac.log and apply changes. Then;

# tail -f /home/trac/myproject/log/trac.log

For further information and highly detailed documentation, don’t forget to visit  http://trac.edgewall.org

Related Posts with Thumbnails
Subscribe to our RSS feeds Email Subscription via FeedBurner RSS Subscription via FeedBurner

  No related posts.

No Comments »


There has not been any trackback links yet.

Reader Comments

There are currently no reader comments available at this time.

RSS feed for comments RSS feed for comments on this post. TrackBack URL

Leave a comment