Export lock_file, unlock_file
[girocco.git] / clone.sh
blob9e750c3ccd25166e87ebc097ce3107013d65c15e
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 # This removes any remnants from /srv/git/$proj.git _and_ gets rid
22 # of the group record.
23 perl -I/home/repo/repomgr/cgi -MGit::RepoCGI -e 'Git::RepoCGI::Project->ghost('"$proj"')->delete;'
24 cd .. && rm -r "$proj"
25 rm "$log"
26 exit 1
30 bang git clone --bare "$url" repodir
31 GIT_DIR=repodir bang git repack -a -d
32 ! [ -d /srv/git/"$proj".git ]
33 bang mv repodir /srv/git/"$proj".git
34 bang chmod g+w base_url owner description homepage README
35 bang mv base_url owner description homepage README /srv/git/"$proj".git/
36 cd .. && rm -r "$proj"
37 # NO bang AT THIS POINT! rm -r depends on cwd.
38 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
39 rm "$log"