+++ date = "2007-06-12" title = "BASH your SVN and Trac installation!" tags = ["General", "Features", "BASH"] slug = "bash-your-svn-and-trac-installation" description = "Quick bash script to setup your Subversion and Track install" +++ I've already discussed how to install Subversion and Trac on your Ubuntu server. In my case I have a server that manages different SVN and Trac installations for a group of developers. Creating a new SVN repository and Trac installation every time is quite boring and "if you need to do it more than once, you should automate it". So, that's what I did. The result is the following BASH script. It takes one argument, the name of the project you want to create. E.g if you wanted to create a SVN repository and trac installation for "My Project" you would run the following command:
$ ./create_dev_env my_project
The script it self looks like this: ```bash #!/bin/sh echo == Creating Subversion and Trac installation for $1 echo = Creating SVN Repository... # Subversion cd /var/lib/svn mkdir -p /var/lib/svn/$1 svnadmin create /var/lib/svn/$1 sed s/EXAMPLE/$1/g /usr/share/trac/contrib/post-commit > /var/lib/svn/$1/hooks/post-commit chmod +x /var/lib/svn/$1/hooks/post-commit chown -R www-data:www-data /var/lib/svn/$1 # Trac echo = Creating Trac install... cd /var/lib/trac mkdir -p /var/lib/trac/$1 echo - Creating files trac-admin /var/lib/trac/$1 initenv $1 sqlite:db/trac.db svn \ /var/lib/svn/$1 /usr/share/trac/templates echo - Removing anonymous permissions trac-admin /var/lib/trac/$1 permission remove anonymous BROWSER_VIEW trac-admin /var/lib/trac/$1 permission remove anonymous CHANGESET_VIEW trac-admin /var/lib/trac/$1 permission remove anonymous FILE_VIEW trac-admin /var/lib/trac/$1 permission remove anonymous LOG_VIEW trac-admin /var/lib/trac/$1 permission remove anonymous MILESTONE_VIEW trac-admin /var/lib/trac/$1 permission remove anonymous REPORT_SQL_VIEW trac-admin /var/lib/trac/$1 permission remove anonymous REPORT_VIEW trac-admin /var/lib/trac/$1 permission remove anonymous ROADMAP_VIEW trac-admin /var/lib/trac/$1 permission remove anonymous SEARCH_VIEW trac-admin /var/lib/trac/$1 permission remove anonymous TICKET_CREATE trac-admin /var/lib/trac/$1 permission remove anonymous TICKET_MODIFY trac-admin /var/lib/trac/$1 permission remove anonymous TICKET_VIEW trac-admin /var/lib/trac/$1 permission remove anonymous TIMELINE_VIEW trac-admin /var/lib/trac/$1 permission remove anonymous WIKI_CREATE trac-admin /var/lib/trac/$1 permission remove anonymous WIKI_MODIFY trac-admin /var/lib/trac/$1 permission remove anonymous WIKI_VIEW echo - Creating Trac admins trac-admin /var/lib/trac/$1 permission add ariejan TRAC_ADMIN chown -R www-data:www-data /var/lib/trac/$1 echo echo == Done. ``` First it creates the SVN directory in /var/lib/svn/my_project and creates repository and adds the trac post-commit hook for trac integration. Next, it creates the trac installation in /var/lib/trac/my_project and removes all the persmission the anonymous users has. (You may want to remove these lines for open source or public projects.) And, finally, I'm added as an administrator to the project. Make sure to replace this with you own username. Hope you find this script useful. Any improvements are welcome, please let me know.