about.html: Link to git/repo.git too
[girocco/testingthisout.git] / clone.sh
blobb80101067b8d93f48d49e3eaaa75ef3d9b177049
1 #!/bin/bash
3 export PATH=/home/pasky/bin:$PATH
5 set -e
7 proj="$1"
9 clone_project() {
10 log="$(mktemp -t repomgr-XXXXXX)"
11 url="$(cat base_url)"
12 mail="$(cat owner)"
14 bang() {
15 if ! "$@" >>"$log" 2>&1; then
17 echo "$* failed with error code $?"
18 echo "Log follows:"
19 cat "$log"
20 } | mail -s "[repo.or.cz] $proj clone failed" "$mail",pasky@ucw.cz
22 # This removes any remnants from /srv/git/$proj.git _and_ gets rid
23 # of the group record.
24 perl -I/home/repo/repomgr/cgi -MGit::RepoCGI -e 'Git::RepoCGI::Project->ghost('"'$proj'"')->delete;'
25 cd "$basedir" && rm -rf "$proj"/* && rmdir -p "$proj"
26 rm "$log"
27 exit 1
31 ref=()
32 if [ -s objects/info/alternates ]; then
33 ref=(--reference "$(cat objects/info/alternates | sed 's#/objects$##')")
35 bang git clone "${ref[@]}" --bare "$url" repodir
36 ! [ -d /srv/git/"$proj".git ]
37 lproj="$(echo "$proj" | sed 's/^\(.*\/\)\(.*\)/\1/')"
38 if [ z"$lproj" != z"$proj" ]; then
39 bang mkdir -m 0775 -p /srv/git/"$lproj"
41 bang mv repodir /srv/git/"$proj".git
42 bang chmod g+w base_url owner description homepage README.html
43 bang mv base_url owner description homepage README.html /srv/git/"$proj".git/
44 #bang mv objects/info/alternates /srv/git/"$proj".git/objects/info/alternates # git clone should've set up that for us
45 GIT_DIR=/srv/git/"$proj".git bang git config --bool --add mirror.allowed true
46 GIT_DIR=/srv/git/"$proj".git bang git update-server-info
47 cd "$basedir" && rm -rf "$proj"/* && rmdir -p "$proj"
48 # NO bang AT THIS POINT! rm -r depends on cwd.
49 mail -s "[repo.or.cz] $proj clone completed" "$mail",pasky@ucw.cz <<EOT
50 Congratulations! The clone of project $proj just completed. You can now adjust
51 the project settings at
53 http://repo.or.cz/m/editproj.cgi?name=$proj
55 Then check out the cool stuff at http://repo.or.cz/w/$proj.git !
56 EOT
57 rm "$log"
60 basedir=$(pwd)
62 if [ -f "$proj"/base_url ]; then
63 cd "$proj"
64 clone_project
65 else
66 # a collection of subprojects
67 find "$proj" -name base_url |
68 sed -e 's/\/base_url$//' |
69 while read proj; do
70 (cd "$proj" && clone_project) || :
71 done