Offload user implementation to Git::RepoCGI::User
[girocco.git] / clone.sh
blobb384228b34e81029914dd92b004a505dc05bbb23
1 #!/bin/bash
3 export PATH=/home/pasky/bin:$PATH
5 set -e
7 log="$(mktemp -t repomgr-XXXXXX)"
8 proj="$1"
9 cd "$proj"
10 url="$(cat base_url)"
11 mail="$(cat owner)"
13 bang() {
14 if ! "$@" >>"$log" 2>&1; then
16 echo "$* failed with error code $?"
17 echo "Log follows:"
18 cat "$log"
19 } | mail -s "[repo.or.cz] $proj clone failed" "$mail",pasky@ucw.cz
21 rm -rf /srv/git/$proj.git
22 cd .. && rm -r "$proj"
23 rm "$log"
24 exit 1
28 bang git clone --bare "$url" repodir
29 GIT_DIR=repodir bang git repack -a -d
30 ! [ -d /srv/git/"$proj".git ]
31 bang mv repodir /srv/git/"$proj".git
32 bang chmod g+w base_url owner description homepage
33 bang mv base_url owner description homepage /srv/git/"$proj".git/
34 cd .. && rm -r "$proj"
35 # NO bang AT THIS POINT! rm -r depends on cwd.
36 echo "Congratulations! You can adjust the project settings in the future at http://repo.or.cz/m/p/editproj.cgi." | mail -s "[repo.or.cz] $proj clone completed" "$mail",pasky@ucw.cz
37 rm "$log"