Contents
Install Trac
Install Packages
- Install required packages
aptitude install trac trac-bzr trac-spamfilter aptitude install python-mysqldb aptitude install python-pypdf aptitude install libtiff-tools aptitude install vim aptitude install sshfs aptitude install libapache2-mod-wsgi aptitude install mysql-server
Setup Mysql
- Setup Mysql server with trac username. Replace 'password' with "some very secret password".
mysql -u root -p create database trac; GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON trac.* TO 'trac'@'localhost' IDENTIFIED BY 'password'; FLUSH PRIVILEGES;
Create Trac project
- Create trac project
trac-admin /path/to/myproject initenv
#System will ask:
Project Name [My Project]> familytrac (enter your project name)
Database connection string [sqlite:db/trac.db]> mysql://username:password@localhost:3306/databasename
#Example:
Database connection string [sqlite:db/trac.db]> mysql://trac:mysecretpassword@localhost:3306/trac
Repository type [svn]> bzr (I work with bzr,pick yours)
Path to repository [/path/to/repos]> (I don't currently have a repozitory, so I'll skip this part. I can add it later in trac.ini)
== Start Trac using apache modwsgi module ==
*Create apache folder where we will create config files.
{{{
cd trac
mkdir apache
cd apache
htpasswd -c .htpasswd admin
htpasswd -c .htpasswd myname
htpasswd -c .htpasswd lucas
htpasswd -c .htpasswd mycoworkername- Create apache wsgi file and apache config file.
- Inside apache folder we created above
vi trac.wsgi
- Paste the following inside trac.wsgi:
import os os.environ['PYTHON_EGG_CACHE'] = '/path/to/trac/apache/eggs' import trac.web.main def application(environ, start_response): environ['trac.env_path'] = '/path/to/trac' return trac.web.main.dispatch_request(environ, start_response)
- Now lets create apache config file that we will place in /etc/apache2/sites-available/trac
- Right next to trac.wsgi create:
vi trac
- Paste
WSGIDaemonProcess trac threads=7 processes=8 maximum-requests=5000
WSGIProcessGroup trac
WSGIScriptAlias /trac /path/to/trac/apache/trac.wsgi
<Directory /path/to/trac/apache>
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
<Location "/trac/login">
AuthType Basic
AuthName "Trac"
AuthUserFile /path/to/trac/apache/.htpasswd
Require valid-user
</Location>- Now copy the trac file to apache2 site-available folder. (You might need to be a root or sudo):
cp trac /etc/apache2/sites-available/trac
- Modify permissions for attachment folder:
chown www-data:www-data attachments chown www-data:www-data conf
If you wanted to see if trac is working you could use:
tracd -p 8080 --basic-auth=*,/path/to/trac/apache/.htpasswd, tracd -p 8080 --basic-auth=*,/path/to/trac/apache/.htpasswd,/path/to/trac/ /path/to/trac/
Create login file, add Users
cd trac mkdir apache cd apache htpasswd -c .htpasswd admin htpasswd -c .htpasswd lucas htpasswd -c .htpasswd mycoworker
Give admin permissions
trac-admin /path/to/trac/ permission add admin TRAC_ADMIN trac-admin /path/to/trac/ permission add lucas TRAC_ADMIN
Customize Milestone, components,version
=== Remove default milestones,version, components ===
- Remove default milestones,version, components:
trac-admin ./trac/ milestone remove milestone1 trac-admin ./trac/ milestone remove milestone2 trac-admin ./trac/ milestone remove milestone3 trac-admin ./trac/ milestone remove milestone4 trac-admin ./trac/ version remove 1.0 trac-admin ./trac/ version remove 2.0 trac-admin ./trac/ component remove component1 trac-admin ./trac/ component remove component2
Add custom milestones,version, components
- Here I will show you how a "family trac" can be used as a document management for your bills, school documents, medical, official documents"
- I will use year as my version. You could change it to year,month, or persons name: lucas, john, michal..etc.
trac-admin ./trac/ version add 2008 trac-admin ./trac/ version add 2009 trac-admin ./trac/ version add 2010 trac-admin ./trac/ version add 2011 trac-admin ./trac/ version add 2012
- Add milestone, these are your categories: "bills", "vehicles", "school","home","
trac-admin ./trac/ milestone add Incoming trac-admin ./trac/ milestone add Bills trac-admin ./trac/ milestone add Vehicles trac-admin ./trac/ milestone add Home trac-admin ./trac/ milestone add School trac-admin ./trac/ milestone add Medical
- Add component: "comed", "att","nicor","cellphone","city of","other"
trac-admin ./trac/ component add None somebody trac-admin ./trac/ component add ComEd somebody trac-admin ./trac/ component add Att somebody trac-admin ./trac/ component add Nicor somebody trac-admin ./trac/ component add CellPhone somebody trac-admin ./trac/ component add CityOf somebody trac-admin ./trac/ component add Other somebody
Auto Upload
XML-RPC
- Install xml-rpc plugin
aptitude install trac-xmlrpc
- Use attached script to upload tickets: attachment:fax2trac.py
python fax2trac.py /home/lucas/ScanFolder/mydocument.pdf
Modify trac.ini
- Enable bzr or your favorite revisionism tool.
- Enable rpc (we will be using it to upload documents remotely)
- Enable Admin Page
#Add #[components] #tracbzr.* = enabled #tracrpc.* = enabled #acct_mgr.admin.AccountManagerAdminPage = enabled # #[ticket-custom] #claim_number=text #claim_number.label= Claim Number # #policy_number=text #policy_number.label=Policy Number #agency_number=text #agency_number.label=Agency Number
- Change default type from defect to task
vi ./trac/conf/trac.ini
default_type = task
* Change attachment file size:
max_size = 52480000
- Set default milestone and component to Incoming
default_milestone =Incoming default_component =None
Backup
mysqldump --user=root -p trac >trac_db_backup.sql
mysql -u root -p create database trac; exit;
mysql -u root -p trac < /tmp/trac_db_backup.sql
mysql -u root -p
grant usage on trac.* to trac@localhost identified by 'somepassword';
grant all privileges on trac.* to trac@localhost;
FLUSH PRIVILEGES;
{{{
cd /home/trac/
scp -r username@server:/home/trac/trac ./aptitude install mysql-server