trac/Ê£¿ô¥×¥í¥¸¥§¥¯¥È¤Î±¿±Ä(¿÷·Átrac¤«¤é¤ÎÊ£À½) http://www.ark-web.jp/sandbox/wiki/307.html

trac/Ê£¿ô¥×¥í¥¸¥§¥¯¥È¤Î±¿±Ä(¿÷·Átrac¤«¤é¤ÎÊ£À½)

[edit]

ÇØ·Ê

[edit]

»È¤¤Êý

[edit]

¤ä¤Ã¤Æ¤¯¤ì¤ë¤³¤È

°Ê²¼°ìÉô¤â¤¦¸Å¤¯¤ÆÆ°¤«¤Ê¤¤¤È¤³¤í¤â¤¢¤ê¤Þ¤¹¤±¤ÉÂçÂΤ³¤ó¤Ê´¶¤¸¤Ã¤Æ¤³¤È¤Ç

[edit]

½é´ü²½

# ¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¿ô¤è¤êÀßÄê
# Îã: hogehoge
PROJECT_NAME=$1

# ¥×¥í¥¸¥§¥¯¥È¥Ç¥£¥ì¥¯¥È¥ê¤Î·èÄê
# Îã: /var/www/projects/h/hogehoge
PROJECT_ROOT=/var/www/projects
PROJECT_NAME_FIRST_CHAR=`perl -e "print substr(${PROJECT_NAME}, 0, 1)"`
PROJECT_DIR=${PROJECT_ROOT}/${PROJECT_NAME_FIRST_CHAR}/${PROJECT_NAME}

# ¥Ñ¥¹¥ï¡¼¥É¤ÎÀ¸À®
# Îã) XXXXXX
PASSWORD=`mkpasswd`

# SVN¥Ç¥£¥ì¥¯¥È¥ê¤Î·èÄê
# Îã: /svnroot/projects/hogehoge
SVN_DIR=/svnroot/projects/${PROJECT_NAME}

# trac¥Ç¥£¥ì¥¯¥È¥ê¤Î·èÄê 
# Îã: /var/www/projects/h/hogehoge/trac
TRAC_DIR=${PROJECT_DIR}/trac

# trac¥Ç¡¼¥¿¥Ù¡¼¥¹Ì¾
# Îã: hogehoge_trac
TRAC_DB=${PROJECT_NAME}_trac

# PostgreSQL¤ÎURI
# Îã: postgres://hogehoge:XXXXXX@localhost/hogehoge_trac
POSTGRES_URI=postgres://${PROJECT_NAME}:${PASSWORD}\@localhost/${TRAC_DB}

# Project trac URL
# Îã: http://hogehoge.ark-web.jp
PROJECT_TRAC_URL=http://XXXXXXXXXXXXXX

# ¿÷·Átrac¤Î¥Ñ¥¹
SAMPLE_PROJECT_TRAC_DIR=${PROJECT_ROOT}/s/sample/trac

# ¿÷·Átrac¤Îsvn¥Ñ¥¹
SAMPLE_PROJECT_SVN_DIR=/svnroot/projects/sample

# ¿÷·Átrac¤ÎDB¥Ñ¥¹¥ï¡¼¥É
SAMPLE_PROJECT_TRAC_DB_PASSWORD=XXXXXX

# ¥×¥í¥¸¥§¥¯¥ÈÍÑ¥¢¥«¥¦¥ó¥È¤ÎUID¤Î¼èÆÀ¡£5000ÈÖÂæ¤Î°ìÈÖÂ礭¤Ê¿ô + 1                                                            
# Îã: 5023
PROJECT_USER_ID=`cut -d ':' -f 3 /etc/passwd  | sort -n | grep -E '^5...' | tail -1`
PROJECT_USER_ID=`expr $PROJECT_USER_ID + 1`
[edit]

¥×¥í¥¸¥§¥¯¥È¥¢¥«¥¦¥ó¥È¤ÎºîÀ®

echo useradd -u ${PROJECT_USER_ID} -g staff -d ${SVN_DIR} ${PROJECT_NAME}
[edit]

¥×¥í¥¸¥§¥¯¥È¥Ç¥£¥ì¥¯¥È¥ê¤ÎºîÀ®

echo mkdir -p ${PROJECT_DIR}/htdocs
echo chown -R ${PROJECT_NAME}:staff ${PROJECT_DIR}
echo chmod g+w -R ${PROJECT_DIR}
[edit]

SVN¥ì¥Ý¥¸¥È¥ê¤ÎºîÀ®

echo svnadmin create --fs-type fsfs ${SVN_DIR}
echo chown -R ${PROJECT_NAME}:staff ${SVN_DIR}
echo chmod -R g+w ${SVN_DIR}
[edit]

PostgreSQL¤ÎÀßÄê

# CREATE USERʸ¤Ë¤¹¤ì¤Ð¥Ñ¥¹¥ï¡¼¥É¤òµá¤á¤é¤ì¤Ê¤¯¤Æ¤¹¤à¤ó¤À¤±¤É¤ä¤Ã¤Æ¤Ê¤¤
echo sudo -u postgres createuser -S -D -R -P ${PROJECT_NAME}
echo sudo -u postgres createdb --owner=${PROJECT_NAME} ${TRAC_DB}
[edit]

trac¥Ç¥£¥ì¥¯¥È¥ê¤ÎÊ£À½

echo cp -a ${SAMPLE_PROJECT_TRAC_DIR} ${TRAC_DIR}
echo chown -R ${PROJECT_NAME}:staff ${TRAC_DIR}
echo chmod -R g+w ${TRAC_DIR}
echo chmod ugo+w ${TRAC_DIR}/attachments
echo chmod ugo+w ${TRAC_DIR}/log
echo rm -rf ${TRAC_DIR}/plugins
# ¥×¥é¥°¥¤¥ó¤Ï¿÷·Á¤ò»²¾È¤¹¤ë¤è¤¦¤Ë¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤Ë¤·¤Æ¤ª¤¯
echo ln -s ${SAMPLE_PROJECT_TRAC_DIR}/plugins ${TRAC_DIR}/plugins
[edit]

trac¥Ç¡¼¥¿¥Ù¡¼¥¹¤ÎÊ£À½

# PGPASSWORD´Ä¶­ÊÑ¿ô¤ò»È¤¨¤Ð¥Ñ¥¹¥ï¡¼¥É¤òµá¤á¤é¤ì¤Ê¤¤¤è¤¦¤Ë¤Ç¤­¤ë¤±¤É¤ä¤Ã¤Æ¤Ê¤¤
# »²¹Í) ´Ä¶­ÊÑ¿ô
# http://www.postgresql.jp/document/pg653doc/ej/programmer/libpq-envars.htm
echo "pg_dump -O -U sample sample_trac > /tmp/.setup_project_sample_trac.sql"
echo "psql -U ${PROJECT_NAME} ${TRAC_DB} < /tmp/.setup_project_sample_trac.sql"
echo "rm -f /tmp/.setup_project_sample_trac.sql"
[edit]

¥»¥Ã¥È¥¢¥Ã¥×

# trac.ini¤ÎÊѹ¹
echo perl -pi -e \'s!^name = sample!name = ${PROJECT_NAME}!\' ${TRAC_DIR}/conf/trac.ini
echo perl -pi -e \'s!^database = postgres://sample:${SAMPLE_PROJECT_TRAC_DB_PASSWORD}\@localhost/sample_trac!database = ${POSTGRES_URI}!\' ${TRAC_DIR}/conf/trac.ini
echo perl -pi -e \'s!^repository_dir = ${SAMPLE_PROJECT_SVN_DIR}!repository_dir = ${SVN_DIR}!\' ${TRAC_DIR}/conf/trac.ini
echo perl -pi -e \'s!^url = http://example.org!url = ${PROJECT_TRAC_URL}!\' ${TRAC_DIR}/conf/trac.ini
echo perl -pi -e \'s!^link = http://example.org/!link = ${PROJECT_TRAC_URL}!\' ${TRAC_DIR}/conf/trac.ini
[edit]

¥¨¥ó¥È¥ê¡¼¥Ý¥¤¥ó¥ÈÍѤÎfcgi¤ÎÀßÄê

echo cp /usr/share/trac/cgi-bin/trac.fcgi ${PROJECT_DIR}/htdocs/trac
cat <<EOB                                                                                                                    
cat <<EOF | patch -d ${PROJECT_DIR}/htdocs/                                                                                  
*** trac.orig   2008-03-05 11:57:50.000000000 +0900
--- trac      2008-03-05 11:56:57.000000000 +0900
***************
*** 15,20 ****
--- 15,23 ----
  #                                                                                                                          
  # Author: Jonas BorgstrC6m <jonas@edgewall.com>                                                                            

+ import os
+ os.environ['TRAC_ENV'] = "${TRAC_DIR}"
+
  try:
      from trac.web import fcgi_frontend
      fcgi_frontend.run()
EOF                                                                                                                          
EOB                                                                                                                          

cat <<EOB                                                                                                                    
cat > ${PROJECT_DIR}/htdocs/.htaccess <<EOF                                                                                  
<Files trac>
 SetHandler fcgid-script
</Files>
EOF                                                                                                                          
EOB
[edit]

ºÆµ¯Æ°

echo "/etc/init.d/httpd restart"

Åê¹Æ¼Ô»ÖÅÄ | ¥Ñ¡¼¥Þ¥ê¥ó¥¯

| append.gif

tag: trac, ¥Í¥Ã¥È¥ï¡¼¥¯


¥È¥Ã¥×   ÊÔ½¸ Åà·ë º¹Ê¬ ¥Ð¥Ã¥¯¥¢¥Ã¥× źÉÕ Ê£À½ ̾Á°Êѹ¹ ¥ê¥í¡¼¥É   ¿·µ¬ °ìÍ÷ ñ¸ì¸¡º÷ ºÇ½ª¹¹¿·   ¥Ø¥ë¥×   ºÇ½ª¹¹¿·¤ÎRSS
Last-modified: 2008-03-07 (¶â) 14:58:03 (6100d)

¥¢¡¼¥¯¥¦¥§¥Ö¤Î¥µ¡¼¥Ó¥¹¤ä¥½¥ê¥å¡¼¥·¥ç¥ó¤Ï¤³¤Á¤é