Inizio  >  Docs  >  Linux  >  How to  >  Trac  
TracTrac

Index

Create new Project

 

vim add_proj.sh

############# add_proj.sh Start ###############

#!/bin/bash
SVNPATH="/srv/www/svn/svnrepos";
TRACPATH="/srv/www/trac";
WEBLOGOPATH="http://info.getrag.de/fileadmin/img/trac_logo.png";
ADMINUSER="nikoz"

echo creo progetto $1 con nome "$2"

svnadmin create ${SVNPATH}/$1 --fs-type fsfs

trac-admin ${TRACPATH}/$1 initenv "$2" "sqlite:db/trac.db" "svn" "${SVNPATH}/$1"
trac-admin ${TRACPATH}/$1/ permission remove anonymous WIKI_CREATE WIKI_MODIFY BROWSER_VIEW
trac-admin ${TRACPATH}/$1/ permission add anonymous TICKET_CREATE
trac-admin ${TRACPATH}/$1/ permission add authenticated WIKI_ADMIN BROWSER_VIEW MILESTONE_ADMIN
trac-admin ${TRACPATH}/$1/ permission add ${ADMINUSER} TRAC_ADMIN;
sed -i.bak "s%^alt.*%alt = $2%" ${TRACPATH}/$1/conf/trac.ini|more
sed -i.bak "s%^link.*%link = $WEBLOGOPATH%" ${TRACPATH}/$1/conf/trac.ini|more
sed -i.bak "s%^src.*%src = $WEBLOGOPATH%" ${TRACPATH}/$1/conf/trac.ini|more

chown -R apache:apache /srv/www/
chmod -R g+w /srv/www/
chmod -R g+s /srv/www/

############# add_proj.sh Finish ###############

chmod +x add_proj.sh

./add_proj.sh PorjName "Project Name"

 

To top

Migrate old trac projects

on the old server

cd /opt/projects/trac/

tar cfvz /media/usb/tracDump.tgz  *

 

on the new server

vim upgrade_projects.sh

############## upgrade_projects.sh Start ##############

#!/bin/bash
OLDSVNPATH="/opt/projects/svn";
SVNPATH="/srv/www/svn/svnrepos";
TRACPATH="/srv/www/trac";
WEBLOGOPATH="http://info.getrag.de/fileadmin/img/trac_logo.png";
ADMINUSER="nikoz"

for tracName in `ls -1 ${TRACPATH}/`;
do
    trac-admin ${TRACPATH}/${tracName} upgrade;
  trac-admin ${TRACPATH}/${tracName} wiki upgrade;
  trac-admin ${TRACPATH}/${tracName} permission remove anonymous WIKI_CREATE WIKI_MODIFY BROWSER_VIEW
    trac-admin ${TRACPATH}/${tracName} permission add anonymous TICKET_CREATE
    trac-admin ${TRACPATH}/${tracName} permission add authenticated WIKI_ADMIN BROWSER_VIEW MILESTONE_ADMIN
    trac-admin ${TRACPATH}/${tracName} permission add ${ADMINUSER} TRAC_ADMIN;

    sed -i.bak "s%^link.*%link = $WEBLOGOPATH%" ${TRACPATH}/${tracName}/conf/trac.ini|more
    sed -i.bak "s%^src.*%src = $WEBLOGOPATH%" ${TRACPATH}/${tracName}/conf/trac.ini|more
  sed -i.bak s%$OLDSVNPATH%$SVNPATH% ${TRACPATH}/${tracName}/conf/trac.ini ;
  trac-admin ${TRACPATH}/${tracName}/ repository resync '*' ;
done;

chown -R apache:apache /srv/www/
chmod -R g+w /srv/www/
chmod -R g+s /srv/www/

############## upgrade_projects.sh Finish ##############

To top

Setup 0.12.2 on CentOS 5.5 64

if beyound a  proxy server

export http_proxy=http://proxy:8080/
export https_proxy=https://proxy:8080/
env |grep http

rpm -Uhv apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS//rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

or

rpm -Uhv /media/nfs_3.2/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

yum update

yum -y install subversion trac mod_dav_svn mod_python httpd
mkdir -p /srv/www/svn/svnrepos
mkdir -p /srv/www/svn/auth
htpasswd -cb /srv/www/svn/auth/svn.htpasswd svnuser1 passw0rd
svnadmin create /srv/www/svn/svnrepos/test
svn mkdir file:///srv/www/svn/svnrepos/test/branches file:///srv/www/svn/svnrepos/test/tags file:///srv/www/svn/
svnrepos/test/trunk -m "Creating directories for initial import"
chown -R apache:apache /srv/www/svn/svnrepos/test/
vi /etc/httpd/conf.d/svn.conf
####################################################################
    <Location /svn>
    DAV svn
    SVNListParentPath on
    SVNParentPath /srv/www/svn/svnrepos/

    AuthType Basic
    AuthName "test Site Repository"
    AuthUserFile /srv/www/svn/auth/svn.htpasswd
    Require valid-user
    </Location>
####################################################################

  /etc/init.d/httpd restart
mkdir /srv/www/trac
trac-admin /srv/www/trac/test initenv "Project Name" "sqlite:db/trac.db" "svn" "/srv/www/svn/svnrepos/test"
vi /etc/httpd/conf.d/trac.conf
####################################################################
###
### Sample Trac configuration taken from
trac.edgewall.org/wiki/TracModPython
###

### The recommended Trac web interface requires mod_python
<IfModule mod_python.c>

### Create your Trac environments as subdirectories of /var/trac
### They will appear in a listing on your website at /trac/, and be available
### at /trac/PROJECTNAME/
<Location /trac>
  SetHandler mod_python
  PythonInterpreter main_interpreter
  PythonHandler trac.web.modpython_frontend
  PythonOption TracEnvParentDir /srv/www/trac
  PythonOption TracUriRoot /trac
</Location>

### Use htpasswd to add Trac accounts to the AuthUserFile
<LocationMatch "/trac/[^/]+/login">
  AuthType Basic
  AuthName "Trac"
  AuthUserFile /srv/www/trac/.htpasswd
  Require valid-user
</LocationMatch>

</IfModule>
####################################################################

htpasswd -cb /srv/www/trac/.htpasswd tracuser1 passw0rd
chown -R apache:apache /srv/www/trac/test/
/etc/init.d/httpd restart

 trac-admin /srv/www/trac/test permission add  tracuser1 TRAC_ADMIN

To top

locales setup 0.12.2 on CentOS 5.5 64

yum install babel

cd /opt/

wget -vc http://ftp.edgewall.com/pub/trac/Trac-0.12.2.tar.gz

tar xfvz /media/nfs_3.2/Trac-0.12.2.tar.gz

cd Trac-0.12.2/

make stats-pot update check compile stats locale='it fr de en_GB en_US sv'

cd trac/locale/

cp -av * /usr/lib/python2.4/site-packages/trac/locale/

To top

Setup 0.10.5 on Ubuntu / Debian

aptitude  install subversion libapache2-svn python2.4-pysqlite2 python2.4-subversion python-clearsilver sqlite3
wget -vc ftp.edgewall.com/pub/trac/trac-0.10.5.tar.gz
tar xfvz trac-0.10.5.tar.gz
cd trac-0.10.5/
python setup.py install
cd /opt/
mkdir projects
cd projects/
mkdir svn trac files

ll /etc/apache2/mods-available/
ll /etc/apache2/mods-enabled/

a2enmod dav_fs
cd /etc/apache2/
cd conf.d/
vim project.conf

#################################################################
ScriptAlias /projects /usr/share/trac/cgi-bin/trac.cgi
<Location "/projects">
    SetEnv TRAC_ENV_PARENT_DIR "/opt/projects/trac"
</Location>
<LocationMatch "/projects/[^/]+/login">
    AuthType Basic
    AuthName "Trac Environment"
    AuthUserFile /opt/projects/projects.passwd
    Require valid-user
</LocationMatch>
<Location /svn>
    DAV svn
    SVNParentPath /opt/projects/svn
    AuthType Basic
    AuthName "Subversion Repositories"
    AuthUserFile /opt/projects/projects.passwd
    Require valid-user
</Location>
Alias /files /projects/files
<Location /files>
    DAV On
    AuthType Basic
    AuthName "Files"
    AuthUserFile /opt/projects/projects.passwd
    Require valid-user
</Location>
<LocationMatch ^/files/[^/]+/(images|public)/>
    <LimitExcept GET OPTIONS>
        Require valid-user
    </LimitExcept>
</LocationMatch>

################################################################

 

apache2ctl -t
/etc/init.d/apache2 reload
/etc/init.d/apache2 restart
cd /opt/projects/

svnadmin create svn/sandbox --fs-type fsfs

ll svn/
total 0
drwxr-xr-x 3 root root 1 2009-02-20 16:16 .
drwxr-xr-x 5 root root 1 2009-02-20 16:03 ..
drwxr-xr-x 7 root root 1 2009-02-20 16:16 sandbox
trac-admin trac/sandbox initenv

Creating a new Trac environment at /opt/projects/trac/sandbox

Trac will first ask a few questions about your environment
in order to initalize 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]>
Sandbox
 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]>
[enter]
 Please specify the type of version control system,
 By default, it will be svn.

 If you don't want to use Trac with version control integration,
 choose the default here and don't specify a repository directory.
in the next question.

Repository type [svn]>
[enter]

 Please specify the absolute path to the version control
 repository, or leave it blank to use Trac without a repository.
 You can also set the repository location later.

Path to repository [/path/to/repos]>
/opt/projects/svn/sandbox
 Please enter location of Trac page templates.
 Default is the location of the site-wide templates installed with Trac.

Templates directory [/usr/share/trac/templates]>
[enter]

Creating and Initializing Project
 Installing default wiki pages
 /usr/share/trac/wiki-default/TracReports => TracReports
 /usr/share/trac/wiki-default/TracModPython => TracModPython
 /usr/share/trac/wiki-default/TracNotification => TracNotification
 /usr/share/trac/wiki-default/RecentChanges => RecentChanges
 /usr/share/trac/wiki-default/TracRoadmap => TracRoadmap
 /usr/share/trac/wiki-default/WikiDeletePage => WikiDeletePage
 /usr/share/trac/wiki-default/TracChangeset => TracChangeset
 /usr/share/trac/wiki-default/TracEnvironment => TracEnvironment
 /usr/share/trac/wiki-default/TracFastCgi => TracFastCgi
 /usr/share/trac/wiki-default/WikiMacros => WikiMacros
 /usr/share/trac/wiki-default/TracLogging => TracLogging
 /usr/share/trac/wiki-default/TracAccessibility => TracAccessibility
/usr/share/trac/wiki-default/TracTicketsCustomFields => TracTicketsCustomFields
 /usr/share/trac/wiki-default/WikiHtml => WikiHtml
 /usr/share/trac/wiki-default/WikiStart => WikiStart
 /usr/share/trac/wiki-default/WikiPageNames => WikiPageNames
 /usr/share/trac/wiki-default/WikiRestructuredText => WikiRestructuredText
 /usr/share/trac/wiki-default/CamelCase => CamelCase
 /usr/share/trac/wiki-default/TracTickets => TracTickets
 /usr/share/trac/wiki-default/TracSupport => TracSupport
 /usr/share/trac/wiki-default/InterMapTxt => InterMapTxt
 /usr/share/trac/wiki-default/TracStandalone => TracStandalone
 /usr/share/trac/wiki-default/TracRevisionLog => TracRevisionLog
 /usr/share/trac/wiki-default/TracInterfaceCustomization => TracInterfaceCustomization
 /usr/share/trac/wiki-default/TracAdmin => TracAdmin
 /usr/share/trac/wiki-default/SandBox => SandBox
 /usr/share/trac/wiki-default/TracGuide => TracGuide
 /usr/share/trac/wiki-default/TracLinks => TracLinks
 /usr/share/trac/wiki-default/InterTrac => InterTrac
 /usr/share/trac/wiki-default/InterWiki => InterWiki
 /usr/share/trac/wiki-default/TracQuery => TracQuery
 /usr/share/trac/wiki-default/TracUnicode => TracUnicode
 /usr/share/trac/wiki-default/TracUpgrade => TracUpgrade
 /usr/share/trac/wiki-default/WikiNewPage => WikiNewPage
 /usr/share/trac/wiki-default/TitleIndex => TitleIndex
 /usr/share/trac/wiki-default/TracWiki => TracWiki
 /usr/share/trac/wiki-default/TracBackup => TracBackup
 /usr/share/trac/wiki-default/TracPermissions => TracPermissions
 /usr/share/trac/wiki-default/TracImport => TracImport
 /usr/share/trac/wiki-default/TracInstall => TracInstall
/usr/share/trac/wiki-default/TracPlugins => TracPlugins
 /usr/share/trac/wiki-default/TracSyntaxColoring => TracSyntaxColoring
 /usr/share/trac/wiki-default/TracTimeline => TracTimeline
 /usr/share/trac/wiki-default/WikiRestructuredTextLinks => WikiRestructuredTextLinks
 /usr/share/trac/wiki-default/TracBrowser => TracBrowser
 /usr/share/trac/wiki-default/TracCgi => TracCgi
 /usr/share/trac/wiki-default/TracIni => TracIni
 /usr/share/trac/wiki-default/TracRss => TracRss
 /usr/share/trac/wiki-default/WikiFormatting => WikiFormatting
 /usr/share/trac/wiki-default/TracSearch => TracSearch
 /usr/share/trac/wiki-default/WikiProcessors => WikiProcessors
 Indexing repository

---------------------------------------------------------------------
Project environment for 'Sandbox' created.

You may now configure the environment by editing the file:

  /opt/projects/trac/sandbox/conf/trac.ini

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 /opt/projects/trac/sandbox

Then point your browser to localhost/sandbox.
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
website:

  trac.edgewall.org

Congratulations!

 

htpasswd -c /opt/projects/projects.passwd nikoz
New password: [enter password]
Re-type new password: [enter password]
Adding password for user nikoz


chgrp -R www-data /opt/projects/
chmod -R g+w /opt/projects/
chmod -R g+s /opt/projects/
/etc/init.d/apache2 reload
 * Reloading apache 2.0 configuration...                                                                                                         [ ok ]
 trac-admin trac/sandbox/

Trac [/opt/projects/trac/sandbox]> permission remove anonymous WIKI_CREATE WIKI_MODIFY BROWSER_VIEW
Trac [/opt/projects/trac/sandbox]> permission add authenticated WIKI_ADMIN BROWSER_VIEW MILESTONE_ADMIN
Trac [/opt/projects/trac/sandbox]> quit

to surf our new trac server:

 http://serverweb/projects/

to checkout our projects via svn in a new local copy "localsandbox":

svn co  serverweb/svn/sandbox localsandbox

 

 

 

To top

Import old svn project into trac

Old SVN project: /opt/svn-repos/oldProject
New Trac project: /opt/projects/svn/newProject

Let's create a a new  trac project

cd /opt/projects/
./add_tarc_prj.sh newProject "Project Name"

now we have 2 possibilities:

Method 1 (normal copy):

cp -av /opt/svn-repos/oldProject/db  /opt/projects/svn/newProject/
trac-admin trac/newProject/ resync
chgrp -R www-data /opt/projects/
chmod -R g+w /opt/projects/
chmod -R g+s /opt/projects/

 

Method 2 (svn dump):

cd /opt/projects/
svnadmin dump /opt/svn-repos/oldProject >./oldProject.dump
svnadmin load /opt/projects/svn/newProject <./oldProject.dump
trac-admin trac/newProject/ resync
Resyncing repository history...

 

where ./add_tarc_prj.sh (bash script of previous tips):

#########

#!/bin/bash
#es. ./add_tarc_prj.sh db_prod_t "Produzione 2009temp"
echo creo progetto $1 con nome "$2"
cd /opt/projects/
svnadmin create svn/$1 --fs-type fsfs
##trac-admin trac/$1 initenv
trac-admin trac/$1 initenv "$2" "sqlite:db/trac.db" "svn" "/opt/projects/svn/$1" "/usr/share/trac/templates"
trac-admin trac/$1/ permission remove anonymous WIKI_CREATE WIKI_MODIFY BROWSER_VIEW
trac-admin trac/$1/ permission add authenticated WIKI_ADMIN BROWSER_VIEW MILESTONE_ADMIN
chgrp -R www-data /opt/projects/
chmod -R g+w /opt/projects/
chmod -R g+s /opt/projects/

##########