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

Guest's picture

I can't use trac-initrepo

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

alon'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.
Guest's picture

trac-initproject

when i run trac-initproject svn foobar i get

: invalid option

any ideas?

Guest's picture

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.

Guest's picture

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.

Guest's picture

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!

Guest's picture

Removing the example projects?

 How do I remove the example projects?

Guest's picture

Remove project

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

Guest's picture

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

Guest's picture

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!