TurnKey Linux Virtual Appliance Library

Trac usage: Creating and accessing projects

The below usage notes are dependent on trac-initproject.
The exemplary project name is called foobar.
 

git

To initialize the project, log into the Trac server and execute:

trac-initproject git foobar

Developers can then upload their local master branch using the following methods:

If public push access is enabled:

git-push git://appliance_ip/git/foobar master 

Or, over an SSH connection:

git-push ssh://root@appliance_ip/srv/repos/git/public/foobar.git master

Optionally, the developer can configure the remote repository for simpler future updates:

git-config remote.turnkey-trac.url ssh://root@appliance_ip/srv/repos/git/public/foobar.git
git-config remote.turnkey-trac.push +master:refs/heads/master
git-push turnkey-trac

Users can then clone the remote repository using the following methods:

Anonymously:

git-clone git://appliance_ip/git/foobar

Or, over an SSH connection:

git-clone ssh://root@appliance_ip/srv/repos/git/foobar

 

Bazaar (bzr)

To initialize the project, log into the Trac server and execute:

trac-initproject bzr foobar

Developers can then upload their local branch:

Over an SFTP connection (depends on python-paramiko)

bzr push sftp://root@1.0.0.94/srv/repos/bzr/foobar

If there is no default push location set, the first push will set it. After that, the location can be omitted and the default will be used:

bzr push

Users can then clone the remote repository:

bzr clone bzr://appliance_ip/bzr/foobar

 

Mercurial (hg)

To initialize the project, log into the Trac server and execute:

trac-initproject hg foobar

Developers can then upload their local branch using the following methods:

Note the extra slash. Mercurial assumes paths are relative to the users home directory over SSH connections:

hg push ssh://root@appliance_ip//srv/repos/hg/foobar

Optionally, the developer can configure the remote repository for simpler future updates, by adding the following to foobar/.hg/hgrc

[paths]
default-push = ssh://root@appliance_ip//srv/repos/hg/foobar

Future pushes can then be performed as follows:

hg push

Users can then clone the remote repository:

hg clone http://appliance_ip:8080/foobar

 

Subversion (svn)

To initialize the project, log into the Trac server and execute:

trac-initproject svn foobar

Developers can then checkout the remote repository, make changes, then commit back to the remote repository:

Checkout over SSH:

svn co svn+ssh://root@appliance_ip/srv/repos/svn/foobar

After making local changes, they can be commited to the remote repository:

svn commit

Users can then checkout the remote repository using the following methods:

Anonymously:

svn co svn://appliance_ip/svn/foobar

Or, over an SSH connection:

svn co svn+ssh://root@appliance_ip/srv/repos/svn/foobar

 

 

Comments

I can't use trac-initrepo

As I issue "trac-initrepo svn foobar", it always results to "command not found". Please help.

Alon Swartz's picture

trac-initrepo -> trac-initproject

Oops, thanks for catching that. It was a typo and should be trac-initproject. Fixed.
Just to be clear, the above usage notes are dependent on trac-initproject.

trac-initproject

when i run trac-initproject svn foobar i get

: invalid option

any ideas?

Solution

1. Log in as root through putty or onto the local server

2. reate the script by typing  "nano /usr/local/bin/trac-initproject" it will open a new file.

3. Copy the code below and pase it if using putty or write it in the terminal.

 

#!/bin/bash -e
#Copyright (c) 2009 Alon Swartz <alon@turnkeylinux.org> - all rights reserved

fatal() {
    echo "fatal: $@" 1>&2
    exit 1
}

esc() {
    echo $1 | sed "s/\//\\\\\//g"
}

init_trac_project() {
    echo "initializing trac project: $VC"

    trac-admin $PROJ_LIB initenv "$PROJ_NAME" sqlite:db/trac.db $VC $PROJ_REPO
    trac-admin $PROJ_LIB permission add $ADMIN_USER TRAC_ADMIN

    mv $PROJ_LIB/conf/trac.ini $INI
    ln -s $INI $PROJ_LIB/conf/trac.ini
    chown www-data:www-data $INI

    sed -i "s/^alt = \(.*\)/alt = trac logo/" $INI
    sed -i "s/^height = \(.*\)/height = 73/" $INI
    sed -i "s/^link = \(.*\)/link = \/$PROJ/" $INI
    sed -i "s/^width = \(.*\)/width = 236/" $INI
    sed -i "s/^src = \(.*\)/src = $(esc site/logo.png)/" $INI

    sed -i "s/^descr = \(.*\)/descr = $PROJ_NAME/" $INI

    sed -i "s/^smtp_enabled = \(.*\)/smtp_enabled = true/" $INI
    sed -i "s/trac@localhost/root@localhost/g" $INI

    rmdir $PROJ_LIB/htdocs
    ln -s $TRAC_SHARE/htdocs/site $PROJ_LIB/htdocs

    rmdir $PROJ_LIB/plugins
    ln -s $TRAC_SHARE/plugins $PROJ_LIB/plugins

    chown -R www-data:www-data $TRAC_LIB
}

if [ $# -ne "2" ]; then
    echo "Syntax:  $0 git|bzr|svn|hg NAME"
    echo "Example: $0 git foobar"
    echo 
    echo "Environment variables:"
    echo "    GIT_PUBLIC_WRITE    enabled public write access (default: yes)"
    exit 1
fi

VC=$1
NAME=$2

ADMIN_USER=admin

TRAC_ETC=/etc/trac
TRAC_LIB=/var/local/lib/trac
TRAC_SHARE=/usr/local/share/trac

PROJ=$VC-$NAME
PROJ_LIB=$TRAC_LIB/$PROJ
PROJ_REPO=/srv/repos/$VC/$NAME
PROJ_NAME="$VC $NAME project"
INI=$TRAC_ETC/$PROJ.ini

set ${GIT_PUBLIC_WRITE:=yes}

case "$VC" in
    git)
        # initialize empty repository
        mkdir -p $PROJ_REPO
        cd $PROJ_REPO
        git-init

        touch $PROJ_REPO/.git/git-daemon-export-ok
        ln -s $PROJ_REPO/.git /var/cache/git/$NAME.git
        echo $name > $PROJ_REPO/.git/description

        # allow public git-push to repo
        if [ "$GIT_PUBLIC_WRITE" == "yes" ]; then
            echo "[daemon]" >> $PROJ_REPO/.git/config
            echo "        uploadpack = true" >> $PROJ_REPO/.git/config
            echo "        uploadarchive = true" >> $PROJ_REPO/.git/config
            echo "        receivepack = true" >> $PROJ_REPO/.git/config
        fi

        # initialize trac project
        init_trac_project
        INI=$TRAC_ETC/$VC-$NAME.ini
        GIT_REPO=/var/cache/git/$NAME.git
        sed -i "s/^repository_dir =\(.*\)/repository_dir = $(esc $GIT_REPO)/" $INI
        sed -i "s/^git_bin = \(.*\)/git_bin = $(esc /usr/bin/git)/" $INI
        echo "[components]" >> $INI
        echo "tracext.git.* = enabled" >> $INI
        ;;
    bzr)
        # initialize empty repository
        mkdir -p $PROJ_REPO
        cd $PROJ_REPO
        bzr init-repository .

        # initialize trac project
        init_trac_project
        INI=$TRAC_ETC/$VC-$NAME.ini
        echo "[components]" >> $INI
        echo "tracbzr.* = enabled" >> $INI
        ;;
    hg)
        # initialize empty repository
        mkdir -p $PROJ_REPO
        cd $PROJ_REPO
        hg init

        # initialize trac project
        init_trac_project
        INI=$TRAC_ETC/$VC-$NAME.ini
        echo "[components]" >> $INI
        echo "tracext.hg.* = enabled" >> $INI
        ;;
    svn)
        # initialize empty repository
        mkdir -p $PROJ_REPO
        svnadmin create $PROJ_REPO

        # initialize trac project
        init_trac_project
        ;;
    *)
        fatal "unsupported VC: $VC"
        ;;
esac

4. save it by pressing SHIFT key+X press y and enter

5. enter command as root "

chmod +x /usr/local/bin/trac-initproject

"

6. then follow steps on this page http://www.turnkeylinux.org/docs/trac/usage

Replace foobar with whatever project name you want.

 

I hope this will help.

About this problem :invalid

Hi, I copy - paste this lines and still showing the same error :invalid, why this happening? what's invalid? thanks on advantage.

Tnx mate

Tnx Mate u just made my life easyer.

U helped alote.

This is comment of a lasy Noob :)

PS. Tnx to turnkey devs too

What about revision control appliance?

What about revision control appliance? How do I add repos there?

I tried to copy trac-initproject (after i installed trac via apt-get install trac) and I get

Wrong number of arguments to initenv: 4

Any clues? I didn't find any explicit instructions on revision appliance page :(

 

thanks!

Removing the example projects?

 How do I remove the example projects?

Remove project

I would also like to know how to remove example project (trac + respository - git).

You can remove repository and trac settings

You can remove:

   /srv/repos/git/your_project

   /var/local/lib/trac/your_project

   /etc/trac/your_project.ini

Accessing by

How would one install DAV svn on Turnkey Trac?  (I don't see it already installed.)

Some 3rd party svn clients don't play well with svn+ssh.

Thanks!

Error with initproject

I'm getting this error when run trac-initproject

 

TracError: The user www-data requires read _and_ write permission to the database file /var/local/lib/trac/hg-teste5/db/trac.db and the directory it is located in.

 

All chmod and chown was made with no luck :(

Error with initproject

Same error here :(

some advice?

permission fixed

Ok, I fixed the problem myself :)

I just changed all the files owner to www-data:

chown -R www-data.www-data *

in the trac folder (/var/local/lib/trac/your-project-name)

Security question for committing

Sorry for the newbie question, guys, but how do I give my development team access to commit their changes to the svn repo without giving them the root password?

According to the above you can only commit through SSH, so I created a new Linux user called svn that I planned on distributing to my team, instructing them to access the repo as follows:

svn co svn+ssh://svn@appliance_ip/srv/repos/svn/foobar

However, when I commit from TortoiseSVN I get the following error:

Error: Can't open file '/srv/repos/svn/foobar/db/txn-current-lock': Permission denied

I guess the issue is that the /srv/repos directory (and everything below it) is owned by root, but I don't want to change that and risk breaking everything.

Any tips?

Thanks!

Re: Security question for committing

You should change the group ownership of

/srv/repos/svn/foobar

to the group of the user 'svn' and also change the mode of files and dirs to 775. If the user 'svn' has group 'users' then the following will do the trick.

chgrp -R users /srv/repos/svn/foobar
chmod -R g+w /srv/repos/svn/foobar

You better use svn auth,

You better use svn auth, configure at /srv/repos/svn/yourepo/conf/svnserver.conf search in [general] activate auth-access = write and set password-db. Now add users at .../conf/passwd file. Once youre done restart the svn server with /etc/init.d/svnserve restart.

Just comit with svn ci svn://yourip/svn/yourrepo and you will be prompted by the username in some point.

Leandro's picture

Thanks!

My thanks to both René and "Guest" for their responses. I decided to go along with the latter's, as it's less "intrusive" and my repository isn't especially sensitive (so no need for SSH).


Adding a user

I have my repository setup and I have it secured usin svn auth, but how do I add a user to the projcet so they can view and add tickets?

GIT: Line 75: git-init: command not found

Hello,

I am trying to use the helper script to create a new GIT project.  When executing from the command line:

 

/usr/local/bin/trac-initproject git foobar
 
I am getting the following error:
 
/usr/local/bin/trac-initproject: line 75: git-init: command not found
 
Looking at the script, I see line 75 is:
 
git-init
 
I try to locate the git-init script on my Trac appliance by running:
 
find / | grep git-init and I find it in /usr/lib/git-core/git-init
 
So I modified the trac-initproject script line 75 to include /usr/lib/git-core/git-init and re-run the command trac-initproject git foobar and that seems to work
 
Did I do something along the way to break the ability to locat the git-init command, or is this a known issue?
 
 
 

Setting up a multi-project multi-user git repo with turnkey trac

I spent a few days setting up a multi-user multi-project git repo using turnkey trac. Finally I made it, it is up successfully and the instructions are availeble at http://wp.me/p1BbXy-B . This applies to the following version spec:

Trac: 0.11.7

Python: 2.6.5 (r265:79063, Apr 16 2010, 13:28:26) [GCC 4.4.3]

setuptools: 0.6

SQLite: 3.6.22

pysqlite: 2.4.1

Genshi: 0.5.1

mod_wsgi: 2.8 (WSGIProcessGroup wsgitrac WSGIApplicationGroup 127.0.1.1|)

Pygments: 1.2.2

GIT: 1.7.0.4

 

Trying to add Trac to a Revision Control appliance - need help

Hi,

Unfortunately, the appliance we installed was the Revision Control one for SVN.  I am trying to add Trac on the same machine.  Here are the commands that I ran:

1. sudo apt-get install trac : It appeared to install Trac and I could see it as installed from the Webmin UI)

2. Created the script - http://www.turnkeylinux.org/docs/trac/trac-initproject

3. Ran sudo trac-initproject svn TestRepo (TestRepo was already existing and it complained that svnadmin: '/srv/repos/svn/TestRepo' is a subdirectory of an existing repository rooted at '/srv/repos/svn/TestRepo'

4. Ran it again on a repo that didn't exist

sudo trac-initproject svn testtickets

initializing trac project: svn
Creating and Initializing Project
Initenv for '/var/local/lib/trac/svn-testtickets' failed. 
 Failed to create environment.
[Errno 2] No such file or directory: '/var/local/lib/trac/svn-testtickets'
Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/trac/admin/console.py", line 583, in do_initenv
    options=options)
  File "/usr/lib/python2.6/dist-packages/trac/env.py", line 207, in __init__
    self.create(options)
  File "/usr/lib/python2.6/dist-packages/trac/env.py", line 316, in create
    os.mkdir(self.path)
OSError: [Errno 2] No such file or directory: '/var/local/lib/trac/svn-testtickets'
 
What am I doing wrong?  Can't a trac system be installed as an addition to another appliance?  Any help would be really appreciated.
 
Thanks
-Manoj.