1 | #!/bin/sh |
---|
2 | |
---|
3 | set -x |
---|
4 | export LANG=C |
---|
5 | |
---|
6 | PROJECT_NAME="${1:?"usage: $0 <PROJECT_NAME> <SUB_ROOTDIR> <SUBDOMAIN> "}" |
---|
7 | SUB_ROOTDIR="${2:?"usage: $0 <PROJECT_NAME> <SUB_ROOTDIR> <SUBDOMAIN> "}" |
---|
8 | SUBDOMAIN="${3:?"usage: $0 <PROJECT_NAME> <SUB_ROOTDIR> <SUBDOMAIN> "}" |
---|
9 | |
---|
10 | # stop script if "$1" exists |
---|
11 | isexist () { |
---|
12 | if [ -e "$1" ] ; then |
---|
13 | echo "$1" already exists |
---|
14 | exit |
---|
15 | fi |
---|
16 | } |
---|
17 | |
---|
18 | # set global environments |
---|
19 | NEWTRAC="/var/trac/${SUB_ROOTDIR}/${PROJECT_NAME}" |
---|
20 | TRACBACKUP="/var/backups/trac/${SUB_ROOTDIR}/${PROJECT_NAME}" |
---|
21 | TRACINI="/home/tools/tool/trac.ini.build" |
---|
22 | SVNPATH="/var/svn/${SUB_ROOTDIR}/${PROJECT_NAME}" |
---|
23 | |
---|
24 | # check paths to be created |
---|
25 | isexist ${NEWTRAC} |
---|
26 | isexist ${TRACBACKUP} |
---|
27 | |
---|
28 | # make trac |
---|
29 | mkdir -p ${NEWREPOS} |
---|
30 | trac-admin ${NEWTRAC} initenv ${PROJECT_NAME} sqlite:db/trac.db svn ${SVNPATH} |
---|
31 | trac-admin ${NEWTRAC} permission add mitty TRAC_ADMIN |
---|
32 | chgrp -R www-data ${NEWTRAC} |
---|
33 | chmod -R o-rw ${NEWTRAC} |
---|
34 | chmod -R g-w ${NEWTRAC} |
---|
35 | chmod -R g+w ${NEWTRAC}/attachments |
---|
36 | chmod -R g+w ${NEWTRAC}/db |
---|
37 | chmod -R g+w ${NEWTRAC}/log |
---|
38 | |
---|
39 | # make trac backup |
---|
40 | mkdir -p ${TRACBACKUP} |
---|
41 | chgrp -R www-data ${TRACBACKUP} |
---|
42 | chmod -R g+ws ${TRACBACKUP} |
---|
43 | |
---|
44 | # modify trac.ini |
---|
45 | mv ${NEWTRAC}/conf/trac.ini ${NEWTRAC}/conf/trac.ini.original |
---|
46 | cp ${TRACINI} ${NEWTRAC}/conf/trac.ini |
---|
47 | sed -i s#PROJECT_NAME#${PROJECT_NAME}#g ${NEWTRAC}/conf/trac.ini |
---|
48 | sed -i s#SUBDOMAIN#${SUBDOMAIN}#g ${NEWTRAC}/conf/trac.ini |
---|
49 | sed -i s#SUB_ROOTDIR#${SUB_ROOTDIR}#g ${NEWTRAC}/conf/trac.ini |
---|
50 | sed -i s#SVNPATH#${SVNPATH}#g ${NEWTRAC}/conf/trac.ini |
---|
51 | chgrp -R www-data ${NEWTRAC}/conf/trac.ini |
---|
52 | chmod -R g+w ${NEWTRAC}/conf/trac.ini |
---|
53 | chmod g+w ${NEWTRAC}/conf |
---|
54 | |
---|
55 | |
---|
56 | echo "done" |
---|
57 | echo "${NEWTRAC} ${TRACBACKUP} are created" |
---|