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:
System Information
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 |
——————————-
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.
3.
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 '*'
6.
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”.
adduser <username>
8.2 Create a user group for the project.
groupadd <project-name>
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
example commands:
//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>
Hi!
Nice to know, someone is doing the same thing. I have to problems with your solution “out-of-the-box”.
1. Plugins had to be enabled in GUI? When I enabled them in ini file, there was no change…
2. I get file permission error when try to create new user.
“The password file could not be updated. Trac requires read and write access to both the password file and its parent directory.”
I advice you not to go on a “denyCurrentBranch = false” path, go with “git –bare init”, I think it is more clean solution.
Overall it was helpful, you have put final touches! Thank you.
Kind Regards,
Miroslav
Dear Miroslav,
Thanks for the comments.
Since, I had worked on it some time ago, I am unable to remember the exact details. But I’ll try to say what I remember:
1. I think plugins were enabled in the ini file only. Enabling from gui is also fine. But I think, I had to download and install some plugins which were not available(not sure about it).
2. don’t remember any issue like that. Did you try changing the file permission ? ( I think I might have done these steps http://www.turnkeylinux.org/docs/trac/usage#comment-2067 first ).
3. There was some troubling issue I was facing when doing git –bare, which led me to choose the otherwise. But, unfortunately I don’t remember what exactly it was now.
If you were able to solve the above problems and were able to set up a multi-user trac-integrated git repo in the turnkey vm, can you please share your experience with others. You can write a post on it and I shall link it from my post too. Or I can add a guest post from you also here.