bin bash function create_svn_repo Create svn repository Usage create_s

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
function create_svn_repo
# Create svn repository
# Usage:
# create_svn_repo REPOSITORYNAME NOTIFICATION@EMAIL
{
[ -z $1 ] && { echo "No repository name specified"; exit 0; }
[ -z $2 ] && { echo "No notification email specified"; exit 0; }
svnadmin create "/var/svn/${1}"
chgrp -R svn "/var/svn/${1}"
chmod -R g+w "/var/svn/${1}/db"
}
function create_svn_postcommit
# Create post-commit file in svn repository hooks directory
# Usage:
# create_svn_postcommit REPOSITORYNAME NOTIFICATION@EMAIL
{
[ -z $1 ] && { echo "No repository name specified"; exit 0; }
[ -z $2 ] && { echo "No notification email specified"; exit 0; }
echo "REPOS=\"$1\"" > "/var/svn/${1}/hooks"
echo "REV=\"$2\"" >> "/var/svn/${1}/hooks"
echo "/usr/share/subversion/hook-scripts/commit-email.pl \"$REPOS\" \"$REV\" ${2}" >> "/var/svn/${1}/hooks"
echo "TRAC_ENV=\"/var/lib/trac/sysadm\"" >> "/var/svn/${1}/hooks"
echo "/usr/bin/python /usr/local/bin/trac-post-commit-hook -p \"$TRAC_ENV\" -r \"$REV\"" >> "/var/svn/${1}/hooks"
}
function create_hg_repo
# Create mercurial repository
# Usage:
# create_hg_repo REPOSITORYNAME NOTIFICATION@EMAIL [NOTIFICATION@EMAIL2] ...
{
[ -z $1 ] && { echo "No repository name specified"; exit 0; }
[ -z $2 ] && { echo "You should specify at leat one notification email"; exit 0; }
mkdir "/var/hg/${1}"
hg init "/var/hg/${1}"
emails=""
for i in $(seq 2 $#)
do
[ ! $i == 2 ] && emails=$emails", "
email=`eval echo '$'$i`
emails=${emails}${email}
done
sed s/"\[reposubs\]\$"/"\[reposubs\]\n\/var\/hg\/${1} = ${emails}"/ /etc/mercurial/hgrc.d/notify.rc > /tmp/notify.rc.tmp
mv /tmp/notify.rc.tmp /etc/mercurial/hgrc.d/notify.rc
echo 'changegroup.trac = /var/hg/testproject/.hg/update_trac.sh >&2' >> "/var/hg/${1}/.hg/hgrc"
echo '#!/bin/sh' >> "/var/hg/${1}/.hg/update_trac.sh"
echo 'echo "Syncing TRAC repository"' >> "/var/hg/${1}/.hg/update_trac.sh"
echo 'echo "Running as user $(id -a)"' >> "/var/hg/${1}/.hg/update_trac.sh"
echo 'echo "My umask: $(umask)"' >> "/var/hg/${1}/.hg/update_trac.sh"
echo "cd /var/lib/trac/${1}/hg" >> "/var/hg/${1}/.hg/update_trac.sh"
echo "hg pull /var/hg/${1}" >> "/var/hg/${1}/.hg/update_trac.sh"
echo 'echo "Done"' >> "/var/hg/${1}/.hg/update_trac.sh"
echo 'exit 0' >> >> "/var/hg/${1}/.hg/update_trac.sh"
chmod +x "/var/hg/${1}/.hg/update_trac.sh"
}
function create_trac_project
# Create projec tin Trac
# Usage:
# create_trac_project PROJECTNAME
{
trac-admin "/var/lib/trac/${1} initenv"
mkdir "/var/lib/trac/${1}/.egg-cache/"
chown -R www-data.www-data "/var/lib/trac/${1}/"
chmod g+w "/var/lib/trac/${1}/.egg-cache/"
chmod -R g+w /var/lib/trac/sysadm/db
chmod g+w /var/lib/trac/sysadm/log/
trac-admin "/var/lib/trac/${1}/" permission add lord TRAC_ADMIN
}