![]() |
#!/bin/bash
# Name: trac_setup.sh
# Author: Andowson Chang (andowson [at] gmail [dot] com)
# Version: 0.9
# Since: 2007-01-10
# Last Modified: 2007-08-31
# 請自行依據實際環境修改這邊的參數
SETUP_DIR=/var/trac/setup
REPOSITORY=/var/trac/repos
PROJECTS=/var/trac/projects
TRAC_ADMIN_USER=admin
TRAC_ADMIN_PASSWD=admin
APACHE_USER=apache
APACHE_GROUP=tomcat
# 安裝 Python, ClearSilver, pyPgSQL, Subversion, SWIG, mod_python
# 因為要裝的東西不少,建議是建立一個目錄來存放比較好管理
mkdir -p ${SETUP_DIR}
cd ${SETUP_DIR}
# 安裝Python
yum -y install python python-devel mod_python
PYTHON_VERSION=`python -V 2>&1 | awk '{print $2}' | cut -d "." -f1-2`
# 安裝ClearSilver
yum -y install zlib-devel
wget http://www.clearsilver.net/downloads/clearsilver-0.10.5.tar.gz
tar zxf clearsilver-0.10.5.tar.gz
cd clearsilver-0.10.5
./configure --with-python=/usr/bin/python --prefix=/usr/local --disable-ruby --disable-java --disable-apache --disable-csharp --disable-perl
make
make install
cd ..
# 安裝pyPgSQL
yum -y install postgresql-devel
wget http://nchc.dl.sourceforge.net/sourceforge/pypgsql/pyPgSQL-2.5.1.tar.gz
tar zxvf pyPgSQL-2.5.1.tar.gz
cd pyPgSQL-2.5.1
python setup.py install
cd ..
# 安裝Subversion
yum -y install subversion mod_dav_svn swig
# 安裝setuptools
wget http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py
# 安裝docutils
wget http://docutils.sourceforge.net/docutils-snapshot.tgz
tar zxf docutils-snapshot.tgz
cd docutils
python setup.py install
cd tools
./rst2html.py ../FAQ.txt ../FAQ.html
cd ../..
# 安裝SilverCity
yum -y install gcc-c++ libstdc++-devel
wget http://nchc.dl.sourceforge.net/sourceforge/silvercity/SilverCity-0.9.7.tar.gz
tar zxf SilverCity-0.9.7.tar.gz
cd SilverCity-0.9.7
python setup.py install
cd ..
# 安裝enscript
yum -y install enscript
# 安裝 mxDateTime
wget http://downloads.egenix.com/python/egenix-mx-base-3.0.0.linux-i686-py${PYTHON_VERSION}_ucs4.prebuilt.zip
unzip egenix-mx-base-3.0.0.linux-i686-py${PYTHON_VERSION}_ucs4.prebuilt.zip
cd egenix-mx-base-3.0.0.linux-i686-py${PYTHON_VERSION}_ucs4.prebuilt
python setup.py build --skip install
cd ..
# 安裝Trac
wget http://ftp.edgewall.com/pub/trac/trac-0.10.4.tar.gz
tar zxf trac-0.10.4.tar.gz
cd trac-0.10.4
python setup.py install
cd ..
# 安裝WebAdmin管理介面
easy_install http://svn.edgewall.com/repos/trac/sandbox/webadmin/
# 安裝AccountManager
easy_install http://trac-hacks.org/svn/accountmanagerplugin/0.10/
# 安裝IniAdmin
easy_install http://trac-hacks.org/svn/iniadminplugin/0.11/
# 安裝Gantt圖
wget http://willbarton.com/files/TracGantt-0.3.2a-py${PYTHON_VERSION}.egg
easy_install TracGantt-0.3.2a-py${PYTHON_VERSION}.egg
# 使用mod_python和Apache整合
echo "<Location /projects>
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir ${PROJECTS}
PythonOption TracUriRoot /projects
SetEnv PYTHON_EGG_CACHE /tmp
</Location>
<LocationMatch \"/projects/[^/]+/login\">
AuthType Basic
AuthName \"Trac\"
AuthUserFile ${PROJECTS}/.htpasswd
Require valid-user
</LocationMatch>" >> /etc/httpd/conf.d/python.conf
# 使用mod_dav_svn和Apache整合
echo "<Location /svn>
DAV svn
SVNParentPath ${REPOSITORY}
AuthType Basic
AuthName \"Subversion Repository\"
AuthUserFile ${PROJECTS}/.htpasswd
AuthzSVNAccessFile ${PROJECTS}/svnaccess
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>" >> /etc/httpd/conf.d/subversion.conf
# 新建Subversion Repository Root Directory
mkdir -p ${REPOSITORY}
chown -R ${APACHE_USER}.${APACHE_GROUP} ${REPOSITORY}
# 新建Project Root Directory
mkdir -p ${PROJECTS}
chown -R ${APACHE_USER}.${APACHE_GROUP} ${PROJECTS}
# 建立共用的管理者帳號
htpasswd -bc ${PROJECTS}/.htpasswd ${TRAC_ADMIN_USER} ${TRAC_ADMIN_PASSWD}
chown ${APACHE_USER}.${APACHE_GROUP} ${PROJECTS}/.htpasswd
# 設定Repositoty存取權限
echo "[/]
* = r
${TRAC_ADMIN_USER} = rw" > ${PROJECTS}/svnaccess
service httpd restart
psql -c "create user trac_$1 createdb;" template1
psql -c "create database trac_$1 with encoding 'unicode';" -U trac_$1 template1
psql -c "alter user trac_$1 nocreatedb;" template1
psql -c "alter user trac_$1 with encrypted password 'trac_$1';" template1
su - postgres
./newtracdb.sh project1
# Name: newproject.sh
# Author: Andowson Chang (andowson [at] gmail [dot] com)
# Version: 0.9
# Last Modified: 2007-08-31
# 請自行依據實際環境修改這邊的參數
REPOSITORY=/var/trac/repos/$1
PROJECTS=/var/trac/projects
PROJECT=${PROJECTS}/$1
PROJECT_NAME="$2"
PROJECT_MANAGER=$3
DBNAME=trac_$1
DBUSER=trac_$1
DBPASSWD=trac_$1
TRAC_ADMIN_USER=admin
APACHE_USER=apache
APACHE_GROUP=tomcat
# 新建Subversion Repository
svnadmin create --fs-type fsfs ${REPOSITORY}
mkdir /tmp/$1
mkdir /tmp/$1/branches
mkdir /tmp/$1/tags
mkdir /tmp/$1/trunk
svn import /tmp/$1 file:///${REPOSITORY} --message 'Initial repository layout'
rm -rf /tmp/$1
chown -R ${APACHE_USER}.${APACHE_GROUP} ${REPOSITORY}
echo "
[$1:/]
* = r
${TRAC_ADMIN_USER} = rw
${PROJECT_MANAGER} = rw" >> ${PROJECTS}/svnaccess
# 新建一個Trac環境
trac-admin ${PROJECT} initenv "${PROJECT_NAME}" postgres://${DBUSER}:${DBPASSWD}@localhost/${DBNAME} svn ${REPOSITORY} /usr/share/trac/templates
chown -R ${APACHE_USER}.${APACHE_GROUP} ${PROJECTS}
# 設定管理者帳號
trac-admin ${PROJECT} permission add ${TRAC_ADMIN_USER} TRAC_ADMIN
trac-admin ${PROJECT} permission add ${PROJECT_MANAGER} TRAC_ADMIN
# 取消匿名使用者的部分寫入權限(以免有人惡意搗蛋)
trac-admin ${PROJECT} permission remove anonymous TICKET_CREATE TICKET_MODIFY WIKI_CREATE WIKI_MODIFY
trac-admin ${PROJECT} permission add authenticated TICKET_CREATE TICKET_MODIFY TICKET_VIEW WIKI_CREATE WIKI_MODIFY
# 啟用 WebAdmin
echo "[components]
webadmin.* = enabled
tracgantt.* = enabled
iniadmin.iniadmin.iniadminplugin = enabled
trac.web.auth.LoginModule = disabled
acct_mgr.* = enabled
[account-manager]
password_format = htpasswd
password_file = ${PROJECTS}/.htpasswd
[ticket-custom]
due_assign = text
due_assign.label = Due to assign
due_assign.value = YYYY/MM/DD
dependencies = text
dependencies.label = Dependencies
dependencies.value =
due_close= text
due_close.label = Due to close
due_close.value = YYYY/MM/DD
include_gantt = checkbox
include_gantt.label = Include in GanttChart
include_gantt.value =
[gantt-charts]
# The format of dates entered by humans in the above ticket fields
date_format = %Y/%m/%d
# Include the ticket summary in the gantt chart display
include_summary = true
# Trim the included summary to the given number of characters
summary_length = 16
# Use the creation date of a ticket as the "due assign" date if no
# assignment date is given
use_creation_date = true
# Show on the gantt chart the date the ticket was opened, to contrast
# with the assignment date.
show_opened = true" >> ${PROJECT}/conf/trac.ini
# 調整一些共同的參數
sed -i -e "s/max_size = 262144/max_size = 10000000/" -e "s/always_notify_owner = false/always_notify_owner = true/" -e "s/always_notify_reporter = false/always_notify_reporter = true/" -e "s/smtp_enabled = false/smtp_enabled = true/" -e "s/default_charset = iso-8859-15/default_charset = UTF-8/" ${PROJECT}/conf/trac.ini
trac-admin ${PROJECT} permission add anonymous GANTT_VIEW
./newproject.sh project1 "My Project1" user1
insert into session_attribute(sid, authenticated, name, value) values('admin', 1, 'email', 'admin@example.org');
insert into session_attribute(sid, authenticated, name, value) values('admin', 1, 'name', 'Andowson Chang');
insert into session_attribute(sid, authenticated, name, value) values('user1', 1, 'email', 'user1@example.org');
insert into session_attribute(sid, authenticated, name, value) values('user1', 1, 'name', 'John Doe');
insert into session_attribute(sid, authenticated, name, value) values('user2', 1, 'email', 'user2@example.org');
insert into session_attribute(sid, authenticated, name, value) values('user2', 1, 'name', 'Mary Doe');
su - postgres
psql trac_project1 trac_project1 -f session_attribute.sql
htpasswd -b /var/trac/projects/.htpasswd user1 user1pwd
htpasswd -b /var/trac/projects/.htpasswd user2 user2pwd
[/]
* = r
admin = rw
[project1:/]
* = r
admin = rw
user1 = rw
user2 = rw
檔案名稱 | session_attribute.sql |
描述 | 開發團隊成員姓名及email |
檔案大小 | 665 bytes |
下載次數 | 23 次 |
![]() |
檔案名稱 | trac_setup.sh |
描述 | Trac自動安裝程式 |
檔案大小 | 4 Kbytes |
下載次數 | 21 次 |
![]() |
檔案名稱 | newtracdb.sh |
描述 | 新增PostgreSQL資料庫程式 |
檔案大小 | 259 bytes |
下載次數 | 21 次 |
![]() |
檔案名稱 | newproject.sh |
描述 | 新增Trac專案程式 |
檔案大小 | 3 Kbytes |
下載次數 | 27 次 |
![]() |
cd /var/trac/setup
wget http://taipedia.selfip.info/templates.zh_TW.UTF-8.tar.gz
tar zxvf templates.zh_TW.UTF-8.tar.gz
mv /usr/share/trac/templates /usr/share/trac/templates.orig
mv /var/trac/setup/templates.zh_TW.UTF-8 /usr/share/trac/templates
cd /var/trac/setup
easy_install Genshi
easy_install psycopg2
easy_install docutils
easy_install Pygments
easy_install pytz
easy_install Trac
su - postgres
psql -l
pg_dump trac_project1 > /tmp/trac_project1.bak
exit
trac-admin /var/trac/projects/project1 upgrade --no-backup
trac-admin /var/trac/projects/project1 wiki upgrade
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 406, in dispatch_request
dispatcher.dispatch(req)
File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 206, in dispatch
req.hdf = HDFWrapper(loadpaths=chrome.get_all_templates_dirs())
File "/usr/lib/python2.3/site-packages/trac/web/chrome.py", line 263, in get_all_templates_dirs
dirs += provider.get_templates_dirs()
File "build/bdist.linux-i686/egg/acct_mgr/web_ui.py", line 252, in get_templates_dirs
File "/usr/lib/python2.3/site-packages/setuptools-0.6c3-py2.3.egg/pkg_resources.py", line 799, in resource_filename
return get_provider(package_or_requirement).get_resource_filename(
File "/usr/lib/python2.3/site-packages/setuptools-0.6c3-py2.3.egg/pkg_resources.py", line 1229, in get_resource_filename
return self._extract_resource(manager, zip_path)
File "/usr/lib/python2.3/site-packages/setuptools-0.6c3-py2.3.egg/pkg_resources.py", line 1235, in _extract_resource
last = self._extract_resource(
File "/usr/lib/python2.3/site-packages/setuptools-0.6c3-py2.3.egg/pkg_resources.py", line 1249, in _extract_resource
real_path = manager.get_cache_path(
File "/usr/lib/python2.3/site-packages/setuptools-0.6c3-py2.3.egg/pkg_resources.py", line 880, in get_cache_path
self.extraction_error()
File "/usr/lib/python2.3/site-packages/setuptools-0.6c3-py2.3.egg/pkg_resources.py", line 846, in extraction_error
raise err
ExtractionError: Can't extract file(s) to egg cache
The following error occurred while trying to extract file(s) to the Python egg
cache:
[Errno 13] Permission denied: '/.python-eggs'
The Python egg cache directory is currently set to:
/.python-eggs
Perhaps your account does not have write access to this directory? You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.
<Location /projects>
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /var/trac/projects
PythonOption TracUriRoot /projects
SetEnv PYTHON_EGG_CACHE /tmp
</Location>
JkUnMount /projects/* loadbalancer
JkMount /*.jsp loadbalancer
# Deny direct access to WEB-INF
<LocationMatch ".*WEB-INF.*">
Deny from all
</LocationMatch>
# Allow direct access to WEB-INF directory under /projects and /svn
<LocationMatch "[/projects/ /svn/].*/WEB-INF.*">
Allow from all
</LocationMatch>
Report execution failed: 錯誤: 欄位"modified"不存在
SELECT p.value AS __color__,
t.milestone AS __group__,
(CASE status
WHEN 'closed' THEN 'color: #777; background: #ddd; border-color: #ccc;'
ELSE
(CASE owner WHEN $USER THEN 'font-weight: bold' END)
END) AS __style__,
id AS ticket, summary, component, status,
resolution,version, t.type AS type, priority, owner,
changetime AS modified,
time AS _time,reporter AS _reporter
FROM ticket t
LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority'
ORDER BY (milestone IS NULL), milestone DESC, (status = 'closed'),
(CASE status WHEN 'closed' THEN changetime ELSE (-1)* CAST(p.value AS numeric) END) DESC
<Location /projects>
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /home/trac/projects
PythonOption TracUriRoot /projects
SetEnv PYTHON_EGG_CACHE /tmp
</Location>
<LocationMatch "/projects/[^/]+/login">
AuthType Basic
AuthName "Trac"
AuthUserFile /home/trac/projects/.htpasswd
Require valid-user
</LocationMatch>
<Location /svn>
DAV svn
SVNParentPath /home/trac/repos
<LimitExcept GET PROPFIND OPTIONS REPORT>
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /home/trac/projects/.htpasswd
AuthzSVNAccessFile /home/trac/projects/svnaccess
Require valid-user
</LimitExcept>
</Location>