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 following are the instructions for it. This applies to the following version spec:
|Python:||2.6.5 (r265:79063, Apr 16 2010, 13:28:26) [GCC 4.4.3]|
|mod_wsgi:||2.8 (WSGIProcessGroup wsgitrac WSGIApplicationGroup 127.0.1.1|)|
Adding a project
WARNING: Hosting of the other projects may be affected while performing the following steps. Hence, it is better to take a backup of the vm before performing the following steps.
WARNING: Make sure to perform all the following steps exactly in the mentioned order only.
1. Login as root in the vm containing trac. (Using a terminal from a remote machine instead of directly working on the vm window as it is faster and easier for copy pasting)
// eg: ssh root@<IP>
2. Create the project.
trac-initproject git <project name>
//setting up the web page. Do not use the web interface of the project now.
cd /var/local/lib/trac/git-<project name>/conf/
4. edit trac.ini of the project.
4.1 append the following lines under [components]
acct_mgr.admin.accountmanageradminpage = enabled acct_mgr.api.accountmanager = enabled acct_mgr.db.sessionstore = disabled acct_mgr.htfile.htpasswdstore = enabled acct_mgr.notification.accountchangelistener = enabled acct_mgr.notification.accountchangenotificationadminpanel = enabled acct_mgr.web_ui.accountmodule = enabled acct_mgr.web_ui.loginmodule = enabled httphostlink.* = enabled iniadmin.* = enabled noanonymous.filter.* = enabled trac.web.auth.loginmodule = disabled
4.2 remove the entries under [account-manager] and add the following lines
force_passwd_change = true password_file = /etc/trac/htpasswd password_store = HtPasswdStore
5. Remove default premissions.
trac-admin /var/local/lib/trac/git-<project>/ permission remove authenticated '*' trac-admin /var/local/lib/trac/git-<project>/ permission remove anonymous '*'
service apache2 restart
7. You can use the web interface of the project now.( available at https://<IP> Note: HTTPS instead of HTTP )
7.1 After logging in as admin(username: admin, password: you should ask and get it 🙂 ), you can add new users if required by going to Admin -> Accounts -> Users. Existing user accounts can be viewed in the page. Note that the users created will be global to all the projects and the existing user accounts can be reused.
7.2 The permissions given to users are project specific. Add permissions to different users by going to Admin -> General -> Permissions. TRAC_ADMIN permission will make the user have full administrative access to the newly created project. Details of different permissions are available at http://trac.edgewall.org/wiki/TracPermissions .
The web interface is now fully configured.
8. Configuring the git repo.
8.1 Login as root in the vm.
Create new users or reuse the existing user accounts for the project( Existing users can be seen by issuing cat /etc/passwd ). New users can be created using “adduser”.
8.2 Create a user group for the project.
8.3 add the required user(s) to the group.
usermod -a -G <group name> <user name>
8.4 Allow push to checked out branch
cd /srv/repos/git/<project name>/.git
Append the following to config file.
[receive] denyCurrentBranch = false
8.5 Assign permissions of git repo to group
cd /srv/repos/git/<project name> chown -R www-data.<group name> .git # eg: chown -R www-data.myproject .git chmod -R 771 .git
9. Git for the project is ready for use now.
IMPORTANT: Never edit the source code by logging into to the vm and then commiting there(Otherwise, it will lead to insconsistency in the git repo). Always use git push remotely to modify the repository.
The repository is avaiable for remote use at ssh://<user name>@<IP>/srv/repos/git/public/<project>.git
To submit the initial code from your git repo to master branch in server,
#(If you are starting fresh withoud an existing local repo, in the directory containing the source files to be shared, do the following steps to initialize the local repo # git init # git add . # git commit -am "initial commit" #) git push ssh://<user name>@<IP>/srv/repos/git/public/<project>.git master
Others can clone the repo, create new branches and start working on them and push to master branch. Some remote examples are shown below. But it is better to start using after having a basic idea of git. A git tutorial is available at http://www.vogella.de/articles/Git/article.html
//cloning a repo git clone ssh://<user>@<IP>/srv/repos/git/public/<project>.git //fetching from master git fetch ssh://<user><IP>/srv/repos/git/public/<project>.git master //pushing to remote branch git push ssh://<user>@<IP>/srv/repos/git/public/<project>.git <branch name>
You can avoid the hassle of typing password each time by using ssh passwordless login(see http://linuxconfig.org/Passwordless_ssh ). You can avoid the lengthy remote url in the commands by using “git remote add” (explained in the git tutorial).
Removing a project
cd /var/local/lib/trac/ rm -rf git-<project> cd /etc/trac/ rm -rf git-<project>.ini cd /srv/repos/git rm -rf <project>